-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
209 lines (197 loc) · 7.71 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
trigger:
- master
stages:
- stage: Build
jobs:
- job: Build
pool:
vmImage: 'macOS-10.14'
steps:
- checkout: self
clean: true
- script: brew install gitversion
displayName: Install Gitversion
- pwsh: |
$version = gitversion | ConvertFrom-Json | ForEach-Object MajorMinorPatch
Write-Host "##vso[build.updatebuildnumber]$version"
displayName: Set Build Number
- pwsh: |
$rawManifest = Get-Content -Path "PwshSparkPost.psd1" -raw
$updatedManifest = $rawManifest -replace "ModuleVersion\s*=\s*['`"][0-9.]+['`"]", "ModuleVersion = '$(Build.BuildNumber)'"
$updatedManifest | Out-File -Path "PwshSparkPost.psd1" -NoNewline
displayName: Update Module Manifest Version Number
- task: CopyFiles@2
inputs:
contents: |
**/*
!**/.*/**/*
!**/.*
!azure-pipelines.yml
!gitversion.yml
targetFolder: $(Build.ArtifactStagingDirectory)/PwshSparkPost
- publish: '$(Build.ArtifactStagingDirectory)/PwshSparkPost'
artifact: 'files'
displayName: 'Publish Artifact files'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.ArtifactStagingDirectory)/PwshSparkPost
archiveFile: '$(Build.ArtifactStagingDirectory)/PwshSparkPost_$(Build.BuildNumber).zip'
displayName: 'Archive zip'
- publish: '$(Build.ArtifactStagingDirectory)/PwshSparkPost_$(Build.BuildNumber).zip'
artifact: 'zip'
displayName: 'Publish Artifact zip'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.ArtifactStagingDirectory)/PwshSparkPost
archiveType: tar
archiveFile: '$(Build.ArtifactStagingDirectory)/PwshSparkPost_$(Build.BuildNumber).tar.gz'
displayName: 'Archive tar'
- publish: '$(Build.ArtifactStagingDirectory)/PwshSparkPost_$(Build.BuildNumber).tar.gz'
artifact: 'tar'
displayName: 'Publish Artifact tar'
- stage: Test
jobs:
- job: Mac_10_14
pool:
vmImage: 'macOS-10.14'
steps:
- checkout: none
- download: current
artifact: files
- pwsh: $PSVersionTable | Out-String
displayName: PSVersionTable
- pwsh: |
Save-Module -Name PSScriptAnalyzer -Path '.' -Repository PSGallery -Confirm:$false
Import-Module -Name './PSScriptAnalyzer/'
Get-ChildItem -Path '$(Pipeline.Workspace)' -Directory | Invoke-ScriptAnalyzer -EnableExit | Format-Table -AutoSize
displayName: Script Analyzer
- pwsh: |
Save-Module -Name Pester -Path '.' -Repository PSGallery -Confirm:$false
Import-Module -Name './Pester/'
Set-Location -Path '$(Pipeline.Workspace)'
Invoke-Pester -EnableExit -OutputFile "$(System.DefaultWorkingDirectory)/Test-Pester-Mac.xml" -OutputFormat NUnitXML
displayName: Pester
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'Test-Pester-Mac.xml'
searchFolder: $(System.DefaultWorkingDirectory)
mergeTestResults: true
buildPlatform: Mac 10.14
- job: Ubuntu_18_04
pool:
vmImage: 'ubuntu-18.04'
steps:
- checkout: none
- download: current
artifact: files
- pwsh: $PSVersionTable | Out-String
displayName: PSVersionTable
- pwsh: |
Save-Module -Name PSScriptAnalyzer -Path '.' -Repository PSGallery -Confirm:$false
Import-Module -Name './PSScriptAnalyzer/'
Get-ChildItem -Path '$(Pipeline.Workspace)' -Directory | Invoke-ScriptAnalyzer -EnableExit | Format-Table -AutoSize
displayName: Script Analyzer
- pwsh: |
Save-Module -Name Pester -Path '.' -Repository PSGallery -Confirm:$false
Import-Module -Name './Pester/'
Set-Location -Path '$(Pipeline.Workspace)'
Invoke-Pester -EnableExit -OutputFile "$(System.DefaultWorkingDirectory)/Test-Pester-Ubuntu.xml" -OutputFormat NUnitXML
displayName: Pester
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'Test-Pester-Ubuntu.xml'
searchFolder: $(System.DefaultWorkingDirectory)
mergeTestResults: true
buildPlatform: Ubuntu 18.04
- job: Windows_2019_Pwsh
pool:
vmImage: 'windows-2019'
steps:
- checkout: none
- download: current
artifact: files
- pwsh: $PSVersionTable | Out-String
displayName: PSVersionTable
- pwsh: |
Save-Module -Name PSScriptAnalyzer -Path '.' -Repository PSGallery -Confirm:$false
Import-Module -Name './PSScriptAnalyzer/'
Get-ChildItem -Path '$(Pipeline.Workspace)' -Directory | Invoke-ScriptAnalyzer -EnableExit | Format-Table -AutoSize
displayName: Script Analyzer
- pwsh: |
Save-Module -Name Pester -Path '.' -Repository PSGallery -Confirm:$false
Import-Module -Name './Pester/'
Set-Location -Path '$(Pipeline.Workspace)'
Invoke-Pester -EnableExit -OutputFile "$(System.DefaultWorkingDirectory)/Test-Pester-Win2019.xml" -OutputFormat NUnitXML
displayName: Pester
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'Test-Pester-Win2019.xml'
searchFolder: $(System.DefaultWorkingDirectory)
mergeTestResults: true
buildPlatform: Windows Server 2019
- job: Windows_2016_Powershell
pool:
vmImage: 'vs2017-win2016'
steps:
- checkout: none
- download: current
artifact: files
- powershell: $PSVersionTable | Out-String
displayName: PSVersionTable
- powershell: |
Save-Module -Name PSScriptAnalyzer -Path '.' -Repository PSGallery -Confirm:$false
Resolve-Path -Path './PSScriptAnalyzer/*/PSScriptAnalyzer.psd1' | Import-Module
Get-ChildItem -Path '$(Pipeline.Workspace)' -Directory | Invoke-ScriptAnalyzer -EnableExit | Format-Table -AutoSize
displayName: Script Analyzer
- powershell: |
Save-Module -Name Pester -Path '.' -Repository PSGallery -Confirm:$false
Resolve-Path -Path './Pester/*/Pester.psd1' | Import-Module
Set-Location -Path '$(Pipeline.Workspace)'
Invoke-Pester -EnableExit -OutputFile "$(System.DefaultWorkingDirectory)/Test-Pester-Win2016.xml" -OutputFormat NUnitXML
displayName: Pester
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'Test-Pester-Win2016.xml'
searchFolder: $(System.DefaultWorkingDirectory)
mergeTestResults: true
buildPlatform: Windows Server 2016
- stage: Deploy
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
jobs:
- job: Commit_Updated_Manifest
pool:
vmImage: 'macOS-10.14'
steps:
- checkout: self
clean: true
persistCredentials: true
- download: current
artifact: files
- pwsh: |
Move-Item -Path '$(Pipeline.Workspace)/files/PwshSparkPost.psd1' -Destination 'PwshSparkPost.psd1' -Confirm:$false -Force
git add PwshSparkPost.psd1
git -c "user.name=$(Build.RequestedFor)" -c "user.email=$(Build.RequestedForEmail)" commit -m "Updated module version: $(Build.BuildNumber) [skip ci]"
git push origin HEAD:master
workingDirectory: '$(Build.SourcesDirectory)'
- job: Github_Release
dependsOn: Commit_Updated_Manifest
steps:
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
target: master
gitHubConnection: RobFaie
repositoryName: Readify/PwshSparkPost
tagSource: manual
tag: $(Build.BuildNumber)
assets: |
$(Pipeline.Workspace)/zip/*.zip
$(Pipeline.Workspace)/tar/*.tar