Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4df8bcf

Browse files
committedAug 16, 2024
Added shell script for releaseing
1 parent 6effc04 commit 4df8bcf

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
 

‎release.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# This script creates a tag for the repository and pushes it to the remote
4+
# repository. The remote repository is configured to trigger a GitHub Actions
5+
# workflow when a new tag is pushed, which will create a release on GitHub
6+
# using the tag.
7+
8+
9+
# Check for the correct number of input parameters
10+
if [ "$#" -ne 1 ]; then
11+
echo "Error: Incorrect number of arguments."
12+
echo "Usage: $0 <version-number>"
13+
echo "Example: $0 v1.0.1"
14+
exit 1
15+
fi
16+
17+
# Define the tag
18+
TAG="release_$1"
19+
20+
# Check if the tag already exists
21+
if git rev-parse "$TAG" >/dev/null 2>&1; then
22+
echo "Error: Tag $TAG already exists."
23+
24+
# Ask user if they want to replace the existing tag
25+
read -p "Do you want to replace the existing tag? (y/n) " answer
26+
case $answer in
27+
[Yy]* )
28+
# Delete the tag locally
29+
git tag -d "$TAG"
30+
# Delete the tag from the remote
31+
git push origin --delete "$TAG"
32+
;;
33+
* )
34+
echo "Operation aborted."
35+
exit 1
36+
;;
37+
esac
38+
fi
39+
40+
# Create the annotated tag
41+
# git tag -a "$TAG" -m "$MESSAGE"
42+
git tag -a "$TAG"
43+
44+
# Push the tag to the remote repository
45+
git push origin "$TAG"
46+
47+
echo "Tag $TAG created and pushed successfully."

0 commit comments

Comments
 (0)
Please sign in to comment.