1
1
# GitHub release workflow.
2
2
name : Release
3
+ run-name : Release ${{ github.ref_name }}${{ inputs.dry_run && ' (DRYRUN)' || '' }}
3
4
on :
4
5
workflow_dispatch :
5
6
inputs :
22
23
type : boolean
23
24
required : true
24
25
default : false
25
- snapshot :
26
- description : Force a dev version to be generated, implies dry_run.
27
- type : boolean
28
- default : false
29
26
ignore_missing_commit_metadata :
30
27
description : WARNING! This option disables the requirement that all commits have a PR. Not needed for dry_run.
31
28
type : boolean
@@ -39,11 +36,17 @@ permissions:
39
36
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
40
37
id-token : write
41
38
42
- env :
43
- CODER_RELEASE : ${{ !github.event.inputs.snapshot }}
44
-
45
39
concurrency : ${{ github.workflow }}-${{ github.ref }}
46
40
41
+ env :
42
+ # Use `inputs` (vs `github.event.inputs`) to ensure that booleans are actual
43
+ # booleans, not strings.
44
+ # https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/
45
+ CODER_RELEASE : ${{ !inputs.dry_run }}
46
+ CODER_RELEASE_INCREMENT : ${{ inputs.increment }}
47
+ CODER_RELEASE_DRAFT : ${{ inputs.draft }}
48
+ CODER_DRY_RUN : ${{ inputs.dry_run }}
49
+
47
50
jobs :
48
51
release :
49
52
name : Create and publish
52
55
# Necessary for Docker manifest
53
56
DOCKER_CLI_EXPERIMENTAL : " enabled"
54
57
steps :
58
+ - name : Check release on main (or dry-run)
59
+ if : ${{ github.ref_name != 'main' && !inputs.dry_run }}
60
+ run : |
61
+ echo "Release not allowed on ${{ github.ref_name }}, use dry-run."
62
+ exit 1
63
+
55
64
- uses : actions/checkout@v3
56
65
with :
57
66
fetch-depth : 0
76
85
ref=HEAD
77
86
old_version="$(git describe --abbrev=0 "$ref^1")"
78
87
79
- if [[ "${{ github.event. inputs.ignore_missing_commit_metadata }}" == *t* ]]; then
88
+ if [[ "${{ inputs.ignore_missing_commit_metadata }}" == *t* ]]; then
80
89
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
81
90
fi
82
91
87
96
fi
88
97
89
98
version_args=()
90
- if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
99
+ if [[ $CODER_DRY_RUN == *t* ]]; then
91
100
# Allow dry-run of branches to pass.
92
101
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
93
102
version_args+=(--dry-run)
@@ -104,7 +113,7 @@ jobs:
104
113
./scripts/release/tag_version.sh \
105
114
"${version_args[@]}" \
106
115
--ref "$ref" \
107
- --${{ github.event.inputs.increment }}
116
+ --"$CODER_RELEASE_INCREMENT"
108
117
)"
109
118
110
119
# Generate notes.
@@ -232,10 +241,10 @@ jobs:
232
241
set -euo pipefail
233
242
234
243
publish_args=()
235
- if [[ "${{ github.event.inputs.draft }}" == *t* ]]; then
244
+ if [[ $CODER_RELEASE_DRAFT == *t* ]]; then
236
245
publish_args+=(--draft)
237
246
fi
238
- if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
247
+ if [[ $CODER_DRY_RUN == *t* ]]; then
239
248
publish_args+=(--dry-run)
240
249
fi
241
250
declare -p publish_args
@@ -263,7 +272,7 @@ jobs:
263
272
uses : " google-github-actions/setup-gcloud@v1"
264
273
265
274
- name : Publish Helm Chart
266
- if : ${{ !github.event. inputs.dry_run && !github.event.inputs.snapshot }}
275
+ if : ${{ !inputs.dry_run }}
267
276
run : |
268
277
set -euo pipefail
269
278
version="$(./scripts/version.sh)"
@@ -274,8 +283,8 @@ jobs:
274
283
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/coder_helm_${version}.tgz gs://helm.coder.com/v2
275
284
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/v2
276
285
277
- - name : Upload artifacts to actions (if dry-run or snapshot )
278
- if : ${{ github.event. inputs.dry_run || github.event.inputs.snapshot }}
286
+ - name : Upload artifacts to actions (if dry-run)
287
+ if : ${{ inputs.dry_run }}
279
288
uses : actions/upload-artifact@v2
280
289
with :
281
290
name : release-artifacts
0 commit comments