Skip to content

Commit dde8e76

Browse files
committed
improved release script
1 parent 7f3150a commit dde8e76

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tag-release.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
#!/bin/bash
22

3-
SEMVER_REGEX='^v([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z0-9]+)?$'
3+
# Just in case the script is run from another directory
4+
SCRIPT_DIR=$(cd -P -- $(dirname -- "$0") && pwd -P)
5+
cd $SCRIPT_DIR
6+
7+
MODULE_PATHS=("" "cli/" "htmlform/" "cmd/gen-func-wrappers/")
48

9+
SEMVER_REGEX='^v([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z0-9]+)?$'
510
if [[ ! "$1" =~ $SEMVER_REGEX ]]; then
611
echo "Usage: $0 <version> [message]"
712
exit 1
813
fi
914

1015
VERSION=$1
1116
MESSAGE="$VERSION"
12-
13-
# Check if a message was provided as the second argument
1417
if [ -n "$2" ]; then
15-
MESSAGE="$2"
18+
MESSAGE="$2" # provided as the second argument
1619
fi
1720

1821
echo "Tagging $VERSION with message: '$MESSAGE'"
1922

20-
git tag -a $VERSION -m "$MESSAGE"
21-
git tag -a cli/$VERSION -m "$MESSAGE"
22-
git tag -a htmlform/$VERSION -m "$MESSAGE"
23-
git tag -a cmd/gen-func-wrappers/$VERSION -m "$MESSAGE"
23+
for PREFIX in "${MODULE_PATHS[@]}"; do
24+
git tag -a "${PREFIX}${VERSION}" -m "$MESSAGE"
25+
done
2426

2527
echo "Tags to be pushed:"
2628
git push --tags --dry-run
@@ -30,9 +32,8 @@ read CONFIRM
3032
if [[ "$CONFIRM" == "y" || "$CONFIRM" == "Y" ]]; then
3133
git push origin --tags
3234
else
33-
git tag -d $VERSION
34-
git tag -d cli/$VERSION
35-
git tag -d htmlform/$VERSION
36-
git tag -d cmd/gen-func-wrappers/$VERSION
35+
for PREFIX in "${MODULE_PATHS[@]}"; do
36+
git tag -d "${PREFIX}${VERSION}"
37+
done
3738
echo "Reverted local $VERSION tags"
3839
fi

0 commit comments

Comments
 (0)