-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·377 lines (335 loc) · 9.23 KB
/
release
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
#!/bin/bash
# Script: release This SpaceFM developer's script performs a release
# License: GNU GENERAL PUBLIC LICENSE Version 3 http://www.gnu.org/licenses/gpl-3.0.txt
keyid='ignorantguru@gmx.com' # default key used for signing tag
debian_id='IgnorantGuru <ignorantguru@gmx.com>' # written to debian changelog
make_opt='-sj2'
prog="spacefm"
configure="configure.ac"
me_name='release' # name of this script
# define branches to use (usually only change these for testing):
next='next'
master='master'
curdir="$(pwd)"
# deny root user
if [ "$(whoami)" = "root" ]; then
echo "$me_name: no root use" 1>&2
exit 1
fi
cat << EOF
SpaceFM Release
This script is for use by developers. It interactively performs a release of
SpaceFM by increasing the version number, preparing the source dir for
distribution, commiting the $next branch, merging to $master, signing the
release tag, pushing $master, starting the next version, and pushing $next.
This script must be run from the git $next branch.
Manual workflow BEFORE continuing:
backup issues (optional)
pull translations from Transifex (tx pull OR tx pull -fl LANG)
update pot if needed (cd po && ./update-pot && cd .. && tx push -s)
finalize Changelog
build and install without warnings (GTK2 and GTK3)
EOF
# verify on next branch
git_status=`git status`
if [ "${git_status#On branch $next}" = "$git_status" ]; then
echo "$me_name: not on branch $next" 1>&2
exit 1
fi
if [ ! -e "$configure" ]; then
echo "$me_name: $configure not found" 1>&2
exit 1
fi
# get configure version
ver=`grep -m 1 "^AC_INIT(\[$prog\], \[" "$configure" \
| sed "s/AC_INIT(\[$prog\], \[\(.*\)\])/\1/"`
if [ "$ver" = "" ]; then
echo "$me_name: cannot get version" 1>&2
exit 1
fi
# get new version
echo -n "Enter new release version (current is $ver): "
read newver
if [ -z "$newver" ] || [ "${newver/ /}" != "$newver" ]; then
echo "Invalid version. Aborted." 1>&2
exit 1
fi
# set configure version
echo
echo "Changing $configure version $ver to $newver..."
#AC_INIT([spacefm], [1.0.0+next])
sed -i "s/^AC_INIT(\[$prog\], \[[0-9]\..*\])/AC_INIT(\[$prog\], \[$newver\])/" $configure
# test configure version changed
testver=`grep -m 1 "^AC_INIT(\[$prog\], \[" "$configure" \
| sed "s/AC_INIT(\[$prog\], \[\(.*\)\])/\1/"`
if [ "$testver" != "$newver" ]; then
echo "$me_name: change of version in $configure failed" 1>&2
exit 1
fi
# set distros/debian/changelog version
echo "Setting version in distros/debian/changelog..."
cat << EOF > "distros/debian/changelog"
$prog ($newver-1) unstable; urgency=low
* release
-- $debian_id $(date -uR)
EOF
if [ $? -ne 0 ]; then
echo "$me_name: error writing distros/debian/changelog" 1>&2
exit 1
fi
# Rebuild manual
echo "Rebuilding manual with new version..."
echo ">>> cd data"
cd data || exit 1
rm -f spacefm-manual-en.html
echo ">>> time ./build-manual > spacefm-manual-en.html"
time ./build-manual > spacefm-manual-en.html || exit 1
if ( ! grep -q "SpaceFM version $newver" spacefm-manual-en.html ) || \
[ ! "$(stat -c %s spacefm-manual-en.html)" -gt 400000 ]; then
echo "$me_name: manual missing new version or too small" 1>&2
exit 1
fi
if [ -d ../../spacefm-gh-pages ]; then
echo
echo "Copying manual to spacefm-gh-pages..."
cp spacefm-manual-en.html ../../spacefm-gh-pages || exit 1
cp spacefm-manual-en.html \
../../spacefm-gh-pages/spacefm-manual-next-en.html || exit 1
fi
echo ">>> cd .."
cd .. || exit 1
# make spacefm.pot
#echo
#echo -n "Update spacefm.pot? [y/N] "
#read potmsg
#if [ "$potmsg" = "y" ] || [ "$potmsg" = "Y" ]; then
# echo
# cd po || exit 1
# rm -f spacefm.pot
# ./update-pot
# if [ $? -ne 0 ] || [ ! -s spacefm.pot ]; then
# echo "$me_name: error creating po/spacefm.pot" 1>&2
# exit 1
# fi
# cd .. || exit 1
#fi
# Pull wiki
if [ -d ../spacefm-wiki ]; then
echo
echo -n "Pull ../spacefm-wiki? [Y/n] "
read pullwiki
if [ -z "$pullwiki" ] || [ "$pullwiki" = "y" ] || [ "$pullwiki" = "Y" ]; then
echo "Pulling ../spacefm-wiki"
echo ">>> cd ../spacefm-wiki"
cd ../spacefm-wiki || exit 1
git status
echo ">>> git pull origin master"
git pull origin master
echo ">>> cd '$curdir'"
cd "$curdir" || exit 1
fi
fi
# autoreconf
echo
echo "Running autoreconf..."
rm -f configure aclocal.m4 config.log config.status Makefile Makefile.in
#echo ">>> NOCONFIGURE=x ./autogen.sh"
#NOCONFIGURE=x ./autogen.sh
echo ">>> autoreconf"
autoreconf || exit 1
# configure
echo
echo "Running configure..."
echo ">>> env CFLAGS=-O3 ./configure --prefix=/usr"
env CFLAGS=-O3 ./configure --prefix=/usr
err=$?
rm -rf autom4te.cache
if [ $err -ne 0 ]; then
echo "$me_name: configure returned error $err" 1>&2
exit 1
fi
# make clean and test
echo
echo "Testing make..."
echo ">>> make clean"
make clean || exit 1
echo ">>> make $make_opt"
make $make_opt || exit 1
echo ">>> make clean"
make clean || exit 1
echo
# commit
echo "Release is ready to be commited and merged to $master."
echo
echo ">>> git status"
git status
echo "(all unstaged changes will be added - new files are not added)"
echo
msg_def="release $newver"
echo -n "Enter commit message (blank='$msg_def' or custom or q=quit): "
read msg
if [ "$msg" != "q" ]; then
if [ "$msg" = "" ]; then
msg="$msg_def"
fi
echo
echo ">>> git commit -am '$msg'"
git commit -am "$msg" || exit 1
else
echo
echo "Run this script again to complete."
exit 1
fi
# merge to master
echo
echo "Merging to $master..."
echo ">>> git checkout $master"
git checkout $master || exit 1
echo ">>> git merge $next"
git merge $next || exit 1
# signed tag
echo
echo "Adding signed tag..."
while true; do
echo
echo -n "Enter signing keyid, or 'skip' [$keyid]: "
read usekeyid
if [ "$usekeyid" = "q" ]; then
echo "Aborted." 1>&2
exit 1
elif [ "$usekeyid" = "skip" ]; then
echo "No release tag was added."
break
elif [ -z "$usekeyid" ]; then
usekeyid="$keyid"
fi
keyid="$usekeyid"
echo ">>> git tag -u '$keyid' -s '$newver' -m 'release $newver'"
git tag -u "$keyid" -s "$newver" -m "release $newver"
if [ $? -eq 0 ]; then
break
fi
echo "Retry... (enter q to quit)"
done
# push master
echo
echo "Pushing $master..."
echo
echo ">>> git gc"
git gc || exit 1
echo ">>> git push --tags origin $master"
git push --tags origin $master || exit 1
# push gh-pages
if [ -d ../spacefm-gh-pages ]; then
echo
echo "Commiting and pushing ../spacefm-gh-pages..."
echo
cd ../spacefm-gh-pages || exit 1
echo ">>> git status"
git status
echo
msg_def="release $newver"
echo -n "Enter commit message (blank='$msg_def' or custom or skip=skip): "
read msg
if [ "$msg" != "skip" ]; then
if [ "$msg" = "" ]; then
msg="$msg_def"
fi
echo
echo ">>> git add -A"
git add -A
echo ">>> git commit -am '$msg'"
git commit -am "$msg" || exit 1
echo ">>> git push origin gh-pages"
git push origin gh-pages || exit 1
fi
cd "$curdir" || exit 1
fi
# get next version
echo
echo "Starting next version..."
echo
echo -n "Enter next version [${newver}+next]: "
read nextver
if [ -z "$nextver" ]; then
nextver="${newver}+next"
elif [ "$nextver" = "q" ]; then
echo "Aborted." 1>&2
exit 1
fi
# start next version
echo ">>> git checkout $next"
git checkout $next || exit 1
echo ">>> git merge $master"
git merge $master || exit 1
# set configure version
echo "Changing $configure version $newver to $nextver..."
#AC_INIT([spacefm], [1.0.0+next])
sed -i "s/^AC_INIT(\[$prog\], \[[0-9]\..*\])/AC_INIT(\[$prog\], \[$nextver\])/" $configure
# test configure version changed
testver=`grep -m 1 "^AC_INIT(\[$prog\], \[" "$configure" \
| sed "s/AC_INIT(\[$prog\], \[\(.*\)\])/\1/"`
if [ "$testver" != "$nextver" ]; then
echo "$me_name: change of version in $configure failed" 1>&2
exit 1
fi
# set distros/debian/changelog version
echo "Setting next version in distros/debian/changelog..."
cat << EOF > "distros/debian/changelog"
$prog ($nextver-1) unstable; urgency=low
* release
-- $debian_id $(date -uR)
EOF
if [ $? -ne 0 ]; then
echo "$me_name: error writing distros/debian/changelog" 1>&2
exit 1
fi
# autoreconf
echo
echo "Running autoreconf..."
rm -f configure aclocal.m4 config.log config.status Makefile Makefile.in
#echo ">>> NOCONFIGURE=x ./autogen.sh"
#NOCONFIGURE=x ./autogen.sh
echo ">>> autoreconf"
autoreconf || exit 1
# configure
echo
echo "Running configure..."
echo ">>> env CFLAGS=-O3 ./configure --prefix=/usr"
env CFLAGS=-O3 ./configure --prefix=/usr
err=$?
rm -rf autom4te.cache
if [ $err -ne 0 ]; then
echo "$me_name: configure returned error $err" 1>&2
exit 1
fi
# make clean
echo
echo ">>> make clean"
make clean || exit 1
# commit
echo "Next version is ready to be commited."
msg_def="start $nextver"
echo
echo ">>> git status"
git status
echo "(all unstaged changes will be added)"
echo
echo -n "Enter commit message (blank='$msg_def' or custom or q=quit): "
read msg
if [ "$msg" != "q" ]; then
if [ "$msg" = "" ]; then
msg="$msg_def"
fi
echo
echo ">>> git commit -am '$msg'"
git commit -am "$msg" || exit 1
echo ">>> git push origin $next"
git push origin $next || exit 1
else
echo
echo "SKIPPING $next commit and push" 1>&2
exit 1
fi
echo
echo "$me_name: Done."