@@ -9,23 +9,58 @@ RED='\033[0;31m'
99GREEN=' \033[0;32m'
1010BLUE=' \033[0;34m'
1111
12- latest_tag=$( git describe --tags $( git rev-list --tags --max-count=1) )
13- echo -e " The latest release tag is: ${BLUE}${latest_tag}${OFF} "
14- read -p ' New Release Tag (vX.X.X format): ' new_tag
12+ # Read the version from src/version.js
13+ version_file=" src/version.js"
14+ if [[ ! -f $version_file ]]; then
15+ echo -e " ${RED} ERROR${OFF} - Version file not found: $version_file "
16+ exit 1
17+ fi
18+
19+ version_line=$( grep ' export const VERSION' $version_file )
20+ if [[ -z $version_line ]]; then
21+ echo -e " ${RED} ERROR${OFF} - Version line not found in: $version_file "
22+ exit 1
23+ fi
24+
25+ # Extract the version value
26+ new_tag=$( echo $version_line | sed -E " s/export const VERSION = '([^']+)'/\1/" )
27+ if [[ -z $new_tag ]]; then
28+ echo -e " ${RED} ERROR${OFF} - Failed to extract version from: $version_file "
29+ exit 1
30+ fi
1531
16- tag_regex=' ^v[0-9]+\.[0-9]+\.[0-9]+$'
17- echo " $new_tag " | grep -E " $tag_regex "
32+ # Validate the version tag format
33+ tag_regex=' ^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$'
34+ echo " $new_tag " | grep -E " $tag_regex " > /dev/null
1835
1936if [[ $? -ne 0 ]]; then
20- echo -e " ${RED} ERROR${OFF} - Tag: $new_tag is not valid. Please use vX.X.X format."
37+ echo -e " ${RED} ERROR${OFF} - Tag: $new_tag is not valid. Please use vX.X.X or vX.X.X-rc.X format."
2138 exit 1
2239fi
2340
41+ # Get the latest tag
42+ latest_tag=$( git describe --tags $( git rev-list --tags --max-count=1) )
43+ echo -e " The latest release tag is: ${BLUE}${latest_tag}${OFF} "
44+
45+ # Confirm the new tag
46+ read -p " New Release Tag (press ENTER for default: ${new_tag} ): " input_tag
47+ new_tag=${input_tag:- $new_tag }
48+
49+ # Tag the new release
2450git tag -a $new_tag -m " $new_tag Release"
51+ if [[ $? -ne 0 ]]; then
52+ echo -e " ${RED} ERROR${OFF} - Failed to create tag: $new_tag "
53+ exit 1
54+ fi
2555
2656echo -e " ${GREEN} OK${OFF} - Tagged: $new_tag "
2757
58+ # Push the tags to remote
2859git push --tags
60+ if [[ $? -ne 0 ]]; then
61+ echo -e " ${RED} ERROR${OFF} - Failed to push tags to remote"
62+ exit 1
63+ fi
2964
3065echo -e " ${GREEN} OK${OFF} - Tags pushed to remote!"
3166echo -e " ${GREEN} DONE${OFF} "
0 commit comments