Skip to content

Commit 277dc0c

Browse files
committed
fixup! ci: Do release tagging in CI and add --draft support
1 parent 2048a81 commit 277dc0c

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

scripts/release.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,34 @@
2222
# "feat(api)!:") or the PR that was merged can be tagged with the
2323
# "release/breaking" label.
2424
#
25-
# Usage: ./release.sh [--draft] [--dry-run] [--ref <ref>] [--major | --minor | --patch]
25+
# To test changes to this script, you can set `--branch <my-branch>`, which will
26+
# run the release workflow in CI as a dry-run and use the latest commit on the
27+
# specified branch as the release commit. This will also set --dry-run.
28+
#
29+
# Usage: ./release.sh [--branch <name>] [--draft] [--dry-run] [--ref <ref>] [--major | --minor | --patch]
2630

2731
set -euo pipefail
2832
# shellcheck source=scripts/lib.sh
2933
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
3034
cdroot
3135

36+
branch=main
3237
draft=0
3338
dry_run=0
3439
ref=
3540
increment=
3641

37-
args="$(getopt -o n -l draft,dry-run,ref:,major,minor,patch -- "$@")"
42+
args="$(getopt -o n -l branch:,draft,dry-run,ref:,major,minor,patch -- "$@")"
3843
eval set -- "$args"
3944
while true; do
4045
case "$1" in
46+
--branch)
47+
branch="$2"
48+
log "Using branch $branch, implies DRYRUN and CODER_IGNORE_MISSING_COMMIT_METADATA."
49+
dry_run=1
50+
export CODER_IGNORE_MISSING_COMMIT_METADATA=1
51+
shift 2
52+
;;
4153
--draft)
4254
draft=1
4355
shift
@@ -77,13 +89,13 @@ fi
7789

7890
# Make sure the repository is up-to-date before generating release notes.
7991
log "Fetching main and tags from origin..."
80-
git fetch --quiet --tags origin main
92+
git fetch --quiet --tags origin "$branch"
8193

8294
# Resolve to the latest ref on origin/main unless otherwise specified.
83-
ref=$(git rev-parse --short "${ref:-origin/main}")
95+
ref=$(git rev-parse --short "${ref:-origin/$branch}")
8496

8597
# Make sure that we're running the latest release script.
86-
if [[ -n $(git diff --name-status origin/main -- ./scripts/release.sh) ]]; then
98+
if [[ -n $(git diff --name-status origin/"$branch" -- ./scripts/release.sh) ]]; then
8799
error "Release script is out-of-date. Please check out the latest version and try again."
88100
fi
89101

@@ -128,8 +140,9 @@ if ((dry_run)); then
128140
fi
129141

130142
gh workflow run release.yaml \
131-
--ref main \
143+
--ref "$branch" \
132144
-F increment="$increment" \
145+
-F snapshot=false \
133146
"${args[@]}"
134147

135148
log "Release process started, you can watch the release via: gh run watch --exit-status <run-id>"

0 commit comments

Comments
 (0)