File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
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."
You can’t perform that action at this time.
0 commit comments