@@ -2,7 +2,10 @@ name: CI
22
33on :
44 push :
5- branches : [ "main" ]
5+ branches :
6+ - main
7+ - preview
8+ - next-release
69 tags :
710 - ' v*'
811 paths-ignore :
@@ -15,165 +18,166 @@ on:
1518 - ' CHANGELOG.md'
1619 workflow_dispatch :
1720
18- jobs :
19- prepare :
20- runs-on : windows-latest
21- outputs :
22- semVer : ${{ steps.version.outputs.semVer }}
23- fullSemVer : ${{ steps.version.outputs.fullSemVer }}
24- major : ${{ steps.version.outputs.major }}
25- minor : ${{ steps.version.outputs.minor }}
26- patch : ${{ steps.version.outputs.patch }}
27- steps :
28- # Checkout code
29- - name : Checkout code
30- uses : actions/checkout@v4
31- with :
32- fetch-depth : 0
33-
34- # Install GitVersion and calculate version
35- - name : Setup GitVersion
36- uses : gittools/actions/gitversion/setup@v3.2.1
37- with :
38- versionSpec : ' 5.12.0'
21+ env :
22+ buildFolderName : output
23+ buildArtifactName : output
24+ testResultFolderName : testResults
3925
40- - name : Determine Version
41- id : version # step id used as a reference for output values
42- uses : gittools/actions/gitversion/execute@v3.2.1
43- with :
44- useConfigFile : true
45- configFilePath : ' GitVersion.yml'
46-
47- - name : Display GitVersion outputs
48- run : |
49- echo "SemVer: ${{ steps.version.outputs.semVer }}"
50- echo "FullSemVer: ${{ steps.version.outputs.fullSemVer }}"
51- echo "Major: ${{ steps.version.outputs.major }}"
52- echo "Minor: ${{ steps.version.outputs.minor }}"
53- echo "Patch: ${{ steps.version.outputs.patch }}"
54-
55- test_powershell_core :
56- runs-on : windows-latest
57- needs : prepare
58- steps :
59- # Checkout code
60- - name : Checkout code
61- uses : actions/checkout@v4
62- with :
63- fetch-depth : 0
64-
65- # Resolve Dependency and Build Module
66- - name : Resolve Dependency and Build Module
67- env :
68- ModuleVersion : ${{ needs.prepare.outputs.semVer }}
69- ModuleFullVersion : ${{ needs.prepare.outputs.fullSemVer }}
70- ModuleMajor : ${{ needs.prepare.outputs.major }}
71- ModuleMinor : ${{ needs.prepare.outputs.minor }}
72- ModulePatch : ${{ needs.prepare.outputs.patch }}
73- run : |
74- ./build.ps1 -tasks noop -ResolveDependency -UseModuleFast
75- ./build.ps1 -tasks build
76- shell : pwsh
77-
78- # Run Tests and Publish Test Results
79- - name : Run Tests and Publish Test Results
80- env :
81- ModuleVersion : ${{ needs.prepare.outputs.semVer }}
82- ModuleFullVersion : ${{ needs.prepare.outputs.fullSemVer }}
83- ModuleMajor : ${{ needs.prepare.outputs.major }}
84- ModuleMinor : ${{ needs.prepare.outputs.minor }}
85- ModulePatch : ${{ needs.prepare.outputs.patch }}
86- run : ./build.ps1 -tasks test
87- shell : pwsh
88-
89- # # Publish Test Results Artifact
90- # - name: Publish Test Results Artifact
91- # if: always()
92- # uses: actions/upload-artifact@v2
93- # with:
94- # name: CodeCoverageWinPS5
95- # path: ${{ secrets.buildFolderName }}/${{ secrets.testResultFolderName }}/NUnit*.xml
96-
97- # test_windows_powershell:
26+ jobs :
27+ # prepare:
9828 # runs-on: windows-latest
99- # needs: [prepare, test_powershell_core]
29+ # outputs:
30+ # semVer: ${{ steps.version.outputs.LegacySemVerPadded }}
31+ # fullSemVer: ${{ steps.version.outputs.LegacySemVerPadded }}
32+ # major: ${{ steps.version.outputs.major }}
33+ # minor: ${{ steps.version.outputs.minor }}
34+ # patch: ${{ steps.version.outputs.patch }}
10035 # steps:
10136 # # Checkout code
10237 # - name: Checkout code
10338 # uses: actions/checkout@v4
10439 # with:
10540 # fetch-depth: 0
10641
107- # # Resolve Dependency and Build Module
108- # - name: Resolve Dependency and Build Module
109- # env:
110- # ModuleVersion: ${{ needs.prepare.outputs.semVer }}
111- # ModuleFullVersion: ${{ needs.prepare.outputs.fullSemVer }}
112- # ModuleMajor: ${{ needs.prepare.outputs.major }}
113- # ModuleMinor: ${{ needs.prepare.outputs.minor }}
114- # ModulePatch: ${{ needs.prepare.outputs.patch }}
115- # run: |
116- # ./build.ps1 -tasks noop -ResolveDependency -UseModuleFast
117- # ./build.ps1 -tasks build
118- # shell: pwsh
119-
120- # # Run Tests and Publish Test Results
121- # - name: Run Tests and Publish Test Results
122- # env:
123- # ModuleVersion: ${{ needs.prepare.outputs.semVer }}
124- # ModuleFullVersion: ${{ needs.prepare.outputs.fullSemVer }}
125- # ModuleMajor: ${{ needs.prepare.outputs.major }}
126- # ModuleMinor: ${{ needs.prepare.outputs.minor }}
127- # ModulePatch: ${{ needs.prepare.outputs.patch }}
128- # run: ./build.ps1 -tasks test
129- # shell: powershell
42+ # # Install GitVersion and calculate version
43+ # - name: Setup GitVersion
44+ # uses: gittools/actions/gitversion/setup@v3.2.1
45+ # with:
46+ # versionSpec: '5.12.0'
13047
131- # # Publish Test Results Artifact for PS7
132- # - name: Publish Test Results Artifact for PS7
133- # if: always()
134- # uses: actions/upload-artifact@v2
48+ # - name: Determine Version
49+ # id: version # step id used as a reference for output values
50+ # uses: gittools/actions/gitversion/execute@v3.2.1
13551 # with:
136- # name: CodeCoverageWinPS7
137- # path: ${{ secrets.buildFolderName }}/${{ secrets.testResultFolderName }}/NUnit*.xml
52+ # useConfigFile: true
53+ # configFilePath: 'GitVersion.yml'
13854
139- deploy :
140- runs-on : windows-latest
141- # needs: [prepare, test_powershell_core, test_windows_powershell]
142- needs : [prepare, test_powershell_core]
143- env :
144- ModuleVersion : ${{ needs.prepare.outputs.semVer }}
145- ModuleFullVersion : ${{ needs.prepare.outputs.fullSemVer }}
146- ModuleMajor : ${{ needs.prepare.outputs.major }}
147- ModuleMinor : ${{ needs.prepare.outputs.minor }}
148- ModulePatch : ${{ needs.prepare.outputs.patch }}
55+ # - name: Display GitVersion outputs
56+ # run: |
57+ # echo "SemVer: ${{ steps.version.outputs.LegacySemVerPadded }}"
58+ # echo "FullSemVer: ${{ steps.version.outputs.LegacySemVerPadded }}"
59+ # echo "Major: ${{ steps.version.outputs.major }}"
60+ # echo "Minor: ${{ steps.version.outputs.minor }}"
61+ # echo "Patch: ${{ steps.version.outputs.patch }}"
62+
63+ Build_Stage_Package_Module :
64+ name : Package Module
65+ runs-on : ubuntu-latest
66+ steps :
67+ - name : Checkout Code
68+ uses : actions/checkout@v3
69+ with :
70+ ref : ${{ github.head_ref }} # checkout the correct branch name
71+ fetch-depth : 0
72+ - name : Install GitVersion
73+ uses : gittools/actions/gitversion/setup@v0.9.15
74+ with :
75+ versionSpec : 5.x
76+ - name : Evaluate Next Version
77+ uses : gittools/actions/gitversion/execute@v0.9.15
78+ with :
79+ configFilePath : GitVersion.yml
80+ - name : Build & Package Module
81+ shell : pwsh
82+ run : ./build.ps1 -ResolveDependency -tasks pack -Verbose
83+ env :
84+ ModuleVersion : ${{ env.gitVersion.NuGetVersionV2 }}
85+ - name : Publish Build Artifact
86+ uses : actions/upload-artifact@v4
87+ with :
88+ name : ${{ env.buildArtifactName }}
89+ path : ${{ env.buildFolderName }}/
14990
150- if : github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
91+ test_powershell_core :
92+ name : Test Windows PowerShell Core
93+ runs-on : windows-latest
94+ needs : Build_Stage_Package_Module
15195 steps :
152- # Checkout code and set up .NET Core environment for deployment stage.
153- - name : Checkout code and set up .NET Core environment.
154- uses : actions/checkout@v2
96+ - name : Checkout Code
97+ uses : actions/checkout@v3
98+ with :
99+ ref : ${{ github.head_ref }} # checkout the correct branch name
100+ fetch-depth : 0
101+ - name : Download Build Artifact
102+ uses : actions/download-artifact@v4
103+ with :
104+ name : ${{ env.buildArtifactName }}
105+ path : ${{ env.buildFolderName }}
106+ - name : Run Tests
107+ shell : pwsh
108+ run : ./build.ps1 -tasks noop; ./build.ps1 -tasks test
109+ - name : Publish Test Artifact
110+ uses : actions/upload-artifact@v4
111+ with :
112+ path : ${{ env.buildFolderName }}/${{ env.testResultFolderName }}/
113+ name : CodeCoverageWinPS7
114+ if : success() || failure()
155115
156- # # Check PSRepository for deployment stage.
157- # - name: Check PSRepository
158- # run: |
159- # if (Get-PSResourceRepository -Name ${{ secrets.repositoryName }} -ErrorAction SilentlyContinue) {
160- # Unregister-PSResourceRepository -Name ${{ secrets.repositoryName }}
161- # }
162- # Register-PSResourceRepository -Name ${{ secrets.repositoryName }} -Uri ${{ secrets.repositoryUri }} -Trusted
163- # Get-PSResourceRepository -Name ${{ secrets.repositoryName }} -ErrorAction Stop
116+ deploy :
117+ name : Deploy Module
118+ runs-on : windows-latest
119+ needs : test_powershell_core
120+ steps :
121+ - name : Checkout Code
122+ uses : actions/checkout@v3
123+ with :
124+ ref : ${{ github.head_ref }} # checkout the correct branch name
125+ fetch-depth : 0
126+ - name : Download Build Artifact
127+ uses : actions/download-artifact@v4
128+ with :
129+ name : ${{ env.buildArtifactName }}
130+ path : ${{ env.buildFolderName }}
131+ - name : Publish Release
132+ shell : pwsh
133+ run : ./build.ps1 -tasks publish
134+ env :
135+ GitHubToken : ${{ secrets.GitHubToken }}
136+ GalleryApiToken : ${{ secrets.GalleryApiToken }}
137+
138+ # deploy:
139+ # runs-on: windows-latest
140+ # # needs: [prepare, test_powershell_core, test_windows_powershell]
141+ # needs: [prepare, test_powershell_core]
142+ # env:
143+ # ModuleVersion: ${{ needs.prepare.outputs.LegacySemVerPadded }}
144+ # ModuleFullVersion: ${{ needs.prepare.outputs.LegacySemVerPadded }}
145+ # ModuleMajor: ${{ needs.prepare.outputs.major }}
146+ # ModuleMinor: ${{ needs.prepare.outputs.minor }}
147+ # ModulePatch: ${{ needs.prepare.outputs.patch }}
148+
149+ # # if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
150+ # if: |
151+ # github.ref == 'refs/heads/main' ||
152+ # github.ref == 'refs/heads/preview' ||
153+ # github.ref == 'refs/heads/next-release' ||
154+ # startsWith(github.ref, 'refs/tags/')
155+ # steps:
156+ # # Checkout code and set up .NET Core environment for deployment stage.
157+ # - name: Checkout code and set up .NET Core environment.
158+ # uses: actions/checkout@v2
159+
160+ # # # Check PSRepository for deployment stage.
161+ # # - name: Check PSRepository
162+ # # run: |
163+ # # if (Get-PSResourceRepository -Name ${{ secrets.repositoryName }} -ErrorAction SilentlyContinue) {
164+ # # Unregister-PSResourceRepository -Name ${{ secrets.repositoryName }}
165+ # # }
166+ # # Register-PSResourceRepository -Name ${{ secrets.repositoryName }} -Uri ${{ secrets.repositoryUri }} -Trusted
167+ # # Get-PSResourceRepository -Name ${{ secrets.repositoryName }} -ErrorAction Stop
168+ # # shell: pwsh
169+
170+ # # Build Release package using the build script.
171+ # - name: Build Release
172+ # run: $verbosePreference='Continue'; ./build.ps1 -tasks pack -ResolveDependency -UseModuleFast
164173 # shell: pwsh
165174
166- # Build Release package using the build script.
167- - name : Build Release
168- run : ./build.ps1 -tasks pack -ResolveDependency -UseModuleFast
169- shell : pwsh
170-
171- # Publish Release package to the repository.
172- - name : Publish Release
173- run : ./build.ps1 -tasks publish -UseModuleFast
174- shell : pwsh
175- env :
176- # ReleaseBranch: ${{ secrets.defaultBranch }}
177- # MainGitBranch: ${{ secrets.defaultBranch }}
178- GalleryApiToken : ${{ secrets.GalleryApiToken }}
179- # PSModuleFeed: ${{ secrets.repositoryName }}
175+ # # Publish Release package to the repository.
176+ # - name: Publish Release
177+ # run: ./build.ps1 -tasks publish -UseModuleFast
178+ # shell: pwsh
179+ # env:
180+ # # ReleaseBranch: ${{ secrets.defaultBranch }}
181+ # # MainGitBranch: ${{ secrets.defaultBranch }}
182+ # GalleryApiToken: ${{ secrets.GalleryApiToken }}
183+ # # PSModuleFeed: ${{ secrets.repositoryName }}
0 commit comments