-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathrelease.sh
executable file
·49 lines (41 loc) · 1.24 KB
/
release.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
#!/bin/bash
PREVIOUS_VERSION=$(git describe --abbrev=0 --tags)
echo "Choose the version component to increment:"
echo "1. Major"
echo "2. Minor"
echo "3. Patch"
read -p "Enter your choice: " choice
case $choice in
1)
# Increment the major version
MAJOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f1)
MAJOR=$((MAJOR + 1))
NEW_VERSION="$MAJOR.0.0"
;;
2)
# Increment the minor version
MAJOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f1)
MINOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f2)
MINOR=$((MINOR + 1))
NEW_VERSION="$MAJOR.$MINOR.0"
;;
3)
# Increment the patch version
MAJOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f1)
MINOR=$(echo "$PREVIOUS_VERSION" | cut -d. -f2)
PATCH=$(echo "$PREVIOUS_VERSION" | cut -d. -f3)
PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac
# Tag message
TAG_MESSAGE="Release version $NEW_VERSION"
# Create a new tag
git tag -a "$NEW_VERSION" -m "$TAG_MESSAGE"
# Push the tag to the remote repository
git push origin "$NEW_VERSION"
echo "Tag $NEW_VERSION has been created and pushed to the remote repository."