-
-
Notifications
You must be signed in to change notification settings - Fork 176
277 lines (223 loc) · 8.56 KB
/
github.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# This is a basic workflow to help you get started with Actions
name: PSKoans CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
NupkgArtifactName: 'PSKoans.nupkg'
ModuleArtifactName: 'PSKoans'
PesterInfoFileName: 'PesterVersion.txt'
PesterInfoFilePath: '$GITHUB_WORKSPACE/PesterVersion.txt'
jobs:
create_changelog:
name: 'Upload Changelog'
# Don't run this step for pull requests
if: ${{ github.head_ref == '' }}
runs-on: ubuntu-latest
env:
FilePath: '$GITHUB_WORKSPACE/Changelog.md'
steps:
- uses: actions/checkout@v2
- name: Generate Changelog
shell: pwsh
run: ./Build/New-Changelog.ps1 -Path "${{ env.FilePath }}" -ApiKey "${{ secrets.GITHUB_TOKEN }}"
- name: Upload Changelog
uses: actions/[email protected]
with:
name: Changelog.md
path: $FilePath
build:
name: 'Build Module'
runs-on: ubuntu-latest
env:
FileSystemDeploymentPath: '$GITHUB_WORKSPACE/Deploy/FileSystem'
BuiltModulePath: '$GITHUB_WORKSPACE/Deploy/PSKoans'
# This needs to be set by the script which creates the nupkg
NupkgPath: ''
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
shell: pwsh
run: |
$Params = @{
Scope = 'CurrentUser'
Force = $true
}
Write-Host "Installing Modules"
$Params.Name = @( 'PSDeploy', 'BuildHelpers', 'PlatyPS' )
$Params | Out-String | Write-Host
Install-Module @Params
$Params.Name = 'Pester'
$Params.SkipPublisherCheck = $true
$Params.MinimumVersion = $Params.MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version
$Params | Out-String | Write-Host
Install-Module @Params
$Params.MinimumVersion | Set-Content -Path "${{ env.PesterInfoFilePath }}"
$Params.Remove('SkipPublisherCheck')
$Params.Remove('MinimumVersion')
$Params.Name = 'EZOut'
$Params.AllowClobber = $true
$Params | Out-String | Write-Host
Install-Module @Params
- name: Setup Environment
shell: pwsh
run: ./Build/Initialize-Environment.ps1
- name: Build Module
shell: pwsh
run: ./Build/Build-Module.ps1
- name: Upload Module Artifact
uses: actions/[email protected]
with:
name: $ModuleArtifactName
path: $BuiltModulePath
- name: Upload Pester Version Artifact
uses: actions/[email protected]
with:
name: $PesterInfoFileName
path: $PesterInfoFilePath
- name: Generate Nupkg
shell: pwsh
run: |
./Build/Register-FileSystemRepository.ps1 -Path '${{ env.FileSystemDeploymentPath }}' -Name 'FileSystem'
./Deploy/Publish.ps1 -Key 'filesystem' -Path '${{ env.FileSystemDeploymentPath }}' -OutputDirectory '${{ env.FileSystemDeploymentPath }}'
- name: Upload Nupkg Artifact
uses: actions/[email protected]
with:
name: $NupkgArtifactName
path: $NupkgPath
test:
name: "Test Module"
needs: build
strategy:
matrix:
os:
- windows-latest
- macOS-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
env:
PackageDownloadPath: '$GITHUB_WORKSPACE/Module'
PSRepositoryName: 'FileSystem'
# The following variables MUST be set in Invoke-ModuleTests.ps1
TestFile: ''
CodeCoverageFile: ''
ModuleFolders: ''
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
shell: pwsh
run: |
$Params = @{
Scope = 'CurrentUser'
Force = $true
}
Write-Host "Installing Modules"
$Params.Name = @( 'PSDeploy', 'BuildHelpers', 'PlatyPS' )
$Params | Out-String | Write-Host
Install-Module @Params
$Params.Name = 'Pester'
$Params.SkipPublisherCheck = $true
$Params.MinimumVersion = $Params.MinimumVersion = (Get-Module -ListAvailable ./PSKoans).RequiredModules.Where{$_.Name -eq 'Pester'}.Version
$Params | Out-String | Write-Host
Install-Module @Params
$Params.Remove('SkipPublisherCheck')
$Params.Remove('MinimumVersion')
$Params.Name = 'EZOut'
$Params.AllowClobber = $true
$Params | Out-String | Write-Host
Install-Module @Params
- name: Setup Environment
shell: pwsh
run: ./Build/Initialize-Environment.ps1
- name: Register FileSystem Repository
shell: pwsh
run: ./Build/Register-FileSystemRepository.ps1 -Path '${{ env.PackageDownloadPath }}' -Name '${{ env.PSRepositoryName }}'
- name: Download Module Nupkg
uses: actions/[email protected]
with:
name: $NupkgArtifactName
path: $PackageDownloadPath
- name: Download Pester Version Information
uses: actions/[email protected]
with:
name: $PesterInfoFileName
path: $PesterInfoFilePath
- name: Install Module from Nupkg
shell: pwsh
run: |
$pesterParams = @{
Name = 'Pester'
MinimumVersion = Get-Content -Path "${{ env.PesterInfoFilePath }}"
ProviderName = 'NuGet'
Path = '${{ env.PackageDownloadPath }}'
Force = $true
Source = 'PSGallery'
}
Register-PackageSource -Name PSGallery -ProviderName NuGet -Location https://www.powershellgallery.com/api/v2 -Force
Save-Package @pesterParams | Select-Object -Property Name, Version, Status, Source
Install-Module PSKoans -Repository ${{ env.PSRepositoryName }} -Force -Scope CurrentUser
- name: Run Pester Tests
shell: pwsh
run: ./Build/Invoke-ModuleTests.ps1
- name: Publish Test Results
if: ${{ always() }}
uses: MirageNet/[email protected]
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
path: '$GITHUB_WORKSPACE\$TestResults'
- name: Generate Code Coverage
uses: danielpalme/[email protected]
with:
reports: '$GITHUB_WORKSPACE\$CodeCoverageFile'
targetdir: '$GITHUB_WORKSPACE\coveragereports'
sourcedirs: $SourceFolders
title: PSKoans Code Coverage
- name: Publish Code Coverage artifacts
uses: actions/[email protected]
with:
name: 'Code Coverage Reports'
path: '$GITHUB_WORKSPACE\coveragereports'
publish:
needs: test
if: ${{ success() && startsWith( 'refs/tags/', env.GITHUB_REF ) }}
runs-on: ubuntu-latest
env:
BuiltModulePath: '$GITHUB_WORKSPACE/Deploy/PSKoans'
GalleryDeploymentPath: '$GITHUB_WORKSPACE/Deploy/PSGallery'
# This variable must be set by the script
TagName: ''
steps:
- uses: actions/checkout@v2
- name: Download Module Artifact
uses: actions/[email protected]
with:
name: $ModuleArtifactName
path: $BuiltModulePath
- name: Deploy Module to PSGallery
shell: pwsh
run: ./Deploy/Publish.ps1 -ApiKey '${{ secrets.PSGALLERYAPIKEY }}' -Path '${{ env.GalleryDeploymentPath }}'
- name: Set Release Tag Name
shell: pwsh
run: |
$tagName = ("${{ env.GITHUB_REF }}" -replace '^refs/tags/').Trim()
"TagName=$tagname" | Add-Content -Path '${{ env.GITHUB_ENV }}'
- name: Download Artifacts
uses: actions/[email protected]
with:
path: '$GITHUB_WORKSPACE/artifacts'
- name: Update Release with Artifacts & Changelog
uses: Roang-zero1/[email protected]
with:
created_tag: $TagName
changelog_file: '$GITHUB_WORKSPACE/artifacts/Changelog.md'
release_title: 'PSKoans Release $TagName'