1da0c48c4Sopenharmony_ci#!/usr/bin/env bash
2da0c48c4Sopenharmony_ci
3da0c48c4Sopenharmony_ci# Must be run in the source directory.
4da0c48c4Sopenharmony_ci# Should have passed make distcheck.
5da0c48c4Sopenharmony_ci# And all final changes should already have been pushed.
6da0c48c4Sopenharmony_ci# Backup copy will be created in $HOME/elfutils-$VERSION
7da0c48c4Sopenharmony_ci
8da0c48c4Sopenharmony_ci# Any error is fatal
9da0c48c4Sopenharmony_ciset -e
10da0c48c4Sopenharmony_ci
11da0c48c4Sopenharmony_ci# We take one arguent, the version (e.g. 0.173)
12da0c48c4Sopenharmony_ciif [ $# -ne 1 ]; then
13da0c48c4Sopenharmony_ci  echo "$0 <version> (e.g. 0.169)"
14da0c48c4Sopenharmony_ci  exit 1
15da0c48c4Sopenharmony_cifi
16da0c48c4Sopenharmony_ci
17da0c48c4Sopenharmony_ciVERSION="$1"
18da0c48c4Sopenharmony_ci
19da0c48c4Sopenharmony_ciecho Make sure the git repo is tagged, signed and pushed
20da0c48c4Sopenharmony_ciecho git tag -s -m \"elfutils $VERSION release\" elfutils-$VERSION
21da0c48c4Sopenharmony_ciecho git push --tags
22da0c48c4Sopenharmony_ci
23da0c48c4Sopenharmony_ci# Create a temporary directory and make sure it is cleaned up.
24da0c48c4Sopenharmony_citempdir=$(mktemp -d) || exit
25da0c48c4Sopenharmony_citrap "rm -rf -- ${tempdir}" EXIT
26da0c48c4Sopenharmony_ci
27da0c48c4Sopenharmony_cipushd "${tempdir}"
28da0c48c4Sopenharmony_ci
29da0c48c4Sopenharmony_ci# Checkout
30da0c48c4Sopenharmony_cigit clone git://sourceware.org/git/elfutils.git
31da0c48c4Sopenharmony_cicd elfutils
32da0c48c4Sopenharmony_cigit tag --verify "elfutils-${VERSION}"
33da0c48c4Sopenharmony_cigit checkout -b "$VERSION" "elfutils-${VERSION}"
34da0c48c4Sopenharmony_ci
35da0c48c4Sopenharmony_ci# Create dist
36da0c48c4Sopenharmony_ciautoreconf -v -f -i
37da0c48c4Sopenharmony_ci./configure --enable-maintainer-mode
38da0c48c4Sopenharmony_cimake -j$(nproc) && make dist
39da0c48c4Sopenharmony_ci
40da0c48c4Sopenharmony_ci# Sign
41da0c48c4Sopenharmony_cimkdir $VERSION
42da0c48c4Sopenharmony_cicp elfutils-$VERSION.tar.bz2 $VERSION/
43da0c48c4Sopenharmony_cicd $VERSION/
44da0c48c4Sopenharmony_cigpg -b elfutils-$VERSION.tar.bz2
45da0c48c4Sopenharmony_cicd ..
46da0c48c4Sopenharmony_ci
47da0c48c4Sopenharmony_ci# Backup copy
48da0c48c4Sopenharmony_cicp -r $VERSION $HOME/elfutils-$VERSION
49da0c48c4Sopenharmony_ci
50da0c48c4Sopenharmony_ci# Upload
51da0c48c4Sopenharmony_ciscp -r $VERSION sourceware.org:/sourceware/ftp/pub/elfutils/
52da0c48c4Sopenharmony_cissh sourceware.org "(cd /sourceware/ftp/pub/elfutils \
53da0c48c4Sopenharmony_ci  && chmod go+rx $VERSION \
54da0c48c4Sopenharmony_ci  && chmod go+r  $VERSION/elfutils-$VERSION.tar.bz2* \
55da0c48c4Sopenharmony_ci  && ln -sf $VERSION/elfutils-$VERSION.tar.bz2 elfutils-latest.tar.bz2 \
56da0c48c4Sopenharmony_ci  && ln -sf $VERSION/elfutils-$VERSION.tar.bz2.sig elfutils-latest.tar.bz2.sig \
57da0c48c4Sopenharmony_ci  && ls -lah elfutils-latest*)"
58da0c48c4Sopenharmony_ci
59da0c48c4Sopenharmony_ci# Cleanup
60da0c48c4Sopenharmony_cipopd
61da0c48c4Sopenharmony_citrap - EXIT
62da0c48c4Sopenharmony_ciexit
63