-
Notifications
You must be signed in to change notification settings - Fork 132
335 lines (296 loc) · 11.6 KB
/
release.yaml
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
name: Release kubectl-testkube
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
id-token: write # needed for keyless signing
contents: write
env:
TESTKUBE_CHOCO_REPO: https://chocolatey.kubeshop.io/
ALPINE_IMAGE: alpine:3.18.0
jobs:
pre_build:
name: Pre-build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: "linux"
path: .builds-linux.goreleaser.yml
- name: "windows"
path: .builds-windows.goreleaser.yml
- name: "darwin"
path: .builds-darwin.goreleaser.yml
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
if: matrix.name == 'linux'
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
if: matrix.name == 'linux'
id: buildx
uses: docker/setup-buildx-action@v1
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Go Cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Login to DockerHub
if: matrix.name == 'linux'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get github sha
id: github_sha
run: echo "::set-output name=sha_short::${GITHUB_SHA::7}"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser-pro
version: latest
args: release -f ${{ matrix.path }} --skip-publish
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_ID}}"
ANALYTICS_API_KEY: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_SECRET}}"
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
ALPINE_IMAGE: ${{ env.ALPINE_IMAGE }}
DOCKER_IMAGE_TAG: ${{ steps.github_sha.outputs.sha_short }}
- name: Push Docker images
if: matrix.name == 'linux'
run: |
docker push kubeshop/testkube-cli:${{ steps.github_sha.outputs.sha_short }}-arm64v8
docker push kubeshop/testkube-cli:${{ steps.github_sha.outputs.sha_short }}-amd64
- name: Upload Artifacts
uses: actions/upload-artifact@master
with:
name: testkube_${{ matrix.name }}
path: |
${{ matrix.name }}/testkube_${{ matrix.name }}_*
retention-days: 1
release:
name: Create and upload release-artifacts
needs: pre_build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: sigstore/[email protected]
- uses: anchore/sbom-action/[email protected]
- name: Download Artifacts for Linux
uses: actions/download-artifact@master
with:
name: testkube_linux
path: linux
- name: Download Artifacts for Windows
uses: actions/download-artifact@master
with:
name: testkube_windows
path: windows
- name: Download Artifacts for Darwin
uses: actions/download-artifact@master
with:
name: testkube_darwin
path: darwin
# Added as a workaround since files lose their permissions when being moved from one stage to another in GH. A bug was reported
# and will be fixed in the next release of GoReleaser, thus we will be able to remove this code.
- name: Add executable mode
run: chmod -R +x linux/ darwin/
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Go Cache
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser-pro
version: latest
args: release -f .goreleaser.yml
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
ANALYTICS_TRACKING_ID: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_ID}}"
ANALYTICS_API_KEY: "${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_SECRET}}"
SLACK_BOT_CLIENT_ID: "${{secrets.TESTKUBE_SLACK_BOT_CLIENT_ID}}"
SLACK_BOT_CLIENT_SECRET: "${{secrets.TESTKUBE_SLACK_BOT_CLIENT_SECRET}}"
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Store Intermediate Artifacts
uses: actions/upload-artifact@master
with:
name: bin-artifacts
path: dist
retention-days: 1
# - name: Setup git email
# run: git config --global user.email "[email protected]"
# - name: Setup git name
# run: git config --global user.name "Brew Bot"
# - name: Bump formulae
# uses: mislav/bump-homebrew-formula-action@v2
# with:
# formula-name: testkube
# env:
# COMMITTER_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
build-and-publish-windows-installer:
needs: release
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Intermediate Artifacts
uses: actions/download-artifact@master
with:
name: testkube_windows
path: windows
- name: Get MSFT Cert
id: write_file
uses: timheuer/[email protected]
with:
fileName: "kubeshop_msft.p12"
fileDir: "./temp/"
encodedString: ${{ secrets.CERT_MSFT_KUBESHOP_P12_B64 }}
- name: Create and Sign MSI
run: |
Copy-Item 'windows\testkube_windows_386\kubectl-testkube.exe' '.\kubectl-testkube.exe'
Copy-Item 'build\installer\windows\testkube.wxs' '.\testkube.wxs'
Copy-Item 'build\installer\windows\tk.bat' '.\tk.bat'
Copy-Item 'build\installer\windows\testkube.bat' '.\testkube.bat'
& "$env:WIX\bin\candle.exe" *.wxs
& "$env:WIX\bin\light.exe" *.wixobj
& "C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe" sign /f "$env:P12_CERT" /p "$env:P12_PASSWORD" /d "Kubetest by Kubeshop" /tr http://timestamp.digicert.com testkube.msi
env:
P12_CERT: ${{ steps.write_file.outputs.filePath }}
P12_PASSWORD: ${{ secrets.CERT_MSFT_KUBESHOP_P12_PASSWORD }}
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
# Optionally strip `v` prefix
strip_v: true
- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Calculate Checksum
id: checksum
run: |
$installer_name = $env:MSI_NAME
$hash=Get-FileHash testkube.msi
$hash.Hash + " " + $installer_name + ".msi" >> msi_checksum.txt
echo "::set-output name=INSTALLER_NAME::${installer_name}"
#export MSI hash to environment
$hashsum = $hash.Hash
echo "::set-output name=CHECKSUM::${hashsum}"
#copy MSI to choco directory to build a nuget package
Copy-Item -Path "testkube.msi" -Destination ".\choco\tools\$env:MSI_NAME.msi"
env:
MSI_NAME: testkube_${{steps.tag.outputs.tag}}_Windows_i386
- name: Upload release binary
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: testkube.msi
asset_name: ${{steps.checksum.outputs.INSTALLER_NAME}}.msi
asset_content_type: application/octet-stream
- name: Upload Checksum
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: msi_checksum.txt
asset_name: ${{steps.checksum.outputs.INSTALLER_NAME}}_checksum.txt
asset_content_type: text/plain
- name: Update checksum in chocolateyInstall.ps1 file
working-directory: ./choco
run: |
$file_content = Get-Content .\tools\chocolateyInstall.ps1 -Raw
$update_version = $file_content -replace "(?i)(\schecksum\s*=\s*)('.*')", "`$1'${{steps.checksum.outputs.CHECKSUM}}'"
Set-Content -Path .\tools\chocolateyInstall.ps1 -Value $update_version -NoNewline
- name: Bump versions and push package to chocolatey repo
working-directory: ./choco
run: |
./update.ps1 ${{steps.tag.outputs.tag}} ${{ secrets.COMMOM_CHOCO_API_KEY }} ${{ env.TESTKUBE_CHOCO_REPO }}
build-and-publish-linux-installer:
needs: release
runs-on: ubuntu-latest
steps:
- name: Get Intermediate Artifacts
uses: actions/download-artifact@master
with:
name: bin-artifacts
path: dist
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: true
- name: Publish package
env:
USERNAME: "aptly"
PASSWORD: ${{ secrets.APTLY_PASSWORD }}
APTLY_URL: "repo.testkube.io:8080"
VERSION: ${{steps.tag.outputs.tag}}
run: |
### Upload files
curl -u ${USERNAME}:${PASSWORD} -X POST -F file=@dist/testkube_${VERSION}_linux_386.deb http://${APTLY_URL}/api/files/testkube
curl -u ${USERNAME}:${PASSWORD} -X POST -F file=@dist/testkube_${VERSION}_linux_arm64.deb http://${APTLY_URL}/api/files/testkube
curl -u ${USERNAME}:${PASSWORD} -X POST -F file=@dist/testkube_${VERSION}_linux_amd64.deb http://${APTLY_URL}/api/files/testkube
### Add file to repo
curl -u ${USERNAME}:${PASSWORD} -X POST http://${APTLY_URL}/api/repos/testkube/file/testkube?forceReplace=1
### Create snapshot
curl -u ${USERNAME}:${PASSWORD} -X POST -H 'Content-Type: application/json' --data '{"Name":"testkube-'${VERSION}'"}' http://${APTLY_URL}/api/repos/testkube/snapshots
### Publish repo
curl -u ${USERNAME}:${PASSWORD} -X PUT -H 'Content-Type: application/json' --data '{"Snapshots": [{"Component": "main", "Name": "testkube-'${VERSION}'"}]}'}], http://repo.testkube.io:8080/api/publish/:linux/linux
trigger-argocd-image-build:
needs: release
runs-on: ubuntu-latest
steps:
- name: Release tag
id: release_tag
run: |
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Set env
env:
SOURCE_TAG: ${{ steps.release_tag.outputs.SOURCE_TAG }}
run: |
echo RELEASE_TAG=${SOURCE_TAG:1} >> $GITHUB_ENV
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.CI_BOT_TOKEN }}
repository: kubeshop/testkube-argocd
event-type: trigger-argocd-image-build
client-payload: '{"release_version": "${{ env.RELEASE_TAG }}"}'