forked from linkerd/linkerd2
-
Notifications
You must be signed in to change notification settings - Fork 0
351 lines (340 loc) · 13 KB
/
release.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
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
name: Release
on:
push:
tags:
- "*"
permissions:
contents: read
env:
GH_ANNOTATION: true
DOCKER_REGISTRY: ghcr.io/linkerd
jobs:
docker_build:
runs-on: ubuntu-20.04
strategy:
matrix:
component: [proxy, controller, metrics-api, web, cni-plugin, debug, cli-bin, grafana, jaeger-webhook, tap]
name: Docker build (${{ matrix.component }})
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- uses: ./.github/actions/docker-build
with:
docker-registry: ${{ env.DOCKER_REGISTRY }}
docker-target: multi-arch
docker-push: 1
docker-ghcr-username: ${{ secrets.DOCKER_GHCR_USERNAME }}
docker-ghcr-pat: ${{ secrets.DOCKER_GHCR_PAT }}
component: ${{ matrix.component }}
- name: Create artifact with CLI
# windows_static_cli_tests below needs this because it can't create linux containers
# inside windows
if: matrix.component == 'cli-bin'
env:
ARCHIVES: /home/runner/archives
DOCKER_TARGET: windows
run: |
bin/docker-pull-binaries $TAG
mkdir -p $ARCHIVES
cp -r $PWD/target/release/linkerd2-cli-$TAG-windows.exe $ARCHIVES/linkerd-windows.exe
# `with.path` values do not support environment variables yet, so an
# absolute path is used here.
# https://github.com/actions/upload-artifact/issues/8
- name: Upload artifact
if: matrix.component == 'cli-bin'
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
with:
name: image-archives
path: /home/runner/archives
policy_controller_build:
runs-on: ubuntu-20.04
timeout-minutes: 30
strategy:
matrix:
arch: [amd64, arm64, arm]
name: Policy controller build (${{ matrix.arch }})
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- run: |
. bin/_tag.sh
echo "TAG=$(CI_FORCE_CLEAN=1 bin/root-tag)" >> $GITHUB_ENV
echo "DOCKER_BUILDKIT_CACHE=${{ runner.temp }}/.buildx-cache" >> $GITHUB_ENV
- name: Cache docker layers
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
with:
path: ${{ env.DOCKER_BUILDKIT_CACHE }}
key: policy-controller-${{ matrix.arch }}-${{ env.TAG }}
restore-keys: policy-controller-
- name: Build ${{ matrix.arch }}
run: |
echo "${{ secrets.DOCKER_GHCR_PAT }}" | docker login ghcr.io -u "${{ secrets.DOCKER_GHCR_USERNAME }}" --password-stdin
docker buildx build --push . \
-f ./policy-controller/${{ matrix.arch }}.dockerfile \
-t $DOCKER_REGISTRY/policy-controller:$TAG-${{ matrix.arch }} \
--cache-from type=local,src=${DOCKER_BUILDKIT_CACHE} \
--cache-to type=local,dest=${DOCKER_BUILDKIT_CACHE},mode=max
- name: Prune docker layers cache
# changes generate new images while the existing ones don't get removed
# so we manually do that to avoid bloating the cache
shell: bash
run: bin/docker-cache-prune
policy_controller_manifest:
runs-on: ubuntu-20.04
timeout-minutes: 30
needs: [policy_controller_build]
name: Policy controller manifest
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- run: |
. bin/_tag.sh
echo "TAG=$(CI_FORCE_CLEAN=1 bin/root-tag)" >> $GITHUB_ENV
- name: Create multiarch manifest
run: |
docker manifest create $DOCKER_REGISTRY/policy-controller:$TAG \
$DOCKER_REGISTRY/policy-controller:$TAG-amd64 \
$DOCKER_REGISTRY/policy-controller:$TAG-arm64 \
$DOCKER_REGISTRY/policy-controller:$TAG-arm
- name: Annotate multiarch manifest
run: |
docker manifest annotate $DOCKER_REGISTRY/policy-controller:$TAG \
$DOCKER_REGISTRY/policy-controller:${TAG}-amd64 --os=linux --arch=amd64
docker manifest annotate $DOCKER_REGISTRY/policy-controller:$TAG \
$DOCKER_REGISTRY/policy-controller:${TAG}-arm64 --os=linux --arch=arm64
docker manifest annotate $DOCKER_REGISTRY/policy-controller:$TAG \
$DOCKER_REGISTRY/policy-controller:${TAG}-arm --os=linux --arch=arm
- name: Push multiarch manifest
run: |
echo "${{ secrets.DOCKER_GHCR_PAT }}" | docker login ghcr.io -u "${{ secrets.DOCKER_GHCR_USERNAME }}" --password-stdin
docker manifest push $DOCKER_REGISTRY/policy-controller:$TAG
windows_static_cli_tests:
name: Static CLI tests (windows)
timeout-minutes: 30
runs-on: windows-latest
needs: [docker_build]
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Download image archives
uses: actions/download-artifact@3be87be14a055c47b01d3bd88f8fe02320a9bb60
with:
name: image-archives
path: image-archives
- name: Run CLI Integration tests
run: go test --failfast --mod=readonly ".\test\cli" --linkerd=$PWD\image-archives\linkerd-windows.exe --cli-tests -v
integration_tests:
strategy:
matrix:
integration_test:
- cluster-domain
- deep
- external-issuer
- external-prometheus-deep
- external-resources
- helm-deep
- helm-upgrade
- uninstall
- upgrade-edge
- upgrade-stable
- cni-calico-deep
- default-policy-deny
needs: [docker_build, policy_controller_manifest]
name: Integration tests (${{ matrix.integration_test }})
timeout-minutes: 60
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Set environment variables from scripts
run: |
TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)"
CMD="$PWD/target/release/linkerd2-cli-$TAG-linux-amd64"
echo "CMD=$CMD" >> $GITHUB_ENV
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Run integration tests
env:
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
run: |
bin/docker-pull-binaries $TAG
# Validate the CLI version matches the current build tag.
[[ "$TAG" == "$($CMD version --short --client)" ]]
bin/tests --images preload --name ${{ matrix.integration_test }} "$CMD"
arm64_integration_tests:
name: ARM64 integration tests
timeout-minutes: 60
runs-on: ubuntu-20.04
needs: [docker_build, policy_controller_manifest]
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Install linkerd CLI
run: |
TAG="$(CI_FORCE_CLEAN=1 bin/root-tag)"
CMD="$PWD/target/release/linkerd2-cli-$TAG-linux-amd64"
bin/docker-pull-binaries $TAG
$CMD version --client
# validate CLI version matches the repo
[[ "$TAG" == "$($CMD version --short --client)" ]]
echo "Installed Linkerd CLI version: $TAG"
echo "CMD=$CMD" >> $GITHUB_ENV
- name: Set KUBECONFIG environment variables
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.ARM64_KUBECONFIG }}" > $HOME/.kube/config
echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
kubectl cluster-info
- name: Run integration tests
env:
RUN_ARM_TEST: 1
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
run: bin/tests --name deep --images preload --skip-cluster-create "$CMD"
- name: CNI tests
run: |
export TAG="$($CMD version --client --short)"
go test -cover -race -v -mod=readonly ./cni-plugin/test -integration-tests
- name: Test cleanup
if: ${{ always() }}
# will fail if other steps didn't run, so ignore error
run: bin/test-cleanup "$CMD" || true
choco_pack:
# only runs for stable tags. The conditionals are at each step level instead of the job level
# otherwise the jobs below that depend on this one won't run
name: Pack Chocolatey release
timeout-minutes: 30
needs: [integration_tests]
runs-on: windows-2019
steps:
- name: Checkout code
if: startsWith(github.ref, 'refs/tags/stable')
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Chocolatey - update nuspec
if: startsWith(github.ref, 'refs/tags/stable')
run: |
$LINKERD_VERSION=$env:GITHUB_REF.Substring(17)
(Get-Content bin\win\linkerd.nuspec).replace('LINKERD_VERSION', $LINKERD_VERSION) | Set-Content bin\win\linkerd.nuspec
- name: Chocolatey - pack
if: startsWith(github.ref, 'refs/tags/stable')
uses: crazy-max/ghaction-chocolatey@87d06bbbd2cfb1835f1820042d356aef4875fb5f
with:
args: pack bin/win/linkerd.nuspec
- name: Chocolatey - upload package
if: startsWith(github.ref, 'refs/tags/stable')
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
with:
name: choco
path: ./linkerd.*.nupkg
gh_release:
name: Create GH release
timeout-minutes: 30
if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge')
runs-on: ubuntu-20.04
needs: [choco_pack]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Set environment variables from scripts
run: |
. bin/_tag.sh
. bin/_release.sh
echo "TAG=$(CI_FORCE_CLEAN=1 bin/root-tag)" >> $GITHUB_ENV
extract_release_notes NOTES.md
- name: Download choco package
if: startsWith(github.ref, 'refs/tags/stable')
uses: actions/download-artifact@3be87be14a055c47b01d3bd88f8fe02320a9bb60
with:
name: choco
path: choco
- name: Pull CLI binaries
env:
DOCKER_TARGET: multi-arch
run : |
bin/docker-pull-binaries $TAG
VERSION=${TAG#"stable-"}
mv choco/linkerd.*.nupkg target/release/linkerd2-cli-stable-$VERSION.nupkg || true
- name: Create release
id: create_release
uses: softprops/action-gh-release@fb0163a75bee697a9cfec2c931801de7c7f10042
with:
draft: false
prerelease: false
body_path: NOTES.md
files: |
./target/release/linkerd2-cli-*-darwin*
./target/release/linkerd2-cli-*-linux-*
./target/release/linkerd2-cli-*-windows.*
./target/release/linkerd2-cli-*.nupkg
website_publish:
name: Linkerd website publish
timeout-minutes: 30
if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge')
runs-on: ubuntu-20.04
needs: [gh_release]
permissions:
contents: write
steps:
- name: Create linkerd/website repository dispatch event
uses: peter-evans/repository-dispatch@ce5485de42c9b2622d2ed064be479e8ed65e76f4
with:
token: ${{ secrets.RELEASE_TOKEN }}
repository: linkerd/website
event-type: release
website_publish_check:
name: Linkerd website publish check
timeout-minutes: 30
if: startsWith(github.ref, 'refs/tags/stable') || startsWith(github.ref, 'refs/tags/edge')
runs-on: ubuntu-20.04
needs: [website_publish]
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Set environment variables from scripts
run: |
. bin/_tag.sh
echo "TAG=$(CI_FORCE_CLEAN=1 bin/root-tag)" >> $GITHUB_ENV
- name: Set install target for stable
if: startsWith(github.ref, 'refs/tags/stable')
run: echo "INSTALL=install" >> $GITHUB_ENV
- name: Set install target for edge
if: startsWith(github.ref, 'refs/tags/edge')
run: echo "INSTALL=install-edge" >> $GITHUB_ENV
- name: Check published version
run: |
until RES=$(curl -sL https://run.linkerd.io/$INSTALL | grep "LINKERD2_VERSION=\${LINKERD2_VERSION:-$TAG}") \
|| (( count++ >= 10 ))
do
sleep 30
done
if [[ -z $RES ]]; then
echo "::error::The version '$TAG' was NOT found published in the website"
exit 1
fi
chart_deploy:
name: Helm chart deploy
timeout-minutes: 30
runs-on: ubuntu-20.04
needs: [gh_release]
steps:
- name: Checkout code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Configure gsutils
uses: linkerd/linkerd2-action-gcloud@f01c9de238d33e87029fddb7f2f9a1fb93903b8f
with:
cloud_sdk_service_account_key: ${{ secrets.LINKERD_SITE_TOKEN }}
gcp_project: ${{ secrets.LINKERD_SITE_PROJECT }}
gcp_zone: ${{ secrets.LINKERD_SITE_ZONE }}
- name: Edge Helm chart creation and upload
if: startsWith(github.ref, 'refs/tags/edge')
uses: ./.github/actions/helm-publish
with:
branch: edge
- name: Stable Helm chart creation and upload
if: startsWith(github.ref, 'refs/tags/stable')
uses: ./.github/actions/helm-publish
with:
branch: stable