forked from flannel-io/cni-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
385 lines (338 loc) · 11.6 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
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
380
381
382
383
384
385
on:
# You must provide a tag either via the action input or the git ref (i.e push / create a tag).
# If you do not provide a tag the action will fail.
# If the tag of the release you are creating does not yet exist, you should set
# both the tag and commit action inputs. commit can point to a commit hash or a branch name (ex - main).
# workflow_dispatch:
# inputs:
# branch:
# description: 'Define branch name to run the release GH action against'
# required: true
# default: 'main'
# TODO_TEST
push:
# branches:
# - main
env:
GO_VERSION: "1.20.5"
LINUX_ARCHES: "amd64 386 arm arm64 s390x mips64le ppc64le"
REPOSITORY: flannel/flannel-cni-plugin
jobs:
setup-go:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
go: [ "1.20.5" ]
outputs:
GOPATH: ${{ steps.setup-go.outputs.GOPATH }}
GOROOT: ${{ steps.setup-go.outputs.GOROOT }}
GOCACHE: ${{ steps.setup-go.outputs.GOCACHE }}
GOMODCACHE: ${{ steps.setup-go.outputs.GOMODCACHE }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-go@v3
id: setup-go
with:
go-version: ${{ matrix.go }}
- name: go mod vendor and tidy
run: make vendor
- uses: actions/cache@v3
id: cache-go
with:
path: |
{{ outputs.GOPATH }}
{{ outputs.GOMODCACHE }}
{{ outputs.GOCACHE }}
{{ outputs.GOROOT }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
build:
needs: setup-go
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [ "1.20.5" ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-go@v3
id: setup-go
if: steps.cache-go.outputs.cache-hit != 'true'
with:
go-version: ${{ matrix.go }}
- name: go mod vendor and tidy
if: steps.cache-go.outputs.cache-hit != 'true'
run: make vendor
- name: build all binaries for release
if: steps.cache-binaries.outputs.cache-hit != 'true'
run: make build_all
# - uses: dominikh/[email protected]
# with:
# version: "2021.1.2"
# install-go: false
# cache-key: ${{ matrix.go }}
- name: Cache build binaries
id: cache-binaries
uses: actions/cache@v3
env:
cache-name: binaries
with:
path: dist
key: ${{ runner.os }}-binaries-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-binaries-${{ env.cache-name }}
${{ runner.os }}-binaries-
${{ runner.os }}-
test:
needs: [setup-go, build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [ "1.20.5" ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-go@v3
if: steps.cache-go.outputs.cache-hit != 'true'
id: setup-go
with:
go-version: ${{ matrix.go }}
- name: run tests
run: make test_linux
- name: run go vet
run: go vet
package:
needs: [setup-go, build, test]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
go: [ "1.20.5" ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/setup-go@v3
id: setup-go
if: steps.cache-go.outputs.cache-hit != 'true'
with:
go-version: ${{ matrix.go }}
- name: create packages for release
if: success()
run: make release
- name: Cache build tarfiles
id: cache-tarfiles
uses: actions/cache@v3
env:
cache-name: tarfiles
with:
path: release
key: ${{ runner.os }}-tarfiles-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-tarfiles-${{ env.cache-name }}
${{ runner.os }}-tarfiles-
${{ runner.os }}-
- uses: actions/upload-artifact@v3
id: upload-tarfiles
with:
name: flannel-cni-plugin-tarfiles
path: release/
- uses: actions/upload-artifact@v3
id: upload-binaries
with:
name: flannel-cni-plugin-binaries
path: dist/
release:
needs: [setup-go, build, test, package]
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
with:
name: flannel-cni-plugin-tarfiles
path: ~/release/
- uses: actions/download-artifact@v3
id: download-binaries
with:
name: flannel-cni-plugin-binaries
path: ~/release/
- uses: ncipollo/release-action@v1
id: release-artifacts
if: success()
with:
artifacts: "~/release/*"
# prerelease: true
generateReleaseNotes: true
allowUpdates: true
commit: ${{ github.sha }}
tag: ${{ github.ref_name }}
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
# bodyFile: "body.md"
# token: ${{ secrets.GITHUB_TOKEN }}
build-and-push-images:
needs: [setup-go, build, test, package, release]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: true
matrix:
go: [ "1.20.5" ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
if: success()
- uses: actions/setup-go@v3
id: setup-go
with:
go-version: ${{ matrix.go }}
- name: go mod vendor
run: go mod vendor
- name: build linux
run: make build_all_linux_for_images
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REPOSITORY }}
flavor: latest=false
tags: |
type=ref,event=tag
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image for amd64
if: github.repository_owner == 'flannel-io' && success()
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.amd64
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
# - name: Build and push Docker image for arm
# if: github.repository_owner == 'flannel-io'
# uses: docker/build-push-action@v4
# with:
# context: .
# file: Dockerfile.arm
# push: true
# tags: ${{ steps.meta.outputs.tags }}-arm
# - name: Build and push Docker image for arm64
# if: github.repository_owner == 'flannel-io'
# uses: docker/build-push-action@v4
# with:
# context: .
# file: Dockerfile.arm64
# push: true
# tags: ${{ steps.meta.outputs.tags }}-arm64
# - name: Build and push Docker image for s390x
# if: github.repository_owner == 'flannel-io'
# uses: docker/build-push-action@v4
# with:
# context: .
# file: Dockerfile.s390x
# push: true
# tags: ${{ steps.meta.outputs.tags }}-s390x
# - name: Build and push Docker image for ppc64le
# if: github.repository_owner == 'flannel-io'
# uses: docker/build-push-action@v4
# with:
# context: .
# file: Dockerfile.ppc64le
# push: true
# tags: ${{ steps.meta.outputs.tags }}-ppc64le
# - name: Build and push Docker image for mips64le
# if: github.repository_owner == 'flannel-io'
# uses: docker/build-push-action@v4
# with:
# context: .
# file: Dockerfile.mips64le
# push: true
# tags: ${{ steps.meta.outputs.tags }}-mips64le
# build-and-push-multi-arch-image:
# needs: [setup-go, build, test, package, release, build-and-push-images]
# runs-on: ubuntu-latest
# strategy:
# fail-fast: true
# matrix:
# go: [ "1.20.5" ]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# if: success()
# - uses: actions/setup-go@v3
# id: setup-go
# with:
# go-version: ${{ matrix.go }}
# - name: go mod vendor
# run: go mod vendor
# - name: build linux
# if: success()
# run: make build_all_linux_for_images
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Docker meta
# id: meta
# uses: docker/metadata-action@v4
# with:
# images: ${{ env.REPOSITORY }}
# flavor: latest=false
# tags: |
# type=ref,event=tag
# - name: Log in to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Create manifest for multi-arch image
# if: github.repository_owner == 'flannel-io' && success() && ${{ steps.meta.outputs.tags }}
# run: |
# # get artifacts from previous steps and integrate into one multi-arch manifest
# docker pull ${{ steps.meta.outputs.tags }}-amd64
# docker pull ${{ steps.meta.outputs.tags }}-arm64
# docker pull ${{ steps.meta.outputs.tags }}-arm
# docker pull ${{ steps.meta.outputs.tags }}-mips64le
# docker pull ${{ steps.meta.outputs.tags }}-ppc64le
# docker pull ${{ steps.meta.outputs.tags }}-s390x
# docker manifest create ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-amd64 ${{ steps.meta.outputs.tags }}-arm64 ${{ steps.meta.outputs.tags }}-arm ${{ steps.meta.outputs.tags }}-mips64le ${{ steps.meta.outputs.tags }}-ppc64le ${{ steps.meta.outputs.tags }}-s390x
# docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-amd64 --arch amd64
# docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-arm64 --arch arm64
# docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-arm --arch arm
# docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-mips64le --arch mips64le
# docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-ppc64le --arch ppc64le
# docker manifest annotate ${{ steps.meta.outputs.tags }} ${{ steps.meta.outputs.tags }}-s390x --arch s390x
# docker manifest push ${{ steps.meta.outputs.tags }}
# docker pull ${{ steps.meta.outputs.tags }}
# docker tag ${{ steps.meta.outputs.tags }} ${{ env.REPOSITORY }}:latest
# # TODO_TEST
# # docker push ${{ env.REPOSITORY }}:latest