-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (120 loc) · 4.19 KB
/
ci.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
name: CI
on:
push:
release:
types: published
jobs:
build:
runs-on: ubuntu-latest
#runs-on: ubuntu-16.04
steps:
- name: checkout
uses: actions/checkout@v1
- name: pester tests
uses: zyborg/[email protected]
with:
include_paths: ./tests/GitHubActions_tests.ps1
exclude_tags: SkipCI
report_name: action_base_tests
report_title: Action Base Tests
gist_name: pwsh-github-action-base_tests.md
github_token: ${{ secrets.GITHUB_TOKEN }}
gist_token: ${{ secrets.GIST_TOKEN }}
gist_badge_label: Tests %ExecutedAt%
# - name: pester tests manually
# shell: pwsh
# run: |
# $neededModules = @(
# 'Pester'
# 'GitHubActions'
# )
# $neededModules | % {
# if (-not (Get-Module -ListAvailable $_)) {
# Install-Module $_ -Force
# }
# }
# ./tests/GitHubActions_tests.ps1
# - name: bundle distributable components
# shell: pwsh
# run: |
# Compress-Archive -DestinationPath ./dist.zip -Path @(
# 'js', 'lib'
# 'SAMPLE-*', 'LICENSE', 'README.md'
# )
- name: assemble distributable components
shell: pwsh
run: |
mkdir ./dist
Copy-Item ./_init ./dist/ -Recurse
Copy-Item ./SAMPLE-* ./dist/
Copy-Item ./LICENSE ./dist/
Copy-Item ./README.md ./dist/
- name: upload distributable artifact
#if: startsWith(github.ref, 'refs/tags/v=')
if: github.event_name == 'release'
uses: actions/upload-artifact@v1
with:
name: dist
path: ./dist
## For testing out tests on Windows
build-on-win:
runs-on: windows-latest
continue-on-error: true
steps:
- name: checkout
uses: actions/checkout@v1
- name: pester tests
uses: zyborg/[email protected]
with:
include_paths: ./tests/GitHubActions_tests.ps1
exclude_tags: SkipCI
report_name: action_base_tests-on-win
report_title: Action Base Tests (On Windows)
github_token: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
steps:
- name: download distributable artifact
uses: actions/download-artifact@v1
with:
name: dist
- name: bundle distributable components
shell: pwsh
run: |
cd dist
Compress-Archive -DestinationPath ../pwsh-github-action-base-dist.zip -Path ./*
- name: attach asset to release
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$tagName = $env:GITHUB_REF -replace 'refs/tags/',''
$githubHeaders = @{ Authorization = "token $($env:GITHUB_TOKEN)" }
$githubRepo = $env:GITHUB_REPOSITORY
$listRelsUrl = "https://api.github.com/repos/$($githubRepo)/releases"
$listRelsResp = Invoke-WebRequest -Headers $githubHeaders $listRelsUrl
$listRels = $listRelsResp.Content | ConvertFrom-Json
if (-not ($listRels.Count)) {
throw "list releases response did not resolve to any releases"
}
else {
Write-Output "Found [$($listRels.Count)] release(s)."
}
$thisRel = $listRels | Where-Object { $_.tag_name -eq $tagName }
if (-not $thisRel) {
throw "could not find release for tag [$tagName]"
}
else {
Write-Output "Found release [$($thisRel.tag_name)][$($thisRel.url)]"
}
$uploadUrl = $thisRel.upload_url.Replace(
'{?name,label}','?name=pwsh-github-action-base-dist.zip')
$uploadHeaders = @{
"Authorization" = "token $($env:GITHUB_TOKEN)"
"Content-Type" = "application/zip"
}
Write-Output "Adding asset to [$uploadUrl]"
$uploadResp = Invoke-WebRequest -Headers $uploadHeaders $uploadUrl `
-InFile pwsh-github-action-base-dist.zip