-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
74 lines (57 loc) · 1.5 KB
/
release
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
73
74
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Function to create a release
create_release() {
VERSION=$1
if [ -z "$VERSION" ]; then
echo "Usage: $0 create vx.y.z"
exit 1
fi
# Tag the repository with the provided version
git tag -a "$VERSION" -m "Release $VERSION"
# Checkout the tag to trigger post-commit hook to update gitinfo2 info file
git checkout
# show the reltag line of .git/gitHeadInfo.gin
grep reltag .git/gitHeadInfo.gin
cp .git/gitHeadInfo.gin gitHeadLocal.gin
git add gitHeadLocal.gin
git commit -m "Updated gitHeadLocal.gin for release $VERSION"
git tag -f -a "$VERSION" -m "Release $VERSION"
# Push the changes and the tags
git push origin main --follow-tags
echo "Release $VERSION created and pushed successfully."
}
# Function to list releases
list_releases() {
git tag
}
# Function to delete a release
delete_release() {
VERSION=$1
if [ -z "$VERSION" ]; then
echo "Usage: $0 delete vx.y.z"
exit 1
fi
# Delete the tag locally
git tag -d "$VERSION"
# Delete the tag remotely
#git push origin --delete "$VERSION"
echo "Release $VERSION deleted successfully."
}
# Main script logic
case "$1" in
create)
create_release "$2"
;;
list)
list_releases
;;
delete)
delete_release "$2"
;;
*)
echo "Usage: $0 {create|list|delete} [version]"
exit 1
;;
esac