Skip to content

Commit a6f9ca5

Browse files
committed
update the major version tag when creating a new release
1 parent 43c2d7b commit a6f9ca5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

script/release

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ set -e
2525
# Variables
2626
tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$'
2727
tag_glob='v[0-9].[0-9].[0-9]*'
28+
git_remote='origin'
29+
major_tag_regex='\(v[0-9]*\)'
2830

2931
# Terminal colors
3032
OFF='\033[0m'
@@ -75,4 +77,20 @@ echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}"
7577
# Push the new tag to the remote
7678
git push --follow-tags
7779
echo -e "Tags: ${BOLD_GREEN}$new_tag${OFF} pushed to remote"
80+
81+
# Check if the latest major release tag and the new major release tag are the same
82+
latest_major_tag=$(expr "$latest_tag" : "$major_tag_regex")
83+
new_major_tag=$(expr "$new_tag" : "$major_tag_regex")
84+
85+
if [[ "$new_major_tag" = "$latest_major_tag" ]]; then
86+
# This is a minor or patch release
87+
# Point major release tag (e.g. v1, v2) to this release
88+
git tag "$latest_major_tag" --force --annotate --message "Sync $latest_major_tag tag with $new_tag"
89+
echo -e "Synced ${BOLD_GREEN}$latest_major_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}"
90+
# Push major tag to remote
91+
git push $git_remote "$latest_major_tag" --force
92+
echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} pushed to remote"
93+
fi
94+
95+
# Completed
7896
echo -e "${BOLD_GREEN}Done!${OFF}"

0 commit comments

Comments
 (0)