-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathgenerate-release.sh
executable file
·85 lines (70 loc) · 2.2 KB
/
generate-release.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
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
## Usage: ./generate-release.sh [-f] 3 0 0
# must be run from top-level scale folder
if [[ $1 == "-f" ]]; then
force=1
shift
fi
ver=($*)
verstring=$(IFS=. ; echo "${ver[*]}")
if [[ "${verstring}x" == "x" ]]
then
echo Missing version parameter!
echo Usage:
echo ./generate-release.sh [-f] 7 0 0
exit 1
fi
tput setaf 2
echo "Building release $verstring"
tput sgr0
if [[ $(git rev-parse --abbrev-ref HEAD) != "master" ]]; then
tput setaf 1
echo "Current branch is not master!"
tput sgr0
git rev-parse --abbrev-ref HEAD
if [[ ! $force ]]; then exit 1; fi
fi
git diff-index --quiet HEAD
if [[ $? != 0 ]]; then
tput setaf 1
echo "Current index is not clean!"
tput sgr0
git diff-index HEAD
if [[ ! $force ]]; then exit 1; fi
fi
tput setaf 2
echo -e "\nChange the revision on master"
tput sgr0
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '-snapshot')/" scale/scale/__init__.py
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '-snapshot___BUILDNUM___')/" scale/scale/__init__.py.template
grep "VERSION = " scale/scale/__init__.py scale/scale/__init__.py.template
tput setaf 2
echo -e "\nCommit and push the change"
tput sgr0
git commit -a -m "Update snapshot revision to $verstring"
git push origin HEAD
tput setaf 2
echo -e "\nDetach the head"
tput sgr0
git checkout --detach
tput setaf 2
echo -e "\nChange the revision on the release"
tput sgr0
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '')/" scale/scale/__init__.py
sed -i "" -e "s/^VERSION = version_info_t.*$/VERSION = version_info_t($1, $2, $3, '___BUILDNUM___')/" scale/scale/__init__.py.template
grep "VERSION = " scale/scale/__init__.py scale/scale/__init__.py.template
tput setaf 2
echo -e "\nCommit the change"
tput sgr0
git commit -a -m "Update version values for release $verstring"
tput setaf 2
echo -e "\nTag the release"
tput sgr0
git tag -a -m "Scale release $verstring" $verstring
tput setaf 2
echo -e "\nPush the changes"
tput sgr0
git push --tags
tput setaf 2
echo -e "\nDon't forget to update the release notes: https://github.com/ngageoint/scale/releases/edit/$verstring"
tput sgr0