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

Skip to content

Commit 132c70e

Browse files
committed
Add -h, --help to release.sh
1 parent ce869dd commit 132c70e

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

scripts/release.sh

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,49 @@
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-
313
set -euo pipefail
324
# shellcheck source=scripts/lib.sh
335
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
346
cdroot
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+
3640
branch=main
3741
draft=0
3842
dry_run=0
3943
ref=
4044
increment=
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 -- "$@")"
4347
eval set -- "$args"
4448
while 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

scripts/release/increment_version_tag.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dry_run=0
1919
ref=HEAD
2020
increment=
2121

22-
args="$(getopt -o n -l dry-run,ref:,major,minor,patch -- "$@")"
22+
args="$(getopt -o '' -l dry-run,ref:,major,minor,patch -- "$@")"
2323
eval set -- "$args"
2424
while true; do
2525
case "$1" in

0 commit comments

Comments
 (0)