@@ -14,62 +14,50 @@ trigger:
1414pr :
1515- master
1616
17+ variables :
18+ NupkgArtifactName : ' PSKoans.nupkg'
19+
1720stages :
18- - stage : LinuxTests
19- displayName : ' Linux '
21+ - stage : UploadChangelog
22+ displayName : ' Upload Changelog '
2023 dependsOn : []
24+ condition : startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
2125
2226 jobs :
23- - job : Linux
24- displayName : ' Pester Tests '
27+ - job : GenerateChangelog
28+ displayName : " Generate Changelog "
2529
2630 pool :
2731 vmImage : ubuntu-latest
2832
29- steps :
30- - template : templates/environment-setup.yml
31- - template : templates/test-steps.yml
32-
33- - stage : WindowsTests
34- displayName : ' Windows'
35- dependsOn : []
36-
37- jobs :
38- - job : Windows
39- displayName : ' Pester Tests'
40-
41- pool :
42- vmImage : windows-latest
33+ variables :
34+ FilePath : ' $(System.DefaultWorkingDirectory)/Changelog.md'
4335
4436 steps :
45- - template : templates/environment-setup.yml
46- - template : templates/test-steps.yml
47-
48- - stage : MacOSTests
49- displayName : ' MacOS'
50- dependsOn : []
51-
52- jobs :
53- - job : MacOS
54- displayName : ' Pester Tests'
37+ - task : PowerShell@2
38+ displayName : ' Create Changelog'
39+ inputs :
40+ targetType : ' filepath'
41+ filePath : ./Build/New-Changelog.ps1
42+ arguments : -Path '$(FilePath)' -ApiKey $(GithubApiKey) -Verbose
5543
56- pool :
57- vmImage : macOS-latest
44+ - task : PublishPipelineArtifact@1
45+ displayName : ' Publish Changelog'
46+ inputs :
47+ path : ' $(FilePath)'
48+ artifact : Changelog
5849
59- steps :
60- - template : templates/environment-setup.yml
61- - template : templates/test-steps.yml
50+ - stage : Build
51+ displayName : ' Build PSKoans '
52+ dependsOn : []
6253
63- - stage : PublishModule
64- displayName : ' Create Module'
65- dependsOn :
66- - LinuxTests
67- - WindowsTests
68- - MacOSTests
54+ variables :
55+ FileSystemDeploymentPath : ' $(System.DefaultWorkingDirectory)/Deploy/FileSystem'
56+ BuiltModulePath : ' $(System.DefaultWorkingDirectory)/Deploy/PSKoans'
6957
7058 jobs :
71- - job : BuildModule
72- displayName : " Build PSKoans "
59+ - job : BuildNupkg
60+ displayName : ' Module Nupkg '
7361
7462 pool :
7563 vmImage : ubuntu-latest
@@ -78,7 +66,7 @@ stages:
7866 - template : templates/environment-setup.yml
7967
8068 - task : PowerShell@2
81- displayName : ' Initialize Environment '
69+ displayName : ' Stage PSKoans Module '
8270
8371 inputs :
8472 targetType : ' filePath'
@@ -91,34 +79,19 @@ stages:
9179 - task : PublishPipelineArtifact@1
9280 displayName : ' Publish Built Module Artifact'
9381 inputs :
94- path : ' $(BuiltModuleFolder)/PSKoans '
82+ path : ' $(BuiltModulePath) '
9583 artifact : PSKoans
9684
97- - job : PublishFiles
98- dependsOn : BuildModule
99- displayName : " Publish Artifacts"
100-
101- pool :
102- vmImage : ubuntu-latest
103- variables :
104- builtModulePath : ' $(System.DefaultWorkingDirectory)/Deploy/PSKoans'
105- fileSystemDeploymentPath : ' $(System.DefaultWorkingDirectory)/Deploy/FileSystem'
106-
107- steps :
108- - template : templates/environment-setup.yml
109-
110- - task : DownloadPipelineArtifact@2
111- displayName : ' Download Built Module Artifact'
112- inputs :
113- artifact : PSKoans
114- path : $(builtModulePath)
85+ - template : ./templates/register-local-repo.yml
86+ parameters :
87+ repositoryPath : ' $(FileSystemDeploymentPath)'
11588
11689 - task : PowerShell@2
11790 displayName : ' Create Module Nupkg'
11891 inputs :
11992 targetType : ' filePath'
12093 filePath : ./Deploy/Publish.ps1
121- arguments : -Key 'filesystem' -Path '$(fileSystemDeploymentPath )' -OutputDirectory '$(fileSystemDeploymentPath )'
94+ arguments : -Key 'filesystem' -Path '$(FileSystemDeploymentPath )' -OutputDirectory '$(FileSystemDeploymentPath )'
12295
12396 errorActionPreference : ' stop'
12497 failOnStderr : true
@@ -128,18 +101,107 @@ stages:
128101 displayName : ' Publish Nupkg Artifact'
129102 inputs :
130103 path : ' $(NupkgPath)'
131- artifact : PSKoans.nupkg
104+ artifact : ' $(NupkgArtifactName) '
132105
106+ - stage : LinuxTests
107+ displayName : ' Linux'
108+ dependsOn :
109+ - Build
110+
111+ variables :
112+ PackageDownloadPath : ' $(System.DefaultWorkingDirectory)/Module'
113+ PSRepositoryName : ' FileSystem'
114+
115+ jobs :
116+ - job : Linux
117+ displayName : ' Pester Tests'
118+
119+ pool :
120+ vmImage : ubuntu-latest
121+
122+ steps :
123+ - template : templates/environment-setup.yml
124+
125+ - template : ./templates/install-built-module.yml
126+ parameters :
127+ repositoryPath : ' $(PackageDownloadPath)'
128+ repositoryName : ' $(PSRepositoryName)'
129+ artifactName : ' $(NupkgArtifactName)'
130+
131+ - template : templates/test-steps.yml
132+
133+ - stage : WindowsTests
134+ displayName : ' Windows'
135+ dependsOn :
136+ - Build
137+
138+ variables :
139+ PackageDownloadPath : ' $(System.DefaultWorkingDirectory)/Module'
140+ PSRepositoryName : ' FileSystem'
141+
142+ jobs :
143+ - job : Windows
144+ displayName : ' Pester Tests'
145+
146+ pool :
147+ vmImage : windows-latest
148+
149+ steps :
150+ - template : templates/environment-setup.yml
151+
152+ - template : ./templates/install-built-module.yml
153+ parameters :
154+ repositoryPath : ' $(PackageDownloadPath)'
155+ repositoryName : ' $(PSRepositoryName)'
156+ artifactName : ' $(NupkgArtifactName)'
157+
158+ - template : templates/test-steps.yml
159+
160+ - stage : MacOSTests
161+ displayName : ' MacOS'
162+ dependsOn :
163+ - Build
164+
165+ variables :
166+ PackageDownloadPath : ' $(System.DefaultWorkingDirectory)/Module'
167+ PSRepositoryName : ' FileSystem'
168+
169+ jobs :
170+ - job : MacOS
171+ displayName : ' Pester Tests'
172+
173+ pool :
174+ vmImage : macOS-latest
175+
176+ steps :
177+ - template : templates/environment-setup.yml
178+
179+ - template : ./templates/install-built-module.yml
180+ parameters :
181+ repositoryPath : ' $(PackageDownloadPath)'
182+ repositoryName : ' $(PSRepositoryName)'
183+ artifactName : ' $(NupkgArtifactName)'
184+
185+ - template : templates/test-steps.yml
186+
187+ - stage : PublishModule
188+ displayName : ' Publish Module'
189+ dependsOn :
190+ - LinuxTests
191+ - WindowsTests
192+ - MacOSTests
193+ condition : and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
194+
195+ jobs :
133196 - job : PublishToGallery
134- displayName : ' Publish PSKoans to PSGallery'
135- dependsOn : PublishFiles
136- condition : and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
197+ displayName : ' PowerShell Gallery'
137198
138199 pool :
139200 vmImage : ubuntu-latest
201+
140202 variables :
141- builtModulePath : ' $(System.DefaultWorkingDirectory)/Deploy/PSKoans'
142- galleryDeploymentPath : ' $(System.DefaultWorkingDirectory)/Deploy/PSGallery'
203+ BuiltModulePath : ' $(System.DefaultWorkingDirectory)/Deploy/PSKoans'
204+ GalleryDeploymentPath : ' $(System.DefaultWorkingDirectory)/Deploy/PSGallery'
143205
144206 steps :
145207 - template : templates/environment-setup.yml
@@ -148,43 +210,16 @@ stages:
148210 displayName : ' Download Built Module Artifact'
149211 inputs :
150212 artifact : PSKoans
151- path : $(builtModulePath )
213+ path : $(BuiltModulePath )
152214
153215 - task : PowerShell@2
154216 displayName : ' Publish Module to PSGallery'
155217
156218 inputs :
157219 targetType : ' filePath'
158- arguments : -Key $(PSApiKey) -Path '$(galleryDeploymentPath )'
220+ arguments : -Key $(PSApiKey) -Path '$(GalleryDeploymentPath )'
159221 filePath : ./Deploy/Publish.ps1
160222
161223 errorActionPreference : ' stop'
162224 failOnStderr : true
163225 pwsh : true
164-
165- - stage : CreateChangelog
166- displayName : ' Upload Changelog'
167- dependsOn : []
168- condition : startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
169-
170- jobs :
171- - job : GenerateChangelog
172- displayName : " Generate Changelog"
173- pool :
174- vmImage : ubuntu-latest
175- variables :
176- filePath : ' $(System.DefaultWorkingDirectory)/Changelog.md'
177-
178- steps :
179- - task : PowerShell@2
180- displayName : ' Create Changelog'
181- inputs :
182- targetType : ' filepath'
183- filePath : ./Build/New-Changelog.ps1
184- arguments : -Path '$(filePath)' -ApiKey $(GithubApiKey) -Verbose
185-
186- - task : PublishPipelineArtifact@1
187- displayName : ' Publish Changelog'
188- inputs :
189- path : ' $(filePath)'
190- artifact : Changelog
0 commit comments