-
Notifications
You must be signed in to change notification settings - Fork 0
380 lines (311 loc) · 14.5 KB
/
release-build.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
# See LICENSE file in this repo for license details.
name: Release Build
on:
push:
tags:
# Match any semver tag, rely on the workflow steps to apply necessary
# logic to separate "stable" release builds from "prerelease" builds.
- "v[0-9]+.[0-9]+.*"
jobs:
git_describe_semver:
name: Generate semantic release version using git-describe-semver
runs-on: ubuntu-latest
# Default: 360 minutes
timeout-minutes: 5
# https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs
outputs:
version: ${{ steps.git-describe-semver.outputs.version }}
steps:
- name: Print Docker version
run: docker --version
- name: Clone repo with full history
uses: actions/checkout@v4
with:
# Needed in order to retrieve tags for use with semver calculations
fetch-depth: 0
# Mark the current working directory as a safe directory in git to
# resolve "dubious ownership" complaints.
#
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html
# https://github.com/actions/runner-images/issues/6775
# https://github.com/actions/checkout/issues/766
- name: Mark the current working directory as a safe directory in git
# run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
run: git config --global --add safe.directory "${PWD}"
# NOTE: See build-images.yml for other potential approaches.
#
# https://github.com/choffmeister/git-describe-semver/pkgs/container/git-describe-semver
# https://github.com/choffmeister/git-describe-semver/blob/v0.3.11/action.yaml
# https://github.com/choffmeister/git-describe-semver/blob/v0.4.0/action.yaml
# https://github.com/choffmeister/git-describe-semver/issues/8
- name: Record semantic version using git-describe-semver
uses: docker://ghcr.io/choffmeister/git-describe-semver:0.3.11
id: git-describe-semver
with:
args: >-
--fallback="v0.0.0"
--drop-prefix=false
--prerelease-prefix="dev"
--prerelease-suffix=""
--prerelease-timestamped="false"
--format="version=<version>"
$GITHUB_OUTPUT
- name: Print semantic version generated by git-describe-semver
run: |
echo "${{ steps.git-describe-semver.outputs.version }}"
build_and_upload_mirror_images:
name: Build and upload mirror container images
needs: git_describe_semver
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
contents: write
discussions: write
packages: write
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
# Default: 360 minutes
timeout-minutes: 45
steps:
- name: Log tag info
run: |
echo "Ref type: ${{ github.ref_type }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Ref full: ${{ github.ref }}"
echo "Commit SHA: ${{ github.sha }}"
- name: Check out code with default settings
uses: actions/checkout@v4
# Mark the current working directory as a safe directory in git to
# resolve "dubious ownership" complaints.
#
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html
# https://github.com/actions/runner-images/issues/6775
# https://github.com/actions/checkout/issues/766
- name: Mark the current working directory as a safe directory in git
# run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
run: git config --global --add safe.directory "${PWD}"
# bsdmainutils provides "column" which is used by the Makefile
- name: Install Ubuntu packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils
- name: Build mirror images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
run: |
make build-mirror-images
- name: List generated Docker images
run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"
- name: Upload mirror images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
DH_TOKEN: ${{ secrets.DOCKERHUB }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make upload-mirror-images
build_and_upload_alpine_images:
name: Build and upload Alpine container images
needs: git_describe_semver
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
contents: write
discussions: write
packages: write
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
# Default: 360 minutes
timeout-minutes: 45
steps:
- name: Log tag info
run: |
echo "Ref type: ${{ github.ref_type }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Ref full: ${{ github.ref }}"
echo "Commit SHA: ${{ github.sha }}"
- name: Check out code with default settings
uses: actions/checkout@v4
# Mark the current working directory as a safe directory in git to
# resolve "dubious ownership" complaints.
#
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html
# https://github.com/actions/runner-images/issues/6775
# https://github.com/actions/checkout/issues/766
- name: Mark the current working directory as a safe directory in git
# run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
run: git config --global --add safe.directory "${PWD}"
# bsdmainutils provides "column" which is used by the Makefile
- name: Install Ubuntu packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils
- name: Build Alpine images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
run: |
make build-alpine-images
- name: List generated Docker images
run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"
- name: Upload alpine images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
DH_TOKEN: ${{ secrets.DOCKERHUB }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make upload-alpine-images
build_and_upload_mingw_images:
name: Build and upload mingw-w64 container images
needs: git_describe_semver
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
contents: write
discussions: write
packages: write
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
# Default: 360 minutes
timeout-minutes: 45
steps:
- name: Log tag info
run: |
echo "Ref type: ${{ github.ref_type }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Ref full: ${{ github.ref }}"
echo "Commit SHA: ${{ github.sha }}"
- name: Check out code with default settings
uses: actions/checkout@v4
# Mark the current working directory as a safe directory in git to
# resolve "dubious ownership" complaints.
#
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html
# https://github.com/actions/runner-images/issues/6775
# https://github.com/actions/checkout/issues/766
- name: Mark the current working directory as a safe directory in git
# run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
run: git config --global --add safe.directory "${PWD}"
# bsdmainutils provides "column" which is used by the Makefile
- name: Install Ubuntu packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils
- name: Build mingw-w64 images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
run: |
make build-mingw-images
- name: List generated Docker images
run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"
- name: Upload mingw images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
DH_TOKEN: ${{ secrets.DOCKERHUB }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make upload-mingw-images
build_and_upload_standard_images:
name: Build and upload standard container images
needs: git_describe_semver
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
contents: write
discussions: write
packages: write
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
# Default: 360 minutes
timeout-minutes: 45
steps:
- name: Log tag info
run: |
echo "Ref type: ${{ github.ref_type }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Ref full: ${{ github.ref }}"
echo "Commit SHA: ${{ github.sha }}"
- name: Check out code with default settings
uses: actions/checkout@v4
# Mark the current working directory as a safe directory in git to
# resolve "dubious ownership" complaints.
#
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html
# https://github.com/actions/runner-images/issues/6775
# https://github.com/actions/checkout/issues/766
- name: Mark the current working directory as a safe directory in git
# run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
run: git config --global --add safe.directory "${PWD}"
# bsdmainutils provides "column" which is used by the Makefile
- name: Install Ubuntu packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils
- name: Build standard images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
run: |
make build-standard-images
- name: List generated Docker images
run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"
- name: Upload standard images
env:
REPO_VERSION: ${{ needs.git_describe_semver.outputs.version }}
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
DH_TOKEN: ${{ secrets.DOCKERHUB }}
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
make upload-standard-images
create_release:
name: Create GitHub Release
needs:
- git_describe_semver
- build_and_upload_mirror_images
- build_and_upload_alpine_images
- build_and_upload_mingw_images
- build_and_upload_standard_images
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
contents: write
discussions: write
packages: write
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
# Default: 360 minutes
timeout-minutes: 45
steps:
- name: Log tag info
run: |
echo "Ref type: ${{ github.ref_type }}"
echo "Ref name: ${{ github.ref_name }}"
echo "Ref full: ${{ github.ref }}"
echo "Commit SHA: ${{ github.sha }}"
- name: Check out code with default settings
uses: actions/checkout@v4
# Mark the current working directory as a safe directory in git to
# resolve "dubious ownership" complaints.
#
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html
# https://github.com/actions/runner-images/issues/6775
# https://github.com/actions/checkout/issues/766
- name: Mark the current working directory as a safe directory in git
# run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
run: git config --global --add safe.directory "${PWD}"
- name: Generate pre-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc')
run: |
echo Generating pre-release
gh release create ${{ github.ref_name }} \
--verify-tag \
--prerelease \
--discussion-category 'Dev/Release Candidate' \
--generate-notes
- name: Generate stable release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/orgs/community/discussions/26712
if: ${{ !(contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc')) }}
run: |
echo Generating stable release
gh release create ${{ github.ref_name }} \
--verify-tag \
--latest \
--discussion-category 'Stable Release' \
--generate-notes