20
20
powerShellModuleName :
21
21
description : ' The name of the PowerShell module being built.'
22
22
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 }}
29
35
deployFilesArtifactName :
30
36
description : ' The name of the deploy files artifact created by the build.'
31
37
value : ${{ jobs.build-and-test.outputs.deployFilesArtifactName }}
34
40
powerShellModuleName : ' ScriptModuleRepositoryTemplate'
35
41
powerShellModuleDirectoryPath : ' ./src/ScriptModuleRepositoryTemplate'
36
42
deployFilesDirectoryPath : ' ./deploy'
37
- prereleaseModuleArtifactName : ' PrereleaseModuleArtifact'
38
- prereleaseModuleArtifactDirectoryPath : ' ./artifacts/Prerelease'
39
- stableModuleArtifactName : ' StableModuleArtifact'
40
- stableModuleArtifactDirectoryPath : ' ./artifacts/Stable'
43
+ moduleArtifactName : ' ModuleArtifact'
44
+ moduleArtifactDirectoryPath : ' ./artifacts/Module'
41
45
deployFilesArtifactName : ' DeployFilesArtifact'
42
46
deployFilesArtifactDirectoryPath : ' ./artifacts/deploy'
43
47
46
50
runs-on : windows-latest # Use Windows agent to ensure dotnet.exe is available to build C# assemblies, if required.
47
51
outputs :
48
52
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 }}
51
57
deployFilesArtifactName : ${{ env.deployFilesArtifactName }}
52
58
steps :
53
59
- name : Checkout the repo source code
72
78
uses : gittools/actions/gitversion/execute@v0
73
79
74
80
- name : Determine the new version number
81
+ id : version-number
75
82
shell : pwsh
76
83
run : |
77
84
[string] $newVersionNumber = '${{ steps.git-version.outputs.majorMinorPatch }}'
91
98
# PowerShell prerelease labels can only contain the characters 'a-zA-Z0-9', so sanitize it if needed.
92
99
$newVersionNumberPrereleaseLabel = $prereleaseLabel -replace '[^a-zA-Z0-9]', ''
93
100
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
97
104
98
105
- name : Run PowerShell linter with PSScriptAnalyzer
99
106
shell : pwsh
@@ -132,40 +139,25 @@ jobs:
132
139
min-coverage-overall : 60
133
140
min-coverage-changed-files : 60
134
141
135
- - name : Create Stable and Prerelease module artifacts
142
+ - name : Create the module artifact
136
143
shell : pwsh
137
144
run : |
138
145
Write-Output "Reading in environment variables."
139
146
[string] $moduleName = $Env:powerShellModuleName
140
147
[string] $moduleDirectoryPath = $Env:powerShellModuleDirectoryPath
141
148
[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}}'
146
152
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
149
155
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
152
158
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
169
161
170
162
- name : Create deploy files artifact
171
163
shell : pwsh
@@ -181,7 +173,7 @@ jobs:
181
173
if : github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
182
174
shell : pwsh
183
175
run : |
184
- [string] $newVersionNumber = $Env:NewVersionNumberMajorMinorPatch
176
+ [string] $newVersionNumber = '${{ steps.version-number.outputs.majorMinorPatch}}'
185
177
[string] $newVersionTag = "v$newVersionNumber"
186
178
187
179
# To avoid a 403 error on 'git push', ensure you have granted your GitHub Actions workflow read/write permission.
@@ -192,17 +184,11 @@ jobs:
192
184
& git tag $newVersionTag
193
185
& git push origin $newVersionTag
194
186
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
202
188
uses : actions/upload-artifact@v4
203
189
with :
204
- name : ${{ env.stableModuleArtifactName }}
205
- path : ${{ env.stableModuleArtifactDirectoryPath }}
190
+ name : ${{ env.moduleArtifactName }}
191
+ path : ${{ env.moduleArtifactDirectoryPath }}
206
192
207
193
- name : Upload deploy files artifact
208
194
uses : actions/upload-artifact@v4
0 commit comments