-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathpatch.sh
More file actions
executable file
·100 lines (75 loc) · 2.35 KB
/
patch.sh
File metadata and controls
executable file
·100 lines (75 loc) · 2.35 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -e ;# exit on error
set -u ;# exit when using undeclared variable
#set -x
# Parameters
if [ "$#" -ne 1 ]; then
echo "A single parameter must be passed: the version to patch. $# provided."
exit 1
fi
currentVersion=$1
if [[ ! $currentVersion =~ ^v[0-9]+(\.[0-9]+){2,2}$ ]];
then
echo "The parameter must be provided in the form vx.y.z"
exit 2
fi
echo "Version to patch: $currentVersion";
# create the patch version: take the current version x.y.z and do z+1
delimiter=.
array=($(echo "$currentVersion" | tr $delimiter '\n'))
array[2]=$((array[2]+1))
patchVersion=$(IFS=$delimiter ; echo "${array[*]}")
echo "Patched version: $patchVersion";
# check
read -p "Do we continue ? [y|n]" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 3
fi
# checkout last tagged version
cd /tmp
echo "cloning in /tmp/QualityControl if not already there"
if [[ ! -d "/tmp/QualityControl" ]];
then
git clone git@github.com:AliceO2Group/QualityControl.git
fi
cd QualityControl
read -p "Github user ? " user
git remote rename origin upstream
git remote add origin git@github.com:user/QualityControl.git
echo "branch"
git checkout $currentVersion
git checkout -b branch_$patchVersion
echo "cherry-pick the commit from master"
read -p "Hash(es) to cherry-pick? (space separated if multiple)" hash
echo
git cherry-pick $hash
echo "change version in CMakeLists and commit"
patchVersionNumbers="${patchVersion:1}"
echo "patchVersionNumbers: $patchVersionNumbers"
case "$(uname -s)" in
Darwin)
sed -E -i '' 's/VERSION [0-9]+\.[0-9]+\.[0-9]+/VERSION '"${patchVersionNumbers}"'/g' CMakeLists.txt
;;
Linux)
sed -r -i 's/VERSION [0-9]+\.[0-9]+\.[0-9]+/VERSION '"${patchVersionNumbers}"'/g' CMakeLists.txt
;;
*)
echo 'Unknown OS'
exit 4
;;
esac
git add CMakeLists.txt
git commit -m "$patchVersion"
echo "push the branch upstream"
git push upstream -u branch_$patchVersion
echo "tag"
git tag -a $patchVersion -m "$patchVersion"
echo "push the tag upstream"
git push upstream $patchVersion
echo "Go to Github https://github.com/AliceO2Group/QualityControl/releases/new?tag=${patchVersion}&title=${patchVersion}"
read -p "Fill in the release notes and create the new release in GitHub" -n 1 -r
echo
read -p "A PR is automatically made in alidist, go check here: https://github.com/alisw/alidist/pulls"
echo "We are now done."