File tree Expand file tree Collapse file tree 1 file changed +32
-5
lines changed Expand file tree Collapse file tree 1 file changed +32
-5
lines changed Original file line number Diff line number Diff line change 22
33set -e
44
5+ DRY_RUN=1
6+
7+ while getopts " t" opt; do
8+ case $opt in
9+ t)
10+ DRY_RUN=0
11+ ;;
12+ \? )
13+ echo " Invalid option: -$OPTARG " >&2
14+ exit 1
15+ ;;
16+ esac
17+ done
18+
519help () {
620 cat << - EOF
7- Usage: TAG=tag $0
21+ Usage: TAG=tag $0 [-t]
822
923Creates git tags for public Go packages.
24+ The default behaviour is a dry-run.
1025
1126VARIABLES:
1227 TAG git tag, for example, v1.0.0
28+
29+ OPTIONS:
30+ -t Tag mode - executes git commands
1331EOF
1432 exit 0
1533}
@@ -31,12 +49,21 @@ PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; \
3149 | sed ' s/^\.\///' \
3250 | sort)
3351
34- git tag ${TAG}
35- git push origin ${TAG}
52+
53+ execute_git_command () {
54+ if [ " $DRY_RUN " -eq 0 ]; then
55+ " $@ "
56+ else
57+ echo " DRY-RUN: Would execute: $@ "
58+ fi
59+ }
60+
61+ execute_git_command git tag ${TAG}
62+ execute_git_command git push origin ${TAG}
3663
3764for dir in $PACKAGE_DIRS
3865do
3966 printf " tagging ${dir} /${TAG} \n"
40- git tag ${dir} /${TAG}
41- git push origin ${dir} /${TAG}
67+ execute_git_command git tag ${dir} /${TAG}
68+ execute_git_command git push origin ${dir} /${TAG}
4269done
You can’t perform that action at this time.
0 commit comments