From 67934fecc6f03cfaf4feadb423886cd7b1c554a8 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 02:17:03 +0100 Subject: [PATCH 01/18] move `tag_regex` to variables section --- script/release | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/release b/script/release index 1ae8d07..aa883e2 100755 --- a/script/release +++ b/script/release @@ -18,6 +18,9 @@ # # script/release +# Variables +tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$' + # Terminal colors OFF='\033[0m' RED='\033[0;31m' @@ -40,7 +43,6 @@ echo -e "The latest release tag is: ${BLUE}${latest_tag}${OFF}" read -r -p 'Enter a new release tag (vX.X.X format): ' new_tag # Validate the new release tag -tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$' if echo "$new_tag" | grep -q -E "$tag_regex"; then echo -e "Tag: ${BLUE}$new_tag${OFF} is valid" else From be270a6def94a1d39045a7782de3940e2e831b51 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 02:37:14 +0100 Subject: [PATCH 02/18] improve the git describe command - When using the [action versioning recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations), a commit can have duplicate tags (v2, v2.1.2). - The previous implementation did not take that into consideration. - With this new implementation, v2.1.2 is returned even when v2 is the newer commit tag (which is usually the case). - Also, when running this script from another branch (let's say 'releases/v1'), the previous implementation would return newer tags in other branches. - NOTE: This new implementation only searches for annotated tags. --- script/release | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/release b/script/release index aa883e2..81242a2 100755 --- a/script/release +++ b/script/release @@ -20,6 +20,7 @@ # Variables tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$' +tag_glob='v[0-9].[0-9].[0-9]*' # Terminal colors OFF='\033[0m' @@ -28,7 +29,7 @@ GREEN='\033[0;32m' BLUE='\033[0;34m' # Get the latest release tag -latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)") +latest_tag=$(git describe --abbrev=0 --match="$tag_glob") if [[ -z "$latest_tag" ]]; then # There are no existing release tags From 35b1cc8b7b50b04367651ff4a4bbcc873ebd967b Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 02:39:31 +0100 Subject: [PATCH 03/18] terminate script when a command fails - Previously, when the git push command failed, the script would still echo a success message. - This commit also makes sure the git describe command does not terminate the script. --- script/release | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index 81242a2..22cc111 100755 --- a/script/release +++ b/script/release @@ -1,5 +1,9 @@ #!/bin/bash +# Exit early +# See: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin +set -e + # About: # # This is a helper script to tag and push a new release. GitHub Actions use @@ -29,9 +33,7 @@ GREEN='\033[0;32m' BLUE='\033[0;34m' # Get the latest release tag -latest_tag=$(git describe --abbrev=0 --match="$tag_glob") - -if [[ -z "$latest_tag" ]]; then +if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then # There are no existing release tags echo -e "No tags found (yet) - Continue to create and push your first tag" latest_tag="[unknown]" From 4b33f5f5b18d380ceac014085c1371af671f7480 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 02:41:04 +0100 Subject: [PATCH 04/18] use `--follow-tags` flag to push to remote - Using `--follow-tags` instead of `--tags` can be the saner option - `follow-tags` also pushes commits --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 22cc111..4da760f 100755 --- a/script/release +++ b/script/release @@ -59,6 +59,6 @@ git tag -a "$new_tag" -m "$new_tag Release" echo -e "${GREEN}Tagged: $new_tag${OFF}" # Push the new tag to the remote -git push --tags +git push --follow-tags echo -e "${GREEN}Release tag pushed to remote${OFF}" echo -e "${GREEN}Done!${OFF}" From a28b58b06713240437fdbf34a35b5e4b7c5e2ed9 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 02:42:58 +0100 Subject: [PATCH 05/18] make the colored text bold --- script/release | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/script/release b/script/release index 4da760f..d54d37d 100755 --- a/script/release +++ b/script/release @@ -28,9 +28,9 @@ tag_glob='v[0-9].[0-9].[0-9]*' # Terminal colors OFF='\033[0m' -RED='\033[0;31m' -GREEN='\033[0;32m' -BLUE='\033[0;34m' +BOLD_RED='\033[1;31m' +BOLD_GREEN='\033[1;32m' +BOLD_BLUE='\033[1;34m' # Get the latest release tag if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then @@ -40,25 +40,25 @@ if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then fi # Display the latest release tag -echo -e "The latest release tag is: ${BLUE}${latest_tag}${OFF}" +echo -e "The latest release tag is: ${BOLD_BLUE}${latest_tag}${OFF}" # Prompt the user for the new release tag read -r -p 'Enter a new release tag (vX.X.X format): ' new_tag # Validate the new release tag if echo "$new_tag" | grep -q -E "$tag_regex"; then - echo -e "Tag: ${BLUE}$new_tag${OFF} is valid" + echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is valid" else # Release tag is not `vX.X.X` format - echo -e "Tag: ${BLUE}$new_tag${OFF} is ${RED}not valid${OFF} (must be in vX.X.X format)" + echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is ${BOLD_RED}not valid${OFF} (must be in vX.X.X format)" exit 1 fi # Tag the new release git tag -a "$new_tag" -m "$new_tag Release" -echo -e "${GREEN}Tagged: $new_tag${OFF}" +echo -e "${BOLD_GREEN}Tagged: $new_tag${OFF}" # Push the new tag to the remote git push --follow-tags -echo -e "${GREEN}Release tag pushed to remote${OFF}" -echo -e "${GREEN}Done!${OFF}" +echo -e "${BOLD_GREEN}Release tag pushed to remote${OFF}" +echo -e "${BOLD_GREEN}Done!${OFF}" From 371c87b4e5d7ec213492982c21008c9e6cfee072 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 03:06:46 +0100 Subject: [PATCH 06/18] remind user to update `version` field in package.json --- script/release | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/script/release b/script/release index d54d37d..3bd3dbc 100755 --- a/script/release +++ b/script/release @@ -31,6 +31,8 @@ OFF='\033[0m' BOLD_RED='\033[1;31m' BOLD_GREEN='\033[1;32m' BOLD_BLUE='\033[1;34m' +BOLD_PURPLE='\033[1;35m' +BOLD_UNDERLINED='\033[1;4m' # Get the latest release tag if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then @@ -54,6 +56,16 @@ else exit 1 fi +# Remind user to update the version field in package.json +echo -e -n "Make sure the version field in package.json is ${BOLD_BLUE}$new_tag${OFF}. Yes? [Y/${BOLD_UNDERLINED}n${OFF}] " +read -r YN + +if [[ ! ($YN == "y" || $YN == "Y") ]]; then + # Package.json version field is not up to date + echo -e "Please update the package.json version to ${BOLD_PURPLE}$new_tag${OFF} and commit your changes" + exit 1 +fi + # Tag the new release git tag -a "$new_tag" -m "$new_tag Release" echo -e "${BOLD_GREEN}Tagged: $new_tag${OFF}" From c3a8d435e7ba91f25014e976317926347a0d0dc2 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 03:22:26 +0100 Subject: [PATCH 07/18] improve debug messages --- script/release | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/script/release b/script/release index 3bd3dbc..44c81bd 100755 --- a/script/release +++ b/script/release @@ -33,6 +33,7 @@ BOLD_GREEN='\033[1;32m' BOLD_BLUE='\033[1;34m' BOLD_PURPLE='\033[1;35m' BOLD_UNDERLINED='\033[1;4m' +BOLD='\033[1m' # Get the latest release tag if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then @@ -49,10 +50,11 @@ read -r -p 'Enter a new release tag (vX.X.X format): ' new_tag # Validate the new release tag if echo "$new_tag" | grep -q -E "$tag_regex"; then - echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is valid" + # Release tag is valid + echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is valid syntax" else # Release tag is not `vX.X.X` format - echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is ${BOLD_RED}not valid${OFF} (must be in vX.X.X format)" + echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is ${BOLD_RED}not valid${OFF} (must be in ${BOLD}vX.X.X${OFF} format)" exit 1 fi @@ -68,9 +70,9 @@ fi # Tag the new release git tag -a "$new_tag" -m "$new_tag Release" -echo -e "${BOLD_GREEN}Tagged: $new_tag${OFF}" +echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}" # Push the new tag to the remote git push --follow-tags -echo -e "${BOLD_GREEN}Release tag pushed to remote${OFF}" +echo -e "Tags: ${BOLD_GREEN}$new_tag${OFF} pushed to remote" echo -e "${BOLD_GREEN}Done!${OFF}" From 43c2d7b8657fae626567162ee0ddcd7bd5e97a50 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 03:25:01 +0100 Subject: [PATCH 08/18] spell out the git command flags used --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 44c81bd..6459a1f 100755 --- a/script/release +++ b/script/release @@ -69,7 +69,7 @@ if [[ ! ($YN == "y" || $YN == "Y") ]]; then fi # Tag the new release -git tag -a "$new_tag" -m "$new_tag Release" +git tag "$new_tag" --annotate --message "$new_tag Release" echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}" # Push the new tag to the remote From a6f9ca5bd3349bf154eac0370861e3cecee148d0 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 03:26:29 +0100 Subject: [PATCH 09/18] update the major version tag when creating a new release --- script/release | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/script/release b/script/release index 6459a1f..821b39b 100755 --- a/script/release +++ b/script/release @@ -25,6 +25,8 @@ set -e # Variables tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$' tag_glob='v[0-9].[0-9].[0-9]*' +git_remote='origin' +major_tag_regex='\(v[0-9]*\)' # Terminal colors OFF='\033[0m' @@ -75,4 +77,20 @@ echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}" # Push the new tag to the remote git push --follow-tags echo -e "Tags: ${BOLD_GREEN}$new_tag${OFF} pushed to remote" + +# Check if the latest major release tag and the new major release tag are the same +latest_major_tag=$(expr "$latest_tag" : "$major_tag_regex") +new_major_tag=$(expr "$new_tag" : "$major_tag_regex") + +if [[ "$new_major_tag" = "$latest_major_tag" ]]; then + # This is a minor or patch release + # Point major release tag (e.g. v1, v2) to this release + git tag "$latest_major_tag" --force --annotate --message "Sync $latest_major_tag tag with $new_tag" + echo -e "Synced ${BOLD_GREEN}$latest_major_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}" + # Push major tag to remote + git push $git_remote "$latest_major_tag" --force + echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} pushed to remote" +fi + +# Completed echo -e "${BOLD_GREEN}Done!${OFF}" From 1c49bf9c0449c04f4a148a7702a7588577670423 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 03:48:23 +0100 Subject: [PATCH 10/18] consider the new release being a major release This implementation also creates a `releases/v#` branch off of the previous major version tag --- script/release | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/script/release b/script/release index 821b39b..bd3cc07 100755 --- a/script/release +++ b/script/release @@ -74,22 +74,45 @@ fi git tag "$new_tag" --annotate --message "$new_tag Release" echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}" -# Push the new tag to the remote -git push --follow-tags -echo -e "Tags: ${BOLD_GREEN}$new_tag${OFF} pushed to remote" - -# Check if the latest major release tag and the new major release tag are the same +# Set 'is_major_release' variable latest_major_tag=$(expr "$latest_tag" : "$major_tag_regex") new_major_tag=$(expr "$new_tag" : "$major_tag_regex") -if [[ "$new_major_tag" = "$latest_major_tag" ]]; then - # This is a minor or patch release - # Point major release tag (e.g. v1, v2) to this release +if ! [[ "$new_major_tag" = "$latest_major_tag" ]]; then + is_major_release='yes' +else + is_major_release='no' +fi + +# Point major release tag (e.g. v1, v2) to this release +if [ $is_major_release = 'yes' ]; then + # Create a new major verison tag and point to this release + git tag "$new_major_tag" --annotate --message "$new_major_tag Release" + echo -e "New major version tag: ${BOLD_GREEN}$new_major_tag${OFF}" +else + # Update the major verison tag to point to this release git tag "$latest_major_tag" --force --annotate --message "Sync $latest_major_tag tag with $new_tag" echo -e "Synced ${BOLD_GREEN}$latest_major_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}" - # Push major tag to remote +fi + +# Push the new tags (with commits, if any) to remote +git push --follow-tags + +if [ $is_major_release = 'yes' ]; then + # New major version tag is pushed with the '--follow-tags' flags + echo -e "Tags: ${BOLD_GREEN}$new_major_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote" +else + # Force push the updated major version tag git push $git_remote "$latest_major_tag" --force - echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} pushed to remote" + echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote" +fi + +# If this is a major release, create a 'releases/(latest_major_tag)' branch and push +if [ $is_major_release = 'yes' ]; then + git branch "releases/$latest_major_tag" "$latest_major_tag" + echo -e "Branch: ${BOLD_BLUE}releases/$latest_major_tag${OFF} created from ${BOLD_BLUE}$latest_major_tag${OFF} tag" + git push --set-upstream $git_remote "releases/$latest_major_tag" + echo -e "Branch: ${BOLD_GREEN}releases/$latest_major_tag${OFF} pushed to remote" fi # Completed From 5613359501307e4f361a42c6993166f44b4430ff Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 03:48:57 +0100 Subject: [PATCH 11/18] minor comment change --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index bd3cc07..5bd4212 100755 --- a/script/release +++ b/script/release @@ -55,7 +55,7 @@ if echo "$new_tag" | grep -q -E "$tag_regex"; then # Release tag is valid echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is valid syntax" else - # Release tag is not `vX.X.X` format + # Release tag is not in `vX.X.X` format echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is ${BOLD_RED}not valid${OFF} (must be in ${BOLD}vX.X.X${OFF} format)" exit 1 fi From 9da7ccc2835e0ebd1458c67b0fc015a5d5440215 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 04:33:03 +0100 Subject: [PATCH 12/18] update script steps --- script/release | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/script/release b/script/release index 5bd4212..9386563 100755 --- a/script/release +++ b/script/release @@ -13,10 +13,16 @@ set -e # # This script will do the following: # -# 1. Get the latest release tag -# 2. Prompt the user for a new release tag -# 3. Tag the new release -# 4. Push the new tag to the remote +# 1. Retrieve the latest release tag +# 2. Display the latest release tag +# 3. Prompt the user for a new release tag +# 4. Validate the new release tag +# 5. Remind user to update the version field in package.json +# 6. Tag a new release +# 7. Set 'is_major_release' variable +# 8. Point separate major release tag (e.g. v1, v2) to the new release +# 9. Push the new tags (with commits, if any) to remote +# 10. If this is a major release, create a 'releases/(latest_major_tag)' branch and push # # Usage: # @@ -37,20 +43,20 @@ BOLD_PURPLE='\033[1;35m' BOLD_UNDERLINED='\033[1;4m' BOLD='\033[1m' -# Get the latest release tag +# 1. Retrieve the latest release tag if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then # There are no existing release tags echo -e "No tags found (yet) - Continue to create and push your first tag" latest_tag="[unknown]" fi -# Display the latest release tag +# 2. Display the latest release tag echo -e "The latest release tag is: ${BOLD_BLUE}${latest_tag}${OFF}" -# Prompt the user for the new release tag +# 3. Prompt the user for a new release tag read -r -p 'Enter a new release tag (vX.X.X format): ' new_tag -# Validate the new release tag +# 4. Validate the new release tag if echo "$new_tag" | grep -q -E "$tag_regex"; then # Release tag is valid echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is valid syntax" @@ -60,7 +66,7 @@ else exit 1 fi -# Remind user to update the version field in package.json +# 5. Remind user to update the version field in package.json echo -e -n "Make sure the version field in package.json is ${BOLD_BLUE}$new_tag${OFF}. Yes? [Y/${BOLD_UNDERLINED}n${OFF}] " read -r YN @@ -70,11 +76,11 @@ if [[ ! ($YN == "y" || $YN == "Y") ]]; then exit 1 fi -# Tag the new release +# 6. Tag a new release git tag "$new_tag" --annotate --message "$new_tag Release" echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}" -# Set 'is_major_release' variable +# 7. Set 'is_major_release' variable latest_major_tag=$(expr "$latest_tag" : "$major_tag_regex") new_major_tag=$(expr "$new_tag" : "$major_tag_regex") @@ -84,7 +90,7 @@ else is_major_release='no' fi -# Point major release tag (e.g. v1, v2) to this release +# 8. Point separate major release tag (e.g. v1, v2) to the new release if [ $is_major_release = 'yes' ]; then # Create a new major verison tag and point to this release git tag "$new_major_tag" --annotate --message "$new_major_tag Release" @@ -95,7 +101,7 @@ else echo -e "Synced ${BOLD_GREEN}$latest_major_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}" fi -# Push the new tags (with commits, if any) to remote +# 9. Push the new tags (with commits, if any) to remote git push --follow-tags if [ $is_major_release = 'yes' ]; then @@ -107,7 +113,7 @@ else echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote" fi -# If this is a major release, create a 'releases/(latest_major_tag)' branch and push +# 10. If this is a major release, create a 'releases/(latest_major_tag)' branch and push if [ $is_major_release = 'yes' ]; then git branch "releases/$latest_major_tag" "$latest_major_tag" echo -e "Branch: ${BOLD_BLUE}releases/$latest_major_tag${OFF} created from ${BOLD_BLUE}$latest_major_tag${OFF} tag" From 3b79f20e3a6bcdd84bb82ad9c858246f5864ce4a Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 04:37:30 +0100 Subject: [PATCH 13/18] update readme to reflect changes made --- README.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3e1c006..928f679 100644 --- a/README.md +++ b/README.md @@ -217,13 +217,16 @@ GitHub Actions allows users to select a specific version of the action to use, based on release tags. This script simplifies this process by performing the following steps: -1. **Retrieving the latest release tag:** The script starts by fetching the most - recent release tag by looking at the local data available in your repository. -1. **Prompting for a new release tag:** The user is then prompted to enter a new - release tag. To assist with this, the script displays the latest release tag - and provides a regular expression to validate the format of the new tag. -1. **Tagging the new release:** Once a valid new tag is entered, the script tags - the new release. -1. **Pushing the new tag to the remote:** Finally, the script pushes the new tag - to the remote repository. From here, you will need to create a new release in - GitHub and users can easily reference the new tag in their workflows. +1. **Retrieving the latest release tag:** The script starts by fetching the + most recent release tag of the current branch, by looking at the local data + available in your repository. +1. **Prompting for a new release tag:** The user is then prompted to enter a + new release tag. To assist with this, the script displays the tag retrieved + in the previous step, and validates the format of the inputted tag (vX.X.X). + The user is also reminded to update the version field in package.json. +1. **Tagging the new release:** The script then tags a new release and syncs + the separate major tag with the new release. When the user is creating a new + major release, the script auto-detects that and creates a `releases/v#` + branch for the previous major version. +1. **Pushing changes to remote:** Finally, the script pushes the necessary + commits, tags and branches to the remote repository. From d393e547d07492c83f4e35f6d0091a0b0e6089a6 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 05:01:18 +0100 Subject: [PATCH 14/18] add link to action versioning recommendation --- script/release | 1 + 1 file changed, 1 insertion(+) diff --git a/script/release b/script/release index 9386563..21cde4a 100755 --- a/script/release +++ b/script/release @@ -10,6 +10,7 @@ set -e # release tags to allow users to select a specific version of the action to use. # # See: https://github.com/actions/typescript-action#publishing-a-new-release +# See: https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations # # This script will do the following: # From 6590bf4e0c73cc55af055b69209099c1499a3f8a Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 17:11:32 +0100 Subject: [PATCH 15/18] update Publishing a New Release docs --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 928f679..8d5b3e7 100644 --- a/README.md +++ b/README.md @@ -218,15 +218,16 @@ based on release tags. This script simplifies this process by performing the following steps: 1. **Retrieving the latest release tag:** The script starts by fetching the - most recent release tag of the current branch, by looking at the local data - available in your repository. + most recent semver release tag of the current branch, by looking at the + local data available in your repository. 1. **Prompting for a new release tag:** The user is then prompted to enter a new release tag. To assist with this, the script displays the tag retrieved in the previous step, and validates the format of the inputted tag (vX.X.X). The user is also reminded to update the version field in package.json. 1. **Tagging the new release:** The script then tags a new release and syncs - the separate major tag with the new release. When the user is creating a new - major release, the script auto-detects that and creates a `releases/v#` - branch for the previous major version. + the separate major tag (e.g. v1, v2) with the new release tag + (e.g. v1.0.0, v2.1.2). When the user is creating a new major release, the + script auto-detects this and creates a `releases/v#` branch for the previous + major version. 1. **Pushing changes to remote:** Finally, the script pushes the necessary commits, tags and branches to the remote repository. From 8ca79d724787f015558a2e06d366b6980d4e5ca3 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 17:21:55 +0100 Subject: [PATCH 16/18] improve var names and comments --- script/release | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/script/release b/script/release index 21cde4a..9e23fd2 100755 --- a/script/release +++ b/script/release @@ -23,17 +23,17 @@ set -e # 7. Set 'is_major_release' variable # 8. Point separate major release tag (e.g. v1, v2) to the new release # 9. Push the new tags (with commits, if any) to remote -# 10. If this is a major release, create a 'releases/(latest_major_tag)' branch and push +# 10. If this is a major release, create a 'releases/v#' branch and push # # Usage: # # script/release # Variables -tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$' -tag_glob='v[0-9].[0-9].[0-9]*' +semver_tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$' +semver_tag_glob='v[0-9].[0-9].[0-9]*' git_remote='origin' -major_tag_regex='\(v[0-9]*\)' +major_semver_tag_regex='\(v[0-9]*\)' # Terminal colors OFF='\033[0m' @@ -45,7 +45,7 @@ BOLD_UNDERLINED='\033[1;4m' BOLD='\033[1m' # 1. Retrieve the latest release tag -if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then +if ! latest_tag=$(git describe --abbrev=0 --match="$semver_tag_glob"); then # There are no existing release tags echo -e "No tags found (yet) - Continue to create and push your first tag" latest_tag="[unknown]" @@ -58,7 +58,7 @@ echo -e "The latest release tag is: ${BOLD_BLUE}${latest_tag}${OFF}" read -r -p 'Enter a new release tag (vX.X.X format): ' new_tag # 4. Validate the new release tag -if echo "$new_tag" | grep -q -E "$tag_regex"; then +if echo "$new_tag" | grep -q -E "$semver_tag_regex"; then # Release tag is valid echo -e "Tag: ${BOLD_BLUE}$new_tag${OFF} is valid syntax" else @@ -82,10 +82,10 @@ git tag "$new_tag" --annotate --message "$new_tag Release" echo -e "Tagged: ${BOLD_GREEN}$new_tag${OFF}" # 7. Set 'is_major_release' variable -latest_major_tag=$(expr "$latest_tag" : "$major_tag_regex") -new_major_tag=$(expr "$new_tag" : "$major_tag_regex") +latest_major_release_tag=$(expr "$latest_tag" : "$major_semver_tag_regex") +new_major_release_tag=$(expr "$new_tag" : "$major_semver_tag_regex") -if ! [[ "$new_major_tag" = "$latest_major_tag" ]]; then +if ! [[ "$new_major_release_tag" = "$latest_major_release_tag" ]]; then is_major_release='yes' else is_major_release='no' @@ -93,13 +93,13 @@ fi # 8. Point separate major release tag (e.g. v1, v2) to the new release if [ $is_major_release = 'yes' ]; then - # Create a new major verison tag and point to this release - git tag "$new_major_tag" --annotate --message "$new_major_tag Release" - echo -e "New major version tag: ${BOLD_GREEN}$new_major_tag${OFF}" + # Create a new major verison tag and point it to this release + git tag "$new_major_release_tag" --annotate --message "$new_major_release_tag Release" + echo -e "New major version tag: ${BOLD_GREEN}$new_major_release_tag${OFF}" else - # Update the major verison tag to point to this release - git tag "$latest_major_tag" --force --annotate --message "Sync $latest_major_tag tag with $new_tag" - echo -e "Synced ${BOLD_GREEN}$latest_major_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}" + # Update the major verison tag to point it to this release + git tag "$latest_major_release_tag" --force --annotate --message "Sync $latest_major_release_tag tag with $new_tag" + echo -e "Synced ${BOLD_GREEN}$latest_major_release_tag${OFF} with ${BOLD_GREEN}$new_tag${OFF}" fi # 9. Push the new tags (with commits, if any) to remote @@ -107,19 +107,19 @@ git push --follow-tags if [ $is_major_release = 'yes' ]; then # New major version tag is pushed with the '--follow-tags' flags - echo -e "Tags: ${BOLD_GREEN}$new_major_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote" + echo -e "Tags: ${BOLD_GREEN}$new_major_release_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote" else # Force push the updated major version tag - git push $git_remote "$latest_major_tag" --force - echo -e "Tags: ${BOLD_GREEN}$latest_major_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote" + git push $git_remote "$latest_major_release_tag" --force + echo -e "Tags: ${BOLD_GREEN}$latest_major_release_tag${OFF} and ${BOLD_GREEN}$new_tag${OFF} pushed to remote" fi -# 10. If this is a major release, create a 'releases/(latest_major_tag)' branch and push +# 10. If this is a major release, create a 'releases/v#' branch and push if [ $is_major_release = 'yes' ]; then - git branch "releases/$latest_major_tag" "$latest_major_tag" - echo -e "Branch: ${BOLD_BLUE}releases/$latest_major_tag${OFF} created from ${BOLD_BLUE}$latest_major_tag${OFF} tag" - git push --set-upstream $git_remote "releases/$latest_major_tag" - echo -e "Branch: ${BOLD_GREEN}releases/$latest_major_tag${OFF} pushed to remote" + git branch "releases/$latest_major_release_tag" "$latest_major_release_tag" + echo -e "Branch: ${BOLD_BLUE}releases/$latest_major_release_tag${OFF} created from ${BOLD_BLUE}$latest_major_release_tag${OFF} tag" + git push --set-upstream $git_remote "releases/$latest_major_release_tag" + echo -e "Branch: ${BOLD_GREEN}releases/$latest_major_release_tag${OFF} pushed to remote" fi # Completed From eef8edb8ef87e2fe0f83c8a4f40d49488d4736dc Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 17:25:02 +0100 Subject: [PATCH 17/18] update Pushing changes to remote docs --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d5b3e7..8c0da11 100644 --- a/README.md +++ b/README.md @@ -230,4 +230,6 @@ following steps: script auto-detects this and creates a `releases/v#` branch for the previous major version. 1. **Pushing changes to remote:** Finally, the script pushes the necessary - commits, tags and branches to the remote repository. + commits, tags and branches to the remote repository. From here, you will + need to create a new release in GitHub so users can easily reference the + new tags in their workflows. From 95dd9a459e3cb6e94b2e2391b59bea833e1008fe Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Fri, 9 Aug 2024 15:09:09 +0100 Subject: [PATCH 18/18] fix spacing in readme --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8c0da11..3f92a2f 100644 --- a/README.md +++ b/README.md @@ -217,19 +217,19 @@ GitHub Actions allows users to select a specific version of the action to use, based on release tags. This script simplifies this process by performing the following steps: -1. **Retrieving the latest release tag:** The script starts by fetching the - most recent semver release tag of the current branch, by looking at the - local data available in your repository. -1. **Prompting for a new release tag:** The user is then prompted to enter a - new release tag. To assist with this, the script displays the tag retrieved - in the previous step, and validates the format of the inputted tag (vX.X.X). - The user is also reminded to update the version field in package.json. -1. **Tagging the new release:** The script then tags a new release and syncs - the separate major tag (e.g. v1, v2) with the new release tag - (e.g. v1.0.0, v2.1.2). When the user is creating a new major release, the - script auto-detects this and creates a `releases/v#` branch for the previous - major version. +1. **Retrieving the latest release tag:** The script starts by fetching the most + recent semver release tag of the current branch, by looking at the local data + available in your repository. +1. **Prompting for a new release tag:** The user is then prompted to enter a new + release tag. To assist with this, the script displays the tag retrieved in + the previous step, and validates the format of the inputted tag (vX.X.X). The + user is also reminded to update the version field in package.json. +1. **Tagging the new release:** The script then tags a new release and syncs the + separate major tag (e.g. v1, v2) with the new release tag (e.g. v1.0.0, + v2.1.2). When the user is creating a new major release, the script + auto-detects this and creates a `releases/v#` branch for the previous major + version. 1. **Pushing changes to remote:** Finally, the script pushes the necessary - commits, tags and branches to the remote repository. From here, you will - need to create a new release in GitHub so users can easily reference the - new tags in their workflows. + commits, tags and branches to the remote repository. From here, you will need + to create a new release in GitHub so users can easily reference the new tags + in their workflows.