-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushRelease
executable file
·60 lines (46 loc) · 1.02 KB
/
pushRelease
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
#!/bin/bash
fetch_latest_changes() {
git fetch origin master
git pull
git push
}
get_latest_tag() {
latest_tag=$(git describe --tags --abbrev=0)
echo "$latest_tag"
}
increment_version() {
version=$1
part=$2
if [[ ! "$version" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "Invalid version format: $version"
exit 1
fi
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
case "$part" in
"major")
((major++))
minor=0
patch=0
;;
"minor")
((minor++))
patch=0
;;
"patch")
((patch++))
;;
*)
echo "Invalid part: $part"
exit 1
;;
esac
echo "v$major.$minor.$patch"
}
fetch_latest_changes
latest_tag=$(get_latest_tag)
new_tag=$(increment_version "$latest_tag" "patch")
git tag "$new_tag"
git push origin "$new_tag"
echo "Created and pushed tag: $new_tag"