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

Skip to content

Commit c7e1ecf

Browse files
authored
ci: Fix release workflow inputs (#5681)
1 parent 1df72ee commit c7e1ecf

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

.github/workflows/release.yaml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ on:
1616
description: Create a draft release (for manually editing release notes before publishing).
1717
type: boolean
1818
required: true
19-
snapshot:
20-
description: Force a dev version to be generated, implies dry_run.
21-
type: boolean
22-
required: true
19+
default: false
2320
dry_run:
2421
description: Perform a dry-run release.
2522
type: boolean
2623
required: true
24+
default: false
25+
snapshot:
26+
description: Force a dev version to be generated, implies dry_run.
27+
type: boolean
28+
default: false
2729
ignore_missing_commit_metadata:
2830
description: WARNING! This option disables the requirement that all commits have a PR. Not needed for dry_run.
2931
type: boolean
@@ -38,9 +40,7 @@ permissions:
3840
id-token: write
3941

4042
env:
41-
CODER_RELEASE: ${{ github.event.inputs.snapshot && 'false' || 'true' }}
42-
DRY_RUN: ${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && 'true' || 'false' }}
43-
CODER_IGNORE_MISSING_COMMIT_METADATA: ${{ github.event.inputs.ignore_missing_commit_metadata && '1' || '0' }}
43+
CODER_RELEASE: ${{ !github.event.inputs.snapshot }}
4444

4545
concurrency: ${{ github.workflow }}-${{ github.ref }}
4646

@@ -76,25 +76,33 @@ jobs:
7676
ref=HEAD
7777
old_version="$(git describe --abbrev=0 "$ref^1")"
7878
79+
if [[ "${{ github.event.inputs.ignore_missing_commit_metadata }}" == *t* ]]; then
80+
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
81+
fi
82+
7983
# Warn if CODER_IGNORE_MISSING_COMMIT_METADATA is set any other way
8084
# than via dry-run.
8185
if [[ ${CODER_IGNORE_MISSING_COMMIT_METADATA:-0} != 0 ]]; then
8286
echo "WARNING: CODER_IGNORE_MISSING_COMMIT_METADATA is enabled and we will ignore missing commit metadata." 1>&2
8387
fi
8488
85-
if [[ $DRY_RUN == true ]]; then
89+
version_args=()
90+
if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
8691
# Allow dry-run of branches to pass.
8792
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
93+
version_args+=(--dry-run)
8894
fi
8995
9096
# Cache commit metadata.
9197
. ./scripts/release/check_commit_metadata.sh "$old_version" "$ref"
9298
99+
declare -p version_args
100+
93101
# Create new release tag (note that this tag is not pushed before
94102
# release.sh is run).
95103
version="$(
96104
./scripts/release/tag_version.sh \
97-
${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \
105+
"${version_args[@]}" \
98106
--ref "$ref" \
99107
--${{ github.event.inputs.increment }}
100108
)"
@@ -222,9 +230,18 @@ jobs:
222230
- name: Publish release
223231
run: |
224232
set -euo pipefail
233+
234+
publish_args=()
235+
if [[ "${{ github.event.inputs.draft }}" == *t* ]]; then
236+
publish_args+=(--draft)
237+
fi
238+
if [[ "${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}" == *t* ]]; then
239+
publish_args+=(--dry-run)
240+
fi
241+
declare -p publish_args
242+
225243
./scripts/release/publish.sh \
226-
${{ github.event.inputs.draft && '--draft' }} \
227-
${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \
244+
"${publish_args[@]}" \
228245
--release-notes-file "$CODER_RELEASE_NOTES_FILE" \
229246
./build/*_installer.exe \
230247
./build/*.zip \
@@ -246,6 +263,7 @@ jobs:
246263
uses: "google-github-actions/setup-gcloud@v1"
247264

248265
- name: Publish Helm Chart
266+
if: ${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot }}
249267
run: |
250268
set -euo pipefail
251269
version="$(./scripts/version.sh)"

scripts/release.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ if ! [[ $create =~ ^[Yy]$ ]]; then
147147
fi
148148

149149
args=()
150+
151+
# Draft and dry-run are required args.
150152
if ((draft)); then
151153
args+=(-F draft=true)
152154
else
@@ -168,7 +170,6 @@ log
168170
gh workflow run release.yaml \
169171
--ref "$branch" \
170172
-F increment="$increment" \
171-
-F snapshot=false \
172173
"${args[@]}"
173174
log
174175

0 commit comments

Comments
 (0)