Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 182fc6d

Browse files
committed
ci: Fix release workflow env vars
1 parent 41b58cd commit 182fc6d

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

.github/workflows/release.yaml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,20 @@ permissions:
3939
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
4040
id-token: write
4141

42-
env:
43-
CODER_RELEASE: ${{ !github.event.inputs.snapshot }}
44-
4542
concurrency: ${{ github.workflow }}-${{ github.ref }}
4643

44+
env:
45+
# Use string semantics for negating the boolean, otherwise it will always
46+
# be false. See https://github.com/actions/runner/issues/1483.
47+
# Note that any time we need to do expressions, more than outputting the
48+
# actual boolean value, it's safest to use `contains` because it casts the
49+
# input to string, meaning we get the same behavior for true and 'true'.
50+
# Boolean behavior differs between workflow_dispatch and workflow_call.
51+
CODER_RELEASE: ${{ contains(github.event.inputs.snapshot, 'false') }}
52+
CODER_RELEASE_INCREMENT: ${{ github.event.inputs.increment }}
53+
CODER_RELEASE_DRAFT: ${{ github.event.inputs.draft }}
54+
CODER_DRY_RUN: ${{ contains(github.event.inputs.dry_run, 'true') || contains(github.event.inputs.snapshot, 'true') }}
55+
4756
jobs:
4857
release:
4958
name: Create and publish
@@ -87,7 +96,7 @@ jobs:
8796
fi
8897
8998
version_args=()
90-
if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
99+
if [[ $CODER_DRY_RUN == *t* ]]; then
91100
# Allow dry-run of branches to pass.
92101
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
93102
version_args+=(--dry-run)
@@ -104,7 +113,7 @@ jobs:
104113
./scripts/release/tag_version.sh \
105114
"${version_args[@]}" \
106115
--ref "$ref" \
107-
--${{ github.event.inputs.increment }}
116+
--"$CODER_RELEASE_INCREMENT"
108117
)"
109118
110119
# Generate notes.
@@ -232,10 +241,10 @@ jobs:
232241
set -euo pipefail
233242
234243
publish_args=()
235-
if [[ "${{ github.event.inputs.draft }}" == *t* ]]; then
244+
if [[ $CODER_RELEASE_DRAFT == *t* ]]; then
236245
publish_args+=(--draft)
237246
fi
238-
if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
247+
if [[ $CODER_DRY_RUN == *t* ]]; then
239248
publish_args+=(--dry-run)
240249
fi
241250
declare -p publish_args
@@ -263,7 +272,8 @@ jobs:
263272
uses: "google-github-actions/setup-gcloud@v1"
264273

265274
- name: Publish Helm Chart
266-
if: ${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot }}
275+
# Do not publish helm charts for either dry run or snapshots.
276+
if: ${{ contains(github.event.inputs.dry_run, 'false') && contains(github.event.inputs.snapshot, 'false') }}
267277
run: |
268278
set -euo pipefail
269279
version="$(./scripts/version.sh)"
@@ -275,7 +285,7 @@ jobs:
275285
gsutil -h "Cache-Control:no-cache,max-age=0" cp build/helm/index.yaml gs://helm.coder.com/v2
276286
277287
- name: Upload artifacts to actions (if dry-run or snapshot)
278-
if: ${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}
288+
if: ${{ contains(github.event.inputs.dry_run, 'true') || contains(github.event.inputs.snapshot, 'true') }}
279289
uses: actions/upload-artifact@v2
280290
with:
281291
name: release-artifacts

scripts/release.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,11 @@ else
167167
fi
168168

169169
log
170-
gh workflow run release.yaml \
170+
# Use maybedryrun to echo the command.
171+
maybedryrun 0 gh workflow run release.yaml \
171172
--ref "$branch" \
172173
-F increment="$increment" \
174+
-F snapshot=false \
173175
"${args[@]}"
174176
log
175177

0 commit comments

Comments
 (0)