Skip to content

Commit 1c49bf9

Browse files
committed
consider the new release being a major release
This implementation also creates a `releases/v#` branch off of the previous major version tag
1 parent a6f9ca5 commit 1c49bf9

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

script/release

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,45 @@ fi
7474
git tag "$new_tag" --annotate --message "$new_tag Release"
7575
echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}"
7676

77-
# Push the new tag to the remote
78-
git push --follow-tags
79-
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
77+
# Set 'is_major_release' variable
8278
latest_major_tag=$(expr "$latest_tag" : "$major_tag_regex")
8379
new_major_tag=$(expr "$new_tag" : "$major_tag_regex")
8480

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
81+
if ! [[ "$new_major_tag" = "$latest_major_tag" ]]; then
82+
is_major_release='yes'
83+
else
84+
is_major_release='no'
85+
fi
86+
87+
# Point major release tag (e.g. v1, v2) to this release
88+
if [ $is_major_release = 'yes' ]; then
89+
# Create a new major verison tag and point to this release
90+
git tag "$new_major_tag" --annotate --message "$new_major_tag Release"
91+
echo -e "New major version tag: ${BOLD_GREEN}$new_major_tag${OFF}"
92+
else
93+
# Update the major verison tag to point to this release
8894
git tag "$latest_major_tag" --force --annotate --message "Sync $latest_major_tag tag with $new_tag"
8995
echo -e "Synced ${BOLD_GREEN}$latest_major_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}"
90-
# Push major tag to remote
96+
fi
97+
98+
# Push the new tags (with commits, if any) to remote
99+
git push --follow-tags
100+
101+
if [ $is_major_release = 'yes' ]; then
102+
# New major version tag is pushed with the '--follow-tags' flags
103+
echo -e "Tags: ${BOLD_GREEN}$new_major_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote"
104+
else
105+
# Force push the updated major version tag
91106
git push $git_remote "$latest_major_tag" --force
92-
echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} pushed to remote"
107+
echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote"
108+
fi
109+
110+
# If this is a major release, create a 'releases/(latest_major_tag)' branch and push
111+
if [ $is_major_release = 'yes' ]; then
112+
git branch "releases/$latest_major_tag" "$latest_major_tag"
113+
echo -e "Branch: ${BOLD_BLUE}releases/$latest_major_tag${OFF} created from ${BOLD_BLUE}$latest_major_tag${OFF} tag"
114+
git push --set-upstream $git_remote "releases/$latest_major_tag"
115+
echo -e "Branch: ${BOLD_GREEN}releases/$latest_major_tag${OFF} pushed to remote"
93116
fi
94117

95118
# Completed

0 commit comments

Comments
 (0)