-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateRelease.sh
executable file
·72 lines (59 loc) · 1.8 KB
/
createRelease.sh
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
67
68
69
70
71
72
#!/bin/bash
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
-m)
if [[ -n "$2" ]]; then
COMMIT_MESSAGE="$2"
shift
else
echo "Missing value for -m argument"
exit 1
fi
;;
*)
echo "Unknown parameter passed: $1"
exit 1
;;
esac
shift
done
# Check if the profile argument is provided
if [[ -z "$COMMIT_MESSAGE" ]]; then
echo "Missing -m argument"
exit 1
fi
# Read the contents of version_number.js into a variable
version_file=$(cat src/version_number.ts)
echo $version_file
# Use a regular expression to extract the version number from the file
version_regex="const search_bar_version = ['\"]([0-9]+\.[0-9]+\.[0-9]+)['\"]"
if [[ $version_file =~ $version_regex ]]; then
search_bar_version=${BASH_REMATCH[1]}
else
echo "Error: Could not extract version number from version_number.ts"
exit 1
fi
# Use the version number in a command
echo "The current version is $search_bar_version"
# Create new tag
TAG_NAME="v$search_bar_version"
# Check if release with tag already exists
output=$(git ls-remote --tags origin "refs/tags/$TAG_NAME")
if [[ $output == *"refs/tags/$TAG_NAME"* ]]; then
echo "Release $TAG_NAME exists."
echo "Please make sure to increase the version number"
exit 1
else
echo "Release $TAG_NAME does not exist."
fi
echo "Creating new release"
npm version $search_bar_version --no-git-tag-version --allow-same-version
# commit changes
git add .
git commit -m "R $TAG_NAME: $COMMIT_MESSAGE"
git push
# create tag and push to remote repository
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
git push origin "$TAG_NAME"
gh release create "$TAG_NAME" --title "Release $TAG_NAME" --notes "$COMMIT_MESSAGE"