|
22 | 22 | # "feat(api)!:") or the PR that was merged can be tagged with the
|
23 | 23 | # "release/breaking" label.
|
24 | 24 | #
|
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] |
26 | 30 |
|
27 | 31 | set -euo pipefail
|
28 | 32 | # shellcheck source=scripts/lib.sh
|
29 | 33 | source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
30 | 34 | cdroot
|
31 | 35 |
|
| 36 | +branch=main |
32 | 37 | draft=0
|
33 | 38 | dry_run=0
|
34 | 39 | ref=
|
35 | 40 | increment=
|
36 | 41 |
|
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 -- "$@")" |
38 | 43 | eval set -- "$args"
|
39 | 44 | while true; do
|
40 | 45 | 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 | + ;; |
41 | 53 | --draft)
|
42 | 54 | draft=1
|
43 | 55 | shift
|
|
77 | 89 |
|
78 | 90 | # Make sure the repository is up-to-date before generating release notes.
|
79 | 91 | log "Fetching main and tags from origin..."
|
80 |
| -git fetch --quiet --tags origin main |
| 92 | +git fetch --quiet --tags origin "$branch" |
81 | 93 |
|
82 | 94 | # 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}") |
84 | 96 |
|
85 | 97 | # 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 |
87 | 99 | error "Release script is out-of-date. Please check out the latest version and try again."
|
88 | 100 | fi
|
89 | 101 |
|
@@ -128,8 +140,9 @@ if ((dry_run)); then
|
128 | 140 | fi
|
129 | 141 |
|
130 | 142 | gh workflow run release.yaml \
|
131 |
| - --ref main \ |
| 143 | + --ref "$branch" \ |
132 | 144 | -F increment="$increment" \
|
| 145 | + -F snapshot=false \ |
133 | 146 | "${args[@]}"
|
134 | 147 |
|
135 | 148 | log "Release process started, you can watch the release via: gh run watch --exit-status <run-id>"
|
0 commit comments