Skip to content

Commit 2d70c12

Browse files
Add release script
1 parent ca2c60d commit 2d70c12

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

release.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
if [[ "$#" -ne 1 ]] || [[ ! $1 =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
3+
echo "Usage: $0 vX.Y.Z"
4+
exit 1
5+
fi
6+
7+
branch=$(git branch --show-current)
8+
9+
if [[ "$branch" != "main" ]]; then
10+
echo "You're in the \"${branch}\" branch, you need to switch to main"
11+
exit 1
12+
fi
13+
14+
major=v${BASH_REMATCH[1]}
15+
minor=${major}.${BASH_REMATCH[2]}
16+
patch=${minor}.${BASH_REMATCH[3]}
17+
18+
echo "HEAD is $(git log -1 --pretty="%h: %B")"
19+
read -p "You are about to create the following tags: ${major}, ${minor} and ${patch}, continue? [y/n] " -r -n 1
20+
echo
21+
22+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
23+
echo "Aborting..."
24+
exit 1
25+
fi
26+
27+
echo "Creating tag ${major}"
28+
git tag -f ${major}
29+
30+
echo "Creating tag ${minor}"
31+
git tag -f ${minor}
32+
33+
echo "Creating tag ${patch}"
34+
git tag -f ${patch}
35+
36+
read -p "Tags created, push? [y/n] " -r -n 1
37+
echo
38+
39+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
40+
echo "Aborting..."
41+
exit 1
42+
fi
43+
44+
git push
45+
git push --tags -f

0 commit comments

Comments
 (0)