-
Notifications
You must be signed in to change notification settings - Fork 132
379 lines (332 loc) · 13.3 KB
/
release-dev.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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
name: Release kubectl-testkube dev
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-*"
permissions:
id-token: write # needed for keyless signing
contents: write
env:
ALPINE_IMAGE: alpine:3.20.3
BUSYBOX_IMAGE: busybox:1.36.1-musl
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@v4
with:
fetch-depth: 0
- name: Set up QEMU
if: matrix.name == 'linux'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: matrix.name == 'linux'
id: buildx
uses: docker/setup-buildx-action@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Go Cache
uses: actions/cache@v4
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@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
version: 'v2.3.2' # 2.4.4 fails with "no such file or directory"
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 }}
BUSYBOX_IMAGE: ${{ env.BUSYBOX_IMAGE }}
DOCKER_IMAGE_TAG: ${{steps.tag.outputs.tag}}
- name: Push Docker images
if: matrix.name == 'linux'
run: |
docker push kubeshop/testkube-cli:${{steps.tag.outputs.tag}}-arm64v8
docker push kubeshop/testkube-cli:${{steps.tag.outputs.tag}}-amd64
# adding the docker manifest for the latest image tag
docker manifest create kubeshop/testkube-cli:latest --amend kubeshop/testkube-cli:${{steps.tag.outputs.tag}}-amd64 --amend kubeshop/testkube-cli:${{steps.tag.outputs.tag}}-arm64v8
docker manifest push -p kubeshop/testkube-cli:latest
docker manifest create kubeshop/testkube-cli:${{steps.tag.outputs.tag}} --amend kubeshop/testkube-cli:${{steps.tag.outputs.tag}}-amd64 --amend kubeshop/testkube-cli:${{steps.tag.outputs.tag}}-arm64v8
docker manifest push -p kubeshop/testkube-cli:${{steps.tag.outputs.tag}}
- name: Push README to Dockerhub
if: matrix.name == 'linux'
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKERHUB_TOKEN }}
with:
destination_container_repo: kubeshop/testkube-cli
provider: dockerhub
short_description: "Testkube CLI Docker image"
readme_file: "./README.md"
- name: Upload Artifacts
uses: actions/upload-artifact@master
with:
name: testkube_${{ matrix.name }}
path: |
${{ matrix.name }}/testkube_${{ matrix.name }}_*
retention-days: 1
build_agent_image:
name: Build a Docker image for Testkube Agent
runs-on: ubuntu-latest
env:
TESTKUBE_CLOUD_URL: "agent.testkube.io:443"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: true
- name: Preload kind images
run: |
mkdir -p build/kind/images
docker pull --platform linux/arm64 kindest/node:v1.31.0
docker save kindest/node:v1.31.0 > build/kind/images/node.tar
docker pull --platform linux/amd64 kindest/node:v1.31.0
docker save kindest/node:v1.31.0 >> build/kind/images/node.tar
- name: Build and push
uses: docker/build-push-action@v6
with:
build-args: |
segmentio_key=${{secrets.TESTKUBE_SEGMENTIO_KEY}}
ga_id=${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_ID}}
ga_secret=${{secrets.TESTKUBE_CLI_GA_MEASUREMENT_SECRET}}
docker_image_version=${{steps.tag.outputs.tag}}
cloud_url=${{ env.TESTKUBE_CLOUD_URL }}
context: build/kind
file: build/kind/kind.Dockerfile
platforms: linux/amd64,linux/arm64/v8
provenance: mode=max
push: true
sbom: true
tags: kubeshop/testkube-agent:${{steps.tag.outputs.tag}}
release:
name: Create and upload release-artifacts
needs: pre_build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
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@v5
with:
go-version: stable
- name: Go Cache
uses: actions/cache@v4
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@v6
with:
distribution: goreleaser-pro
version: 'v2.3.2' # 2.4.4 fails with "no such file or directory"
args: release -f .goreleaser-dev.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
build-and-publish-windows-installer:
needs: release
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Intermediate Artifacts
uses: actions/download-artifact@master
with:
name: testkube_windows
path: windows
- 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
- name: Sign Artifact with CodeSignTool
uses: sslcom/esigner-codesign@develop
with:
command: sign
username: ${{ secrets.ES_USERNAME }}
password: ${{ secrets.ES_PASSWORD }}
totp_secret: ${{ secrets.ES_TOTP_SECRET }}
file_path: testkube.msi
output_path: ${GITHUB_WORKSPACE}\artifacts
malware_block: false
- 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
$installer_path = $env:MSI_PATH
$hash=Get-FileHash $installer_path
$hash.Hash + " " + $installer_name + ".msi" >> msi_checksum.txt
echo "::set-output name=INSTALLER_NAME::${installer_name}"
echo "::set-output name=INSTALLER_PATH::${installer_path}"
#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 "$installer_path" -Destination ".\choco\tools\$env:MSI_NAME.msi"
env:
MSI_NAME: testkube_${{steps.tag.outputs.tag}}_Windows_i386
MSI_PATH: D:\a\testkube\testkube\artifacts\testkube.msi
- name: Upload release binary
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ${{steps.checksum.outputs.INSTALLER_PATH}}
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
# 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 --fail-with-body -u ${USERNAME}:${PASSWORD} -X POST -F file=@dist/testkube_${VERSION}_linux_386.deb http://${APTLY_URL}/api/files/testkube
# curl --fail-with-body -u ${USERNAME}:${PASSWORD} -X POST -F file=@dist/testkube_${VERSION}_linux_arm64.deb http://${APTLY_URL}/api/files/testkube
# curl --fail-with-body -u ${USERNAME}:${PASSWORD} -X POST -F file=@dist/testkube_${VERSION}_linux_amd64.deb http://${APTLY_URL}/api/files/testkube
# ### Add file to repo
# curl --fail-with-body -u ${USERNAME}:${PASSWORD} -X POST http://${APTLY_URL}/api/repos/testkube/file/testkube?forceReplace=1
# ### Create snapshot
# curl --fail-with-body -u ${USERNAME}:${PASSWORD} -X POST -H 'Content-Type: application/json' --data '{"Name":"testkube-'${VERSION}'"}' http://${APTLY_URL}/api/repos/testkube/snapshots
# ### Publish repo
# curl --fail-with-body -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-deploy-to-dev-env:
needs: release
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.CI_BOT_TOKEN }}
repository: kubeshop/helm-charts
event-type: trigger-helm-chart-deployment-to-develop-cluster