-
Notifications
You must be signed in to change notification settings - Fork 289
/
release.sh
executable file
·196 lines (177 loc) · 5.3 KB
/
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#! /usr/bin/env bash
# use this script to make a new release
# just type ./release.sh
# and follow instructions
confirm () {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
update_changelog() {
echo $1 $2 $3
awk -v version="$2" -v shortversion="$3" -v date="$4" '{
if(version == shortversion ".0" && $1=="##" && $2=="Version" && $3==shortversion){
print "## Version " shortversion " (" date ")"
done=1
} else if($1=="##" && $2=="Version" && $3==version){
print "## Version " version " (" date ")"
done=1
} else if(!done && $1=="##" && $2=="Unreleased" && $3=="changes"){
print "## Version " version " (" date ")"
} else print
}' $1 > $1.tmp
mv $1.tmp $1
}
VALIDATED=
if [ "$1" = --validated ] ; then
VALIDATED=yes
elif test -n "$1" ; then
echo ERROR
echo "cannot understand $1 option"
exit 1
fi
echo "*** Only use this script if you want to release a new PLUMED version. ***"
echo "*** Follow instructions below, and use Control-C to exit. ***"
ls src README.md 1>/dev/null 2>/dev/null || {
echo "Launch from root directory"
exit 1
}
# Guess version number:
branch="$(git status | grep "On branch" | awk '{print $3}')"
for((i=0;;i++))
do
guess="${branch#v}.$i"
if ! git tag | grep -q "^v${guess//./\\.}$" ; then
echo "Guessed next version: ${guess}"
break;
fi
done
case "$branch" in
(v2.?*)
read -r -p "Type the version number (default: ${guess}): " version
case "$version" in
("")
version="$guess"
esac
;;
(*)
read -r -p "Type the version number (e.g. 2.1.3 or 2.2b): " version
;;
esac
case "$version" in
(2.?*)
version="${version#2.}"
;;
(*)
echo "ERROR"
echo "Use a version in form 2.*"
exit 1
;;
esac
shortversion=$(echo "$version" | sed 's/^\([0-9][0-9]*\).*/\1/' )
version=2.$version
shortversion=2.$shortversion
echo "major version v$shortversion"
echo "minor version v$version"
if test $version == $shortversion ; then
echo "ERROR"
echo "please add a patch identified so that tag and branch have different names"
exit 1
fi
if test "$(git tag -l | awk '{if($1=="'v$version'")print "yes"}')" == yes ; then
echo "tag v$version already exists"
exit 1
fi
echo "checking out branch v$shortversion"
git checkout v$shortversion
set -e
if ! test "$VALIDATED" ; then
update_changelog CHANGES/v$shortversion.md $version $shortversion "coming soon"
echo
msg="Travis tests for v$version
"
echo "Now I will add an empty commit and push the result to origin"
echo "I will use the following commands:"
echo "***"
echo "git add CHANGES/v$shortversion.md"
echo "git commit --allow-empty -m \"$msg\""
echo "git push origin v$shortversion"
echo "***"
confirm || exit
git add CHANGES/v$shortversion.md
git commit --allow-empty -m "$msg"
git push -f origin v$shortversion:test-v$shortversion
echo
echo "Now you should go at this link:"
echo " http://travis-ci.org/plumed/plumed2/builds"
echo "and wait for travis to finish the tests"
echo "In case of failures, fix and repeat the procedure"
echo "Also check the online manual, that should be here:"
echo " http://www.plumed.org/doc-v$shortversion"
echo "In case of success, relaunch this script as \"./release.sh --validated\""
else
update_changelog CHANGES/v$shortversion.md $version $shortversion "$(date '+%b %e, %Y' | sed 's/ / /g')"
{
grep \# VERSION.txt
echo $version
} > VERSION.tmp
mv VERSION.tmp VERSION.txt
echo "Here's the new VERSION file:"
echo "***"
cat VERSION.txt
echo "***"
msg="Release v$version
"
echo "Now I will add it, prepare a release commit, add a tag named v$version"
echo "push it to origin and create a tgz file"
echo "I will use the following commands:"
echo "***"
echo "git add CHANGES/v$shortversion.md"
echo "git add VERSION.txt"
echo "git commit --allow-empty -m \"$msg\""
echo "git tag v$version"
echo "git push origin v$version"
echo "git archive -o plumed-$version.tgz --prefix plumed-$version/ v$version"
echo "***"
confirm || exit
git add CHANGES/v$shortversion.md
git add VERSION.txt
git commit --allow-empty -m "$msg"
git tag v$version
git push origin v$shortversion v$version
git archive -o plumed-$version.tgz --prefix plumed-$version/ v$version
echo
echo "Done!"
echo "Now creating partial tar files"
rm -fr plumed-$version
tar xzf plumed-$version.tgz
tar czf plumed-doc-$version.tgz plumed-$version/*-doc
tar czf plumed-test-$version.tgz plumed-$version/regtest
rm -fr plumed-$version/*-doc
rm -fr plumed-$version/regtest
tar czf plumed-src-$version.tgz plumed-$version
rm -fr plumed-$version
cd macports
plumed_repository=https://github.com/plumed/plumed2.git make
cd ../
echo "**** NOW DO THE FOLLOWING THINGS ****"
echo
echo "1. Upload the file plumed-$version.tgz on the download directory"
echo
echo "2. Make a new github release and upload these files:"
echo "plumed-$version.tgz"
echo "plumed-doc-$version.tgz"
echo "plumed-test-$version.tgz"
echo "plumed-src-$version.tgz"
echo
echo "3. Update MacPorts and Conda-Forge"
echo "WARNING: make sure MacPorts and Conda-Forge only build python 3 wrappers!"
echo "4. Notify the mailing list"
fi