@@ -23,17 +23,17 @@ set -e
23
23
# 7. Set 'is_major_release' variable
24
24
# 8. Point separate major release tag (e.g. v1, v2) to the new release
25
25
# 9. Push the new tags (with commits, if any) to remote
26
- # 10. If this is a major release, create a 'releases/(latest_major_tag) ' branch and push
26
+ # 10. If this is a major release, create a 'releases/v# ' branch and push
27
27
#
28
28
# Usage:
29
29
#
30
30
# script/release
31
31
32
32
# Variables
33
- tag_regex =' v[0-9]+\.[0-9]+\.[0-9]+$'
34
- tag_glob =' v[0-9].[0-9].[0-9]*'
33
+ semver_tag_regex =' v[0-9]+\.[0-9]+\.[0-9]+$'
34
+ semver_tag_glob =' v[0-9].[0-9].[0-9]*'
35
35
git_remote=' origin'
36
- major_tag_regex =' \(v[0-9]*\)'
36
+ major_semver_tag_regex =' \(v[0-9]*\)'
37
37
38
38
# Terminal colors
39
39
OFF=' \033[0m'
@@ -45,7 +45,7 @@ BOLD_UNDERLINED='\033[1;4m'
45
45
BOLD=' \033[1m'
46
46
47
47
# 1. Retrieve the latest release tag
48
- if ! latest_tag=$( git describe --abbrev=0 --match=" $tag_glob " ) ; then
48
+ if ! latest_tag=$( git describe --abbrev=0 --match=" $semver_tag_glob " ) ; then
49
49
# There are no existing release tags
50
50
echo -e " No tags found (yet) - Continue to create and push your first tag"
51
51
latest_tag=" [unknown]"
@@ -58,7 +58,7 @@ echo -e "The latest release tag is: ${BOLD_BLUE}${latest_tag}${OFF}"
58
58
read -r -p ' Enter a new release tag (vX.X.X format): ' new_tag
59
59
60
60
# 4. Validate the new release tag
61
- if echo " $new_tag " | grep -q -E " $tag_regex " ; then
61
+ if echo " $new_tag " | grep -q -E " $semver_tag_regex " ; then
62
62
# Release tag is valid
63
63
echo -e " Tag: ${BOLD_BLUE} $new_tag ${OFF} is valid syntax"
64
64
else
@@ -82,44 +82,44 @@ git tag "$new_tag" --annotate --message "$new_tag Release"
82
82
echo -e " Tagged: ${BOLD_GREEN} $new_tag ${OFF} "
83
83
84
84
# 7. Set 'is_major_release' variable
85
- latest_major_tag =$( expr " $latest_tag " : " $major_tag_regex " )
86
- new_major_tag =$( expr " $new_tag " : " $major_tag_regex " )
85
+ latest_major_release_tag =$( expr " $latest_tag " : " $major_semver_tag_regex " )
86
+ new_major_release_tag =$( expr " $new_tag " : " $major_semver_tag_regex " )
87
87
88
- if ! [[ " $new_major_tag " = " $latest_major_tag " ]]; then
88
+ if ! [[ " $new_major_release_tag " = " $latest_major_release_tag " ]]; then
89
89
is_major_release=' yes'
90
90
else
91
91
is_major_release=' no'
92
92
fi
93
93
94
94
# 8. Point separate major release tag (e.g. v1, v2) to the new release
95
95
if [ $is_major_release = ' yes' ]; then
96
- # Create a new major verison tag and point to this release
97
- git tag " $new_major_tag " --annotate --message " $new_major_tag Release"
98
- echo -e " New major version tag: ${BOLD_GREEN} $new_major_tag ${OFF} "
96
+ # Create a new major verison tag and point it to this release
97
+ git tag " $new_major_release_tag " --annotate --message " $new_major_release_tag Release"
98
+ echo -e " New major version tag: ${BOLD_GREEN} $new_major_release_tag ${OFF} "
99
99
else
100
- # Update the major verison tag to point to this release
101
- git tag " $latest_major_tag " --force --annotate --message " Sync $latest_major_tag tag with $new_tag "
102
- echo -e " Synced ${BOLD_GREEN} $latest_major_tag ${OFF} with ${BOLD_GREEN} $new_tag ${OFF} "
100
+ # Update the major verison tag to point it to this release
101
+ git tag " $latest_major_release_tag " --force --annotate --message " Sync $latest_major_release_tag tag with $new_tag "
102
+ echo -e " Synced ${BOLD_GREEN} $latest_major_release_tag ${OFF} with ${BOLD_GREEN} $new_tag ${OFF} "
103
103
fi
104
104
105
105
# 9. Push the new tags (with commits, if any) to remote
106
106
git push --follow-tags
107
107
108
108
if [ $is_major_release = ' yes' ]; then
109
109
# New major version tag is pushed with the '--follow-tags' flags
110
- echo -e " Tags: ${BOLD_GREEN} $new_major_tag ${OFF} and ${BOLD_GREEN} $new_tag ${OFF} pushed to remote"
110
+ echo -e " Tags: ${BOLD_GREEN} $new_major_release_tag ${OFF} and ${BOLD_GREEN} $new_tag ${OFF} pushed to remote"
111
111
else
112
112
# Force push the updated major version tag
113
- git push $git_remote " $latest_major_tag " --force
114
- echo -e " Tags: ${BOLD_GREEN} $latest_major_tag ${OFF} and ${BOLD_GREEN} $new_tag ${OFF} pushed to remote"
113
+ git push $git_remote " $latest_major_release_tag " --force
114
+ echo -e " Tags: ${BOLD_GREEN} $latest_major_release_tag ${OFF} and ${BOLD_GREEN} $new_tag ${OFF} pushed to remote"
115
115
fi
116
116
117
- # 10. If this is a major release, create a 'releases/(latest_major_tag) ' branch and push
117
+ # 10. If this is a major release, create a 'releases/v# ' branch and push
118
118
if [ $is_major_release = ' yes' ]; then
119
- git branch " releases/$latest_major_tag " " $latest_major_tag "
120
- echo -e " Branch: ${BOLD_BLUE} releases/$latest_major_tag ${OFF} created from ${BOLD_BLUE} $latest_major_tag ${OFF} tag"
121
- git push --set-upstream $git_remote " releases/$latest_major_tag "
122
- echo -e " Branch: ${BOLD_GREEN} releases/$latest_major_tag ${OFF} pushed to remote"
119
+ git branch " releases/$latest_major_release_tag " " $latest_major_release_tag "
120
+ echo -e " Branch: ${BOLD_BLUE} releases/$latest_major_release_tag ${OFF} created from ${BOLD_BLUE} $latest_major_release_tag ${OFF} tag"
121
+ git push --set-upstream $git_remote " releases/$latest_major_release_tag "
122
+ echo -e " Branch: ${BOLD_GREEN} releases/$latest_major_release_tag ${OFF} pushed to remote"
123
123
fi
124
124
125
125
# Completed
0 commit comments