A git-only SBCL workflow
[sbcl.git] / release.sh
1 #! /bin/sh
2
3 set -e
4
5 usage () {
6     if ! [ -z "$1" ]
7     then
8         echo $1
9     fi
10     cat <<EOF
11
12 usage: $0 [-s] VERSION-NUMBER [REV]
13
14   This script frobs NEWS, makes a "release" commit, builds, runs tests
15   and creates an annotated tag for the release with VERSION-NUMBER.
16
17   If -s is given, then use the gpg-sign mechanism of "git tag". You
18   will need to have your gpg secret key handy.
19
20   if REV is given, it is the git revision to build into a release.
21   Default is origin/master.
22
23   No changes will be pushed upstream. This script will tell you how to
24   do this when it finishes.
25
26 EOF
27     exit 1
28 }
29
30 if [ "-s" = "$1" ] || [ "--sign" = "$1" ]
31 then
32     sign="-s"; shift
33 else
34     sign=""
35 fi
36
37 if [ -z "$1" ]
38 then
39     usage "No version number."
40 else
41     version=$1; shift
42 fi
43
44 if [ -z "$1" ]
45 then
46     rev=origin/master
47 else
48     rev=$1; shift
49     type=$(git cat-file -t "$rev" 2> /dev/null || echo "unknown")
50     if ([ "tag" != "$type" ] && [ "commit" != "$type" ])
51     then
52         usage "$rev is $type, not a tag or a commit."
53     fi
54 fi
55
56 if ! [ -z "$@" ]
57 then
58     usage "Extra command-line arguments: $@"
59 fi
60
61 sbcl_directory="$(cd "$(dirname $0)"; pwd)"
62 tmpfile=$(mktemp -t sbcl-build-$(date +%Y%m%d)-XXXXXXXXX)
63 tmpdir="$(mktemp -d -t sbcl-build-tree-$(date +%Y%m%d)-XXXXXXXXX)"
64
65 ## Check for messy work dirs:
66
67 echo "Fetching updates."
68 git fetch
69
70 branch_name="release-$(date '+%s')"
71 original_branch="$(git describe --all --contains HEAD)"
72 trap "cd \"$sbcl_directory\" ; git checkout $original_branch" EXIT
73 git checkout -b $branch_name $rev
74
75 echo "Checking that the tree is clean."
76 if ! [ $(git status --porcelain | wc -l) = 0 ]
77 then
78     echo "There are uncommitted / unpushed changes in this checkout!"
79     git status
80     exit 1
81 fi
82
83 ## Perform the necessary changes to the NEWS file:
84
85 echo "Munging NEWS"
86 sed -i.orig "/^changes relative to sbcl-.*:/ s/changes/changes in sbcl-$version/ " NEWS
87 rm -f NEWS.orig
88 if ! grep "^changes in sbcl-$version relative to" NEWS > /dev/null
89 then
90     echo "NEWS munging failed!"
91     exit 1
92 fi
93
94 cd "$sbcl_directory"
95
96 echo "Committing release version."
97 git add NEWS
98 git commit -m "$version: will be tagged as \"sbcl-$version\""
99
100 relnotes=$tmpdir/sbcl-$version-release-notes.txt
101 awk "BEGIN { state = 0 }
102  /^changes in sbcl-/ { state = 0 }
103  /^changes in sbcl-$version/ { state = 1 }
104  { if(state == 1) print \$0 }" < NEWS > $relnotes
105
106 tag="sbcl-$version"
107 echo "Tagging as $tag"
108 git tag $sign -F $relnotes "$tag"
109
110 SBCL_BUILDING_RELEASE_FROM=HEAD
111 export SBCL_BUILDING_RELEASE_FROM
112 echo "Building SBCL, log: $tmpfile"
113 ./make.sh >$tmpfile 2>&1
114
115 if [ "SBCL $version" != "$(./src/runtime/sbcl --version)" ]
116 then
117     echo "Built version number doesn't match requested one:" &>2
118     echo &>2
119     echo "    $(./src/runtime/sbcl --version)" &>2
120     exit 1
121 fi
122
123 built_version=$(./src/runtime/sbcl --version | awk '{print $2}')
124
125 echo "Running tests, log: $tmpfile"
126 cd tests
127 sh ./run-tests.sh >>$tmpfile 2>&1
128 cd ..
129
130 cp ./src/runtime/sbcl "$tmpdir"/sbcl-$version-bin
131 cp ./output/sbcl.core "$tmpdir"/sbcl-$version.core
132
133 echo "Self-building, log: $tmpfile"
134 ./make.sh --xc-host="$tmpdir/sbcl-$version-bin --core $tmpdir/sbcl-$version.core --no-userinit --no-sysinit --disable-debugger" >>$tmpfile 2>&1
135
136 echo "Building docs, log: $tmpfile"
137 cd doc && sh ./make-doc.sh >$tmpfile 2>&1
138
139 cd ..
140
141 rm -f "$tmpdir"/sbcl-$version-bin "$tmpdir"/sbcl-$version.core
142
143 cp -a "$sbcl_directory" "$tmpdir"/sbcl-$version
144
145 echo "Building tarballs, log $tmpfile"
146 ln -s "$tmpdir"/sbcl-$version "$tmpdir"/sbcl-$version-x86-linux
147 cd "$tmpdir"/
148 sh sbcl-$version/binary-distribution.sh sbcl-$version-x86-linux >$tmpfile 2>&1
149 sh sbcl-$version/html-distribution.sh sbcl-$version >$tmpfile 2>&1
150 cd sbcl-$version
151 sh ./distclean.sh >$tmpfile 2>&1
152 cd ..
153 sh sbcl-$version/source-distribution.sh sbcl-$version >$tmpfile 2>&1
154
155 echo "The SHA256 checksums of the following distribution files are:" > sbcl-$version-crhodes
156 echo >> sbcl-$version-crhodes
157 sha256sum sbcl-$version*.tar >> sbcl-$version-crhodes
158 bzip2 "$tmpdir"/sbcl-$version*.tar
159
160 echo "Building bugmail."
161 bugmail=sbcl-$version-bugmail.txt
162 echo Bugs fixed by sbcl-$version release > $bugmail
163 for bugnum in $(egrep -o "#[1-9][0-9][0-9][0-9][0-9][0-9]+" $relnotes | sed s/#// | sort -n)
164 do 
165   printf "\n bug %s\n status fixreleased" $bugnum >> $bugmail
166 done
167 echo >> $bugmail
168
169 echo SBCL distribution has been prepared in "$tmpdir"
170 echo TODO:
171 echo
172 echo "Sanity check: git show $tag"
173 echo
174 echo "git merge $branch_name && git push && git push --tags"
175 echo "git branch -d $branch_name"
176 echo "cd \"$tmpdir\""
177 echo gpg -sta sbcl-$version-crhodes
178 echo sftp crhodes,sbcl@frs.sourceforge.net
179 echo \* cd /home/frs/project/s/sb/sbcl/sbcl
180 echo \* mkdir $version
181 echo \* chmod 775 $version
182 echo \* cd $version
183 echo \* put sbcl-$version-crhodes.asc
184 echo \* put sbcl-$version-x86-linux-binary.tar.bz2
185 echo \* put sbcl-$version-source.tar.bz2
186 echo \* put sbcl-$version-documentation-html.tar.bz2
187 echo \* put sbcl-$version-release-notes.txt
188 echo 
189 echo perform administrative tasks:
190 echo 
191 echo \* https://sourceforge.net/project/admin/?group_id=1373
192 echo \* In the File Manager interface, click on the release notes file
193 echo \ \ and tick the release notes box.
194 echo \* In the File Manager interface, click on the source tarball and
195 echo \ \ select as default download for all OSes.
196 echo \* mail sbcl-announce
197 echo \* check and send sbcl-$version-bugmail.txt to edit@bugs.launchpad.net
198 echo \ \ '(sign: C-c RET s p)'
199 echo \* update \#lisp IRC topic
200 echo \* update sbcl website
201