Skip to content

Commit 3376779

Browse files
committed
release.sh: Add dry-run
Signed-off-by: Stephen Gallagher <[email protected]>
1 parent a4aaea2 commit 3376779

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

release.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
# Created by argbash-init v2.10.0
3636
# ARG_OPTIONAL_SINGLE([commitish],[c],[The commit to be tagged for release.],[HEAD])
3737
# ARG_OPTIONAL_BOOLEAN([debug],[],[Print debugging output])
38+
# ARG_OPTIONAL_BOOLEAN([dry-run],[],[Make only local changes])
3839
# ARG_POSITIONAL_SINGLE([version],[The version of SSCG to release])
3940
# ARG_DEFAULTS_POS([])
4041
# ARG_HELP([Tags a new upstream release and submits])
@@ -67,15 +68,17 @@ _arg_version=
6768
# THE DEFAULTS INITIALIZATION - OPTIONALS
6869
_arg_commitish="HEAD"
6970
_arg_debug="off"
71+
_arg_dry_run="off"
7072

7173

7274
print_help()
7375
{
7476
printf '%s\n' "Tags a new upstream release and submits"
75-
printf 'Usage: %s [-c|--commitish <arg>] [--(no-)debug] [-h|--help] <version>\n' "$0"
77+
printf 'Usage: %s [-c|--commitish <arg>] [--(no-)debug] [--(no-)dry-run] [-h|--help] <version>\n' "$0"
7678
printf '\t%s\n' "<version>: The version of SSCG to release"
7779
printf '\t%s\n' "-c, --commitish: The commit to be tagged for release. (default: 'HEAD')"
7880
printf '\t%s\n' "--debug, --no-debug: Print debugging output (off by default)"
81+
printf '\t%s\n' "--dry-run, --no-dry-run: Make only local changes (off by default)"
7982
printf '\t%s\n' "-h, --help: Prints help"
8083
}
8184

@@ -102,6 +105,10 @@ parse_commandline()
102105
_arg_debug="on"
103106
test "${1:0:5}" = "--no-" && _arg_debug="off"
104107
;;
108+
--no-dry-run|--dry-run)
109+
_arg_dry_run="on"
110+
test "${1:0:5}" = "--no-" && _arg_dry_run="off"
111+
;;
105112
-h|--help)
106113
print_help
107114
exit 0
@@ -173,12 +180,14 @@ git diff --quiet HEAD --exit-code || git commit -sam "Updating version to ${_arg
173180
# Tag the new release
174181
git tag -sm "Releasing SSCG ${_arg_version}" ${tagname} ${_arg_commitish}
175182

176-
# Push the tag to Github
177-
git push origin main
178-
git push origin tag ${tagname}
183+
if [ "$_arg_dry_run" != "on" ]; then
184+
# Push the tag to Github
185+
git push origin main
186+
git push origin tag ${tagname}
179187

180-
# Create the release
181-
gh release create --generate-notes ${tagname}
188+
# Create the release
189+
gh release create --generate-notes ${tagname}
190+
fi
182191

183192

184193
# ^^^ TERMINATE YOUR CODE BEFORE THE BOTTOM ARGBASH MARKER ^^^

0 commit comments

Comments
 (0)