-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhotfix.sh
executable file
·73 lines (54 loc) · 1.65 KB
/
hotfix.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
source $(dirname "$0")/common.sh
start() {
info "hotfix start"
local main_branch=$(git_current_branch)
if [[ "$main_branch" != main ]]; then
info "Please checkout the main branch"
exit 0
fi
compare_and_check
local release_version="$(read_gradle_version)"
local hotfix_version="$(upgrade_patch_version $release_version)"
info "create hotfix/$hotfix_version"
update_gradle_version "${hotfix_version}-SNAPSHOT"
git add .
git commit -m "Update version for hotfix"
git checkout -b hotfix/$hotfix_version
git push origin hotfix/$hotfix_version
}
finish() {
info "hotfix finish"
local hotfix_branch=$(git_current_branch)
if [[ "$hotfix_branch" != hotfix* ]]; then
info "Please checkout the hotfix branch"
exit 0
fi
compare_and_check
local snapshot_version="$(read_gradle_version)"
local version="$(parse_snapshot_version $snapshot_version)"
update_gradle_version $version
git add .
git commit -m "Update version for hotfix"
git checkout main
git merge --no-ff -m "Merge from $hotfix_branch" $hotfix_branch
git tag -a $version -m "Tag for $version"
git push origin main
git push origin $version
target_branch="develop"
if [ "$2" ]; then
target_branch=$2
fi
git checkout $target_branch
local target_version="$(read_gradle_version)"
git checkout $hotfix_branch
update_gradle_version $target_version
git add .
git commit -m "Update to current development version"
git checkout $target_branch
git merge --no-ff -m "Merge $hotfix_branch back to develop" $hotfix_branch
git push origin $target_branch
git branch -D $hotfix_branch
git push origin -d $hotfix_branch
}
$1