2020 powerShellModuleName :
2121 description : ' The name of the PowerShell module being built.'
2222 value : ${{ jobs.build-and-test.outputs.powerShellModuleName }}
23- prereleaseModuleArtifactName :
24- description : ' The name of the prerelease module artifact created by the build.'
25- value : ${{ jobs.build-and-test.outputs.prereleaseModuleArtifactName }}
26- stableModuleArtifactName :
27- description : ' The name of the stable module artifact created by the build.'
28- value : ${{ jobs.build-and-test.outputs.stableModuleArtifactName }}
23+ stableVersionNumber :
24+ description : ' The stable version number of the PowerShell module created by the build.'
25+ value : ${{ jobs.build-and-test.outputs.stableVersionNumber }}
26+ prereleaseVersionNumber :
27+ description : ' The full prerelease version number of the PowerShell module created by the build.'
28+ value : ${{ jobs.build-and-test.outputs.prereleaseVersionNumber }}
29+ prereleaseVersionLabel :
30+ description : ' The prerelease label of the PowerShell module created by the build.'
31+ value : ${{ jobs.build-and-test.outputs.prereleaseVersionLabel }}
32+ moduleArtifactName :
33+ description : ' The name of the module artifact created by the build.'
34+ value : ${{ jobs.build-and-test.outputs.moduleArtifactName }}
2935 deployFilesArtifactName :
3036 description : ' The name of the deploy files artifact created by the build.'
3137 value : ${{ jobs.build-and-test.outputs.deployFilesArtifactName }}
3440 powerShellModuleName : ' ScriptModuleRepositoryTemplate'
3541 powerShellModuleDirectoryPath : ' ./src/ScriptModuleRepositoryTemplate'
3642 deployFilesDirectoryPath : ' ./deploy'
37- prereleaseModuleArtifactName : ' PrereleaseModuleArtifact'
38- prereleaseModuleArtifactDirectoryPath : ' ./artifacts/Prerelease'
39- stableModuleArtifactName : ' StableModuleArtifact'
40- stableModuleArtifactDirectoryPath : ' ./artifacts/Stable'
43+ moduleArtifactName : ' ModuleArtifact'
44+ moduleArtifactDirectoryPath : ' ./artifacts/Module'
4145 deployFilesArtifactName : ' DeployFilesArtifact'
4246 deployFilesArtifactDirectoryPath : ' ./artifacts/deploy'
4347
4650 runs-on : windows-latest # Use Windows agent to ensure dotnet.exe is available to build C# assemblies, if required.
4751 outputs :
4852 powerShellModuleName : ${{ env.powerShellModuleName }}
49- prereleaseModuleArtifactName : ${{ env.prereleaseModuleArtifactName }}
50- stableModuleArtifactName : ${{ env.stableModuleArtifactName }}
53+ stableVersionNumber : ${{ steps.version-number.outputs.majorMinorPatch }}
54+ prereleaseVersionNumber : ${{ steps.version-number.outputs.majorMinorPatch }}-${{ steps.version-number.outputs.prereleaseLabel }}
55+ prereleaseVersionLabel : ${{ steps.version-number.outputs.prereleaseLabel}}
56+ moduleArtifactName : ${{ env.moduleArtifactName }}
5157 deployFilesArtifactName : ${{ env.deployFilesArtifactName }}
5258 steps :
5359 - name : Checkout the repo source code
7278 uses : gittools/actions/gitversion/execute@v0
7379
7480 - name : Determine the new version number
81+ id : version-number
7582 shell : pwsh
7683 run : |
7784 [string] $newVersionNumber = '${{ steps.git-version.outputs.majorMinorPatch }}'
9198 # PowerShell prerelease labels can only contain the characters 'a-zA-Z0-9', so sanitize it if needed.
9299 $newVersionNumberPrereleaseLabel = $prereleaseLabel -replace '[^a-zA-Z0-9]', ''
93100
94- Write-Output "Setting new environment variables 'NewVersionNumberMajorMinorPatch =$newVersionNumber' and 'NewVersionNumberPrereleaseLabel =$newVersionNumberPrereleaseLabel'."
95- "NewVersionNumberMajorMinorPatch =$newVersionNumber" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
96- "NewVersionNumberPrereleaseLabel =$newVersionNumberPrereleaseLabel" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
101+ Write-Output "Setting step output variables 'majorMinorPatch =$newVersionNumber' and 'prereleaseLabel =$newVersionNumberPrereleaseLabel'."
102+ "majorMinorPatch =$newVersionNumber" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
103+ "prereleaseLabel =$newVersionNumberPrereleaseLabel" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
97104
98105 - name : Run PowerShell linter with PSScriptAnalyzer
99106 shell : pwsh
@@ -132,40 +139,25 @@ jobs:
132139 min-coverage-overall : 60
133140 min-coverage-changed-files : 60
134141
135- - name : Create Stable and Prerelease module artifacts
142+ - name : Create the module artifact
136143 shell : pwsh
137144 run : |
138145 Write-Output "Reading in environment variables."
139146 [string] $moduleName = $Env:powerShellModuleName
140147 [string] $moduleDirectoryPath = $Env:powerShellModuleDirectoryPath
141148 [string] $moduleManifestFileName = $moduleName + '.psd1'
142- [string] $prereleaseArtifactModuleDirectoryPath = Join-Path -Path $Env:prereleaseModuleArtifactDirectoryPath -ChildPath $moduleName
143- [string] $stableArtifactModuleDirectoryPath = Join-Path -Path $Env:stableModuleArtifactDirectoryPath -ChildPath $moduleName
144- [string] $newVersionNumber = $Env:NewVersionNumberMajorMinorPatch
145- [string] $newVersionNumberPrereleaseLabel = $Env:NewVersionNumberPrereleaseLabel
149+ [string] $moduleManifestFilePath = Join-Path -Path $moduleDirectoryPath -ChildPath $moduleManifestFileName
150+ [string] $moduleArtifactDirectoryPath = Join-Path -Path $Env:moduleArtifactDirectoryPath -ChildPath $moduleName
151+ [string] $newVersionNumber = '${{ steps.version-number.outputs.majorMinorPatch}}'
146152
147- Write-Output "Copying the module files to the Prerelease artifact directory '$prereleaseArtifactModuleDirectoryPath '."
148- Copy-Item -Path $moduleDirectoryPath -Destination $prereleaseArtifactModuleDirectoryPath -Exclude '*.Tests.ps1' -Recurse -Force
153+ Write-Output "Updating the version number of the module manifest file '$moduleManifestFilePath' to '$newVersionNumber '."
154+ Update-ModuleManifest -Path $moduleManifestFilePath -ModuleVersion $newVersionNumber
149155
150- Write-Output "Copying the module files to the Stable artifact directory '$stableArtifactModuleDirectoryPath' ."
151- Copy-Item -Path $moduleDirectoryPath -Destination $stableArtifactModuleDirectoryPath -Exclude '*.Tests.ps1' -Recurse -Force
156+ Write-Output "Testing the module manifest file '$moduleManifestFilePath' to ensure it is valid ."
157+ Test-ModuleManifest -Path $moduleManifestFilePath
152158
153- Write-Output "Determining what the module manifest file paths are."
154- [string] $manifestFilePath = Join-Path -Path $moduleDirectoryPath -ChildPath $moduleManifestFileName
155- [string] $prereleaseManifestFilePath = Join-Path -Path $prereleaseArtifactModuleDirectoryPath -ChildPath $moduleManifestFileName
156- [string] $stableManifestFilePath = Join-Path -Path $stableArtifactModuleDirectoryPath -ChildPath $moduleManifestFileName
157-
158- Write-Output "Updating the prerelease manifest's version number to '$newVersionNumber-$newVersionNumberPrereleaseLabel'."
159- Update-ModuleManifest -Path $prereleaseManifestFilePath -ModuleVersion $newVersionNumber -Prerelease $newVersionNumberPrereleaseLabel
160-
161- Write-Output "Updating the stable manifest's version number to '$newVersionNumber'."
162- Update-ModuleManifest -Path $stableManifestFilePath -ModuleVersion $newVersionNumber
163-
164- Write-Output "Testing the Prerelease manifest file '$prereleaseManifestFilePath' to ensure it is valid."
165- Test-ModuleManifest -Path $prereleaseManifestFilePath
166-
167- Write-Output "Testing the Stable manifest file '$stableManifestFilePath' to ensure it is valid."
168- Test-ModuleManifest -Path $stableManifestFilePath
159+ Write-Output "Copying the module files to the module artifact directory '$moduleArtifactDirectoryPath'."
160+ Copy-Item -Path $moduleDirectoryPath -Destination $moduleArtifactDirectoryPath -Exclude '*.Tests.ps1' -Recurse -Force
169161
170162 - name : Create deploy files artifact
171163 shell : pwsh
@@ -181,7 +173,7 @@ jobs:
181173 if : github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
182174 shell : pwsh
183175 run : |
184- [string] $newVersionNumber = $Env:NewVersionNumberMajorMinorPatch
176+ [string] $newVersionNumber = '${{ steps.version-number.outputs.majorMinorPatch}}'
185177 [string] $newVersionTag = "v$newVersionNumber"
186178
187179 # To avoid a 403 error on 'git push', ensure you have granted your GitHub Actions workflow read/write permission.
@@ -192,17 +184,11 @@ jobs:
192184 & git tag $newVersionTag
193185 & git push origin $newVersionTag
194186
195- - name : Upload prerelease module artifact
196- uses : actions/upload-artifact@v4
197- with :
198- name : ${{ env.prereleaseModuleArtifactName }}
199- path : ${{ env.prereleaseModuleArtifactDirectoryPath }}
200-
201- - name : Upload stable module artifact
187+ - name : Upload module artifact
202188 uses : actions/upload-artifact@v4
203189 with :
204- name : ${{ env.stableModuleArtifactName }}
205- path : ${{ env.stableModuleArtifactDirectoryPath }}
190+ name : ${{ env.moduleArtifactName }}
191+ path : ${{ env.moduleArtifactDirectoryPath }}
206192
207193 - name : Upload deploy files artifact
208194 uses : actions/upload-artifact@v4
0 commit comments