-
Notifications
You must be signed in to change notification settings - Fork 9
/
release.sh
executable file
·80 lines (61 loc) · 1.9 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
#!/bin/sh
# Make sure local tags are up to date with github repo
git fetch -t "https://github.com/zotero/scaffold.git"
lastTag="`git describe --tags --abbrev=0 --match=v[0-9]*`"
version="$1"
if [ -z "$version" ]; then
echo "Last version: $lastTag" 1>&2
read -p " New version: v" version
fi
srcPath="src"
##############
## Write changes since last release to change log
##############
changeLog="Changelog"
tempFile="`mktemp`"
tempFile2="`mktemp`"
git log --reverse --no-merges --format="* %s" "$lastTag".. "$srcPath" >> "$tempFile"
${VISUAL:-${EDITOR:-vi}} "$tempFile"
echo "Version $version" > "$tempFile2"
cat "$tempFile" >> "$tempFile2"
echo "" >> "$tempFile2"
cat "$changeLog" >> "$tempFile2"
rm "$tempFile"
mv "$tempFile2" "$changeLog"
git add "$changeLog"
##############
## Update install.rdf
##############
installRDF="$srcPath/install.rdf"
perl -pi -e "s/<em:version>[^<]*/<em:version>$version/;" $installRDF
rm "$installRDF.bak"
git add "$installRDF"
##############
## Build XPI file
##############
./build.sh "$version"
# Cygwin has sha1sum, macOS has shasum, Linux has both
if [[ -n "`which sha1sum 2> /dev/null`" ]]; then
SHACMD="sha1sum"
else
SHACMD="shasum"
fi
SHA1=`$SHACMD build/scaffold-$version.xpi | cut -d' ' -f1`
##############
## Update docs/ for Github Pages
##############
perl -pi -e "s/<em:version>[^<]*/<em:version>$version/;" \
-e "s/<em:updateLink>[^<]*/<em:updateLink>https:\/\/github.com\/zotero\/scaffold\/releases\/download\/v$version\/scaffold-$version.xpi/;" \
-e "s/sha1:[\dabcdef]*/sha1:$SHA1/g;" \
-e "s/<em:updateInfoURL>[^<]*/<em:updateInfoURL>https:\/\/github.com\/zotero\/scaffold\/releases\/tag\/v$version/;" \
docs/scaffold.rdf
git add "docs/scaffold.rdf"
rm "docs/scaffold.rdf.bak"
##############
## Commit everything
##############
git commit -m "Release $version" 1>&2
##############
## Create tag
##############
git tag "v$version"