11#! /usr/bin/env bash
22
3- # This script should be called to create a new release.
4- #
5- # When run, this script will display the new version number and optionally a
6- # preview of the release notes. The new version will be selected automatically
7- # based on if the release contains breaking changes or not. If the release
8- # contains breaking changes, a new minor version will be created. Otherwise, a
9- # new patch version will be created.
10- #
11- # Set --ref if you need to specify a specific commit that the new version will
12- # be tagged at, otherwise the latest commit will be used.
13- #
14- # Set --minor to force a minor version bump, even when there are no breaking
15- # changes. Likewise for --major. By default a patch version will be created.
16- #
17- # Set --dry-run to run the release workflow in CI as a dry-run (no release will
18- # be created).
19- #
20- # To mark a release as containing breaking changes, the commit title should
21- # either contain a known prefix with an exclamation mark ("feat!:",
22- # "feat(api)!:") or the PR that was merged can be tagged with the
23- # "release/breaking" label.
24- #
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]
30-
313set -euo pipefail
324# shellcheck source=scripts/lib.sh
335source " $( dirname " ${BASH_SOURCE[0]} " ) /lib.sh"
346cdroot
357
8+ help () {
9+ cat << -EOH
10+ Usage: ./release.sh [--branch <name>] [--draft] [--dry-run] [--ref <ref>] [--major | --minor | --patch]
11+
12+ This script should be called to create a new release.
13+
14+ When run, this script will display the new version number and optionally a
15+ preview of the release notes. The new version will be selected automatically
16+ based on if the release contains breaking changes or not. If the release
17+ contains breaking changes, a new minor version will be created. Otherwise, a
18+ new patch version will be created.
19+
20+ Set --ref if you need to specify a specific commit that the new version will
21+ be tagged at, otherwise the latest commit will be used.
22+
23+ Set --minor to force a minor version bump, even when there are no breaking
24+ changes. Likewise for --major. By default a patch version will be created.
25+
26+ Set --dry-run to run the release workflow in CI as a dry-run (no release will
27+ be created).
28+
29+ To mark a release as containing breaking changes, the commit title should
30+ either contain a known prefix with an exclamation mark ("feat!:",
31+ "feat(api)!:") or the PR that was merged can be tagged with the
32+ "release/breaking" label.
33+
34+ To test changes to this script, you can set --branch <my-branch>, which will
35+ run the release workflow in CI as a dry-run and use the latest commit on the
36+ specified branch as the release commit. This will also set --dry-run.
37+ EOH
38+ }
39+
3640branch=main
3741draft=0
3842dry_run=0
3943ref=
4044increment=
4145
42- args=" $( getopt -o n -l branch:,draft,dry-run,ref:,major,minor,patch -- " $@ " ) "
46+ args=" $( getopt -o h -l branch:,draft,dry-run,help ,ref:,major,minor,patch -- " $@ " ) "
4347eval set -- " $args "
4448while true ; do
4549 case " $1 " in
@@ -58,6 +62,10 @@ while true; do
5862 dry_run=1
5963 shift
6064 ;;
65+ -h | --help)
66+ help
67+ exit 0
68+ ;;
6169 --ref)
6270 ref=" $2 "
6371 shift 2
0 commit comments