-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrelease
More file actions
executable file
·66 lines (53 loc) · 1.66 KB
/
release
File metadata and controls
executable file
·66 lines (53 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Usage:
# script/release
# COLORS
OFF='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
# Read the version from src/version.js
version_file="src/version.js"
if [[ ! -f $version_file ]]; then
echo -e "${RED}ERROR${OFF} - Version file not found: $version_file"
exit 1
fi
version_line=$(grep 'export const VERSION' $version_file)
if [[ -z $version_line ]]; then
echo -e "${RED}ERROR${OFF} - Version line not found in: $version_file"
exit 1
fi
# Extract the version value
new_tag=$(echo $version_line | sed -E "s/export const VERSION = '([^']+)'/\1/")
if [[ -z $new_tag ]]; then
echo -e "${RED}ERROR${OFF} - Failed to extract version from: $version_file"
exit 1
fi
# Validate the version tag format
tag_regex='^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$'
echo "$new_tag" | grep -E "$tag_regex" > /dev/null
if [[ $? -ne 0 ]]; then
echo -e "${RED}ERROR${OFF} - Tag: $new_tag is not valid. Please use vX.X.X or vX.X.X-rc.X format."
exit 1
fi
# Get the latest tag
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo -e "The latest release tag is: ${BLUE}${latest_tag}${OFF}"
# Confirm the new tag
read -p "New Release Tag (press ENTER for default: ${new_tag}): " input_tag
new_tag=${input_tag:-$new_tag}
# Tag the new release
git tag -a $new_tag -m "$new_tag Release"
if [[ $? -ne 0 ]]; then
echo -e "${RED}ERROR${OFF} - Failed to create tag: $new_tag"
exit 1
fi
echo -e "${GREEN}OK${OFF} - Tagged: $new_tag"
# Push the tags to remote
git push --tags
if [[ $? -ne 0 ]]; then
echo -e "${RED}ERROR${OFF} - Failed to push tags to remote"
exit 1
fi
echo -e "${GREEN}OK${OFF} - Tags pushed to remote!"
echo -e "${GREEN}DONE${OFF}"