1 #@ Include file for the mk-release.sh generic release builder.
2 #@ It also needs two hooks: update_stable_hook(), update_release_hook(),
3 #@ which need to "git add" what they have modified.
5 [ -z "${PROGRAM}" ] && { echo >&2 'Need $PROGRAM'; exit 1; }
6 [ -z "${UPROGRAM}" ] && { echo >&2 'Need $UPROGRAM'; exit 1; }
7 [ -z "${UPLOAD}" ] && { echo >&2 'Need $UPLOAD URL for scp(1)'; exit 1; }
9 [ -z "${ACCOUNT}" ] && { echo >&2 'Need mailx(1) -A $ACCOUNT'; exit 1; }
10 [ -z "${MAILTO}" ] && { echo >&2 'Need $MAILTO for announcement'; exit 1; }
11 [ -z "${MAILBCC}" ] && { echo >&2 'Need $MAILBCC for announcement'; exit 1; }
15 ORIG_LC_ALL=${LC_ALL} LC_ALL=C
18 DATE_MAN=`date -u +'%b %d, %Y'`
19 DATE_ISO=`date -u +%Y-%m-%d`
23 [ ${#} -gt 0 ] && printf '%s ' "${@}"
34 headref="`git rev-parse --verify HEAD`"
36 for i in `git rev-parse --branches=stable master^{commit}`; do
37 if [ ${headref} = ${i} ]; then
42 if [ -z "${brref}" ]; then
43 echo >&2 'Not on the [master] or a [stable/*] branch'
46 if [ "`git status --porcelain --ignored |
47 awk 'BEGIN{no=0}{++no}END{print no}'`" -ne 0 ]; then
48 echo >&2 'Directory not clean, see git status --ignored'
52 echo 'Preparing a release on commit '"${headref}"
53 #brname="`git branch | sed -e '/^* /b X' -e d -e :X -e 's/^* //'`"
54 brname=`git symbolic-ref --short HEAD`
55 echo ' That is '"${brname}"
56 printf ' Name of release tag: '
59 vmaj=`{ echo ${VERSION}; } | sed -e 's/^\([^.]\{1,\}\).*/\1/'`
60 vmin=`{ echo ${VERSION}; } | sed -e 's/^[^.]\{1,\}\.\([^.]\{1,\}\).*/\1/'`
61 [ ${vmin} = ${VERSION} ] && VERSION=${VERSION}.0 vmin=0
62 vupd=`{ echo ${VERSION}; } |
63 sed -e 's/^[^.]\{1,\}\.[^.]\{1,\}\.\([^.-]\{1,\}\).*/\1/'`
64 [ ${vupd} = ${VERSION} ] && VERSION=${VERSION}.0 vupd=0
67 if yesno 'Is '${PROGRAM}' <v'${REL}'> correct?'; then :; else
68 echo >&2 'Bailing out'
72 stblbrname=stable/v${vmaj}.${vmin}
73 brref=`git rev-parse --verify ${stblbrname} 2>/dev/null`
74 if [ -z "${brref}" ]; then
75 if yesno 'Create and switch to new branch '"${stblbrname}"; then
76 git checkout -b ${stblbrname}
78 elif [ ${brref} != ${headref} ] || [ ${brname} != ${stblbrname} ]; then
79 echo >&2 "For ${REL} we should be on ${stblbrname}, not ${brname}"
80 echo >&2 'Bailing out'
84 relbrname=release/v${VERSION}
85 brref=`git rev-parse --verify ${relbrname} 2>/dev/null`
86 if [ -z "${brref}" ]; then :; else
87 echo >&2 "The ${relbrname} already exists"
88 echo >&2 'Bailing out'
93 echo 'Updating stable/ files to match the release'
95 if [ -f version.h ] && [ -f mk-mk.in ]; then
96 grep=grep sed=sed cmp=cmp mv=mv make -f mk-mk.in _update-version
101 LC_ALL=${ORIG_LC_ALL} git commit -S -m "Bump ${UPROGRAM} v${REL}, ${DATE_ISO}"
102 LC_ALL=${ORIG_LC_ALL} git tag -s -f \
103 -m "Bump ${UPROGRAM} v${REL}, ${DATE_ISO}" "v${REL}"
107 if yesno 'Create release/ branch and files?'; then
108 git checkout -b ${relbrname}
110 git rm -f .gitignore .mailmap TODO
113 LC_ALL=${ORIG_LC_ALL} git commit -S \
114 -m "Bump ${UPROGRAM} v${REL}.ar, ${DATE_ISO}"
115 LC_ALL=${ORIG_LC_ALL} git tag -s -f \
116 -m "Bump ${UPROGRAM} v${REL}.ar, ${DATE_ISO}" "v${REL}.ar"
118 if yesno 'Shall i update release/latest "symlink"?'; then
119 git update-ref refs/heads/release/latest ${relbrname}
121 if yesno 'Shall i update release/stable "symlink"?'; then
122 git update-ref refs/heads/release/stable ${relbrname}
125 relbrname=${stblbrname}
131 if [ ${relbrname} != ${stblbrname} ] &&
132 `git rev-parse --verify timeline^{commit} >/dev/null 2>&1` &&
133 yesno 'Shall i update [timeline]?'; then
134 git checkout timeline
136 git archive --format=tar "v${REL}.ar" | tar -x -f -
138 LC_ALL=${ORIG_LC_ALL} git commit -S -m "${UPROGRAM} v${REL}.ar, ${DATE_ISO}"
144 [ ${relbrname} != ${stblbrname} ] && git checkout ${stblbrname}
145 git log --no-walk --decorate --oneline --branches --remotes
146 yesno 'Push git(1) repo?' && git push
151 if [ ${relbrname} != ${stblbrname} ] && yesno 'Create tarballs?'; then
153 # Repack with standard tar(1) to avoid new-style headers
154 git archive --format=tar --prefix="${PROGRAM}-${REL}/" "v${REL}.ar" |
155 ( cd "${TMPDIR}" && tar -x -f - )
157 tar -c -f "${PROGRAM}-${REL}.tar" "${PROGRAM}-${REL}"
159 openssl md5 "${PROGRAM}-${REL}.tar" > "${PROGRAM}-${REL}.cksum"
160 openssl sha1 "${PROGRAM}-${REL}.tar" >> "${PROGRAM}-${REL}.cksum"
161 openssl sha256 "${PROGRAM}-${REL}.tar" >> "${PROGRAM}-${REL}.cksum"
162 openssl sha512 "${PROGRAM}-${REL}.tar" >> "${PROGRAM}-${REL}.cksum"
163 gpg --detach-sign --armor "${PROGRAM}-${REL}.tar"
164 cat "${PROGRAM}-${REL}.tar.asc" >> "${PROGRAM}-${REL}.cksum"
166 < "${PROGRAM}-${REL}.tar" gzip > "${PROGRAM}-${REL}.tar.gz"
167 < "${PROGRAM}-${REL}.tar" xz -e -C sha256 > "${PROGRAM}-${REL}.tar.xz"
169 if yesno 'Upload archives'; then
171 echo "-put ${PROGRAM}-${REL}.tar"
172 echo "-rm ${PROGRAM}-latest.tar"
173 echo "-ln ${PROGRAM}-${REL}.tar ${PROGRAM}-latest.tar"
175 echo "-put ${PROGRAM}-${REL}.tar.gz"
176 echo "-rm ${PROGRAM}-latest.tar.gz"
177 echo "-ln ${PROGRAM}-${REL}.tar.gz ${PROGRAM}-latest.tar.gz"
179 echo "-put ${PROGRAM}-${REL}.tar.xz"
180 echo "-rm ${PROGRAM}-latest.tar.xz"
181 echo "-ln ${PROGRAM}-${REL}.tar.xz ${PROGRAM}-latest.tar.xz"
183 echo "-put ${PROGRAM}-${REL}.tar.asc"
184 echo "-rm ${PROGRAM}-latest.tar.asc"
185 echo "-ln ${PROGRAM}-${REL}.tar.asc ${PROGRAM}-latest.tar.asc"
187 echo "-chmod 0644 ${PROGRAM}-${REL}.tar*"
197 if yesno 'Send announcement mail?'; then
198 if `git rev-parse --verify announce^{blob} >/dev/null 2>&1`; then
199 git show announce > "${TMPDIR}/${PROGRAM}-${REL}.ann.mail"
201 echo > "${TMPDIR}/${PROGRAM}-${REL}.ann.mail"
203 if `git cat-file -e ${relbr}:NEWS 2>/dev/null`; then
204 git show ${relbr}:NEWS >> "${TMPDIR}/${PROGRAM}-${REL}.ann.mail"
207 LC_ALL=${ORIG_LC_ALL} ${MAILX} -A ${ACCOUNT} \
208 -s "[ANN] of ${UPROGRAM} v${REL}" \
209 -q "${TMPDIR}/${PROGRAM}-${REL}.ann.mail" \
210 -b ${MAILBCC} ${MAILTO}
213 # Finally remove the temporary instances than ran this
214 rm -f .git/mk-release.sh .git/mk-release.inc