1
1
#! /usr/bin/env bash
2
2
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
-
31
3
set -euo pipefail
32
4
# shellcheck source=scripts/lib.sh
33
5
source " $( dirname " ${BASH_SOURCE[0]} " ) /lib.sh"
34
6
cdroot
35
7
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
+
36
40
branch=main
37
41
draft=0
38
42
dry_run=0
39
43
ref=
40
44
increment=
41
45
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 -- " $@ " ) "
43
47
eval set -- " $args "
44
48
while true ; do
45
49
case " $1 " in
@@ -58,6 +62,10 @@ while true; do
58
62
dry_run=1
59
63
shift
60
64
;;
65
+ -h | --help)
66
+ help
67
+ exit 0
68
+ ;;
61
69
--ref)
62
70
ref=" $2 "
63
71
shift 2
0 commit comments