|
74 | 74 | git tag "$new_tag" --annotate --message "$new_tag Release"
|
75 | 75 | echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}"
|
76 | 76 |
|
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 |
82 | 78 | latest_major_tag=$(expr "$latest_tag" : "$major_tag_regex")
|
83 | 79 | new_major_tag=$(expr "$new_tag" : "$major_tag_regex")
|
84 | 80 |
|
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 |
88 | 94 | git tag "$latest_major_tag" --force --annotate --message "Sync $latest_major_tag tag with $new_tag"
|
89 | 95 | 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 |
91 | 106 | 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" |
93 | 116 | fi
|
94 | 117 |
|
95 | 118 | # Completed
|
|
0 commit comments