Improve the release script
[lttng-modules.git] / scripts / maintainer / do-release.sh
CommitLineData
5cfbaa8b
MJ
1#!/bin/bash
2
3set -eu
4set -o pipefail
df79c0a0
MD
5
6# invoke with do-release 2.N.M, or 2.N.M-rcXX
7
5cfbaa8b
MJ
8# Default maintainer values
9SRCDIR="${HOME}/git/lttng-modules"
df79c0a0 10# The output files are created in ${HOME}/stable/
5cfbaa8b
MJ
11OUTPUTDIR="${HOME}/stable"
12SIGN="yes"
13VERBOSE=""
14
15usage() {
16 echo "Usage: do-release.sh [OPTION]... RELEASE"
17 echo
18 echo "Mandatory arguments to long options are mandatory for short options too."
19 echo " -s, --srcdir DIR source directory"
20 echo " -o, --outputdir DIR output directory, must exist"
21 echo " -n, --no-sign don't GPG sign the output archive"
22 echo " -v, --verbose verbose command output"
23}
24
25POS_ARGS=()
26while [[ $# -gt 0 ]]
27do
28 arg="$1"
29
30 case $arg in
31 -n|--no-sign)
32 SIGN="no"
33 shift 1
34 ;;
35
36 -s|--srcdir)
37 SRCDIR="$2"
38 shift 2
39 ;;
40
41 -o|--outputdir)
42 OUTPUTDIR="$2"
43 shift 2
44 ;;
45
46 -v|--verbose)
47 VERBOSE="-v"
48 shift 1
49 ;;
50
51 # Catch unknown arguments
52 -*)
53 usage
54 exit 1
55 ;;
56
57 *)
58 POS_ARGS+=("$1")
59 shift
60 ;;
61 esac
62done
63set -- "${POS_ARGS[@]}"
df79c0a0 64
5cfbaa8b
MJ
65REL=${1:-}
66
67if [ x"${REL}" = x"" ]; then
68 usage
df79c0a0
MD
69 exit 1;
70fi
71
5cfbaa8b
MJ
72echo "Doing LTTng modules release ${REL}"
73echo " Source dir: ${SRCDIR}"
74echo " Output dir: ${OUTPUTDIR}"
75echo " GPG sign: ${SIGN}"
df79c0a0 76
5cfbaa8b
MJ
77# Make sure the output directory exists
78if [ ! -d "${OUTPUTDIR}" ]; then
79 echo "Output directory '${OUTPUTDIR}' doesn't exist."
80 exit 1
81fi
df79c0a0 82
5cfbaa8b
MJ
83# Make sure the source directory is a git repository
84if [ ! -r "${SRCDIR}/.git/config" ]; then
85 echo "Source directory '${SRCDIR}' isn't a git repository."
86 exit 1
87fi
df79c0a0 88
5cfbaa8b
MJ
89# Set the git repo directory for all further git commands
90export GIT_DIR="${SRCDIR}/.git/"
df79c0a0 91
5cfbaa8b
MJ
92# Check if the release tag exists
93if ! git rev-parse "refs/tags/v${REL}" >/dev/null 2>&1; then
94 echo "Release tag 'v${REL}' doesn't exist."
95 exit 1
96fi
97
98# Generate the compressed tar archive, the git attributes from the tag will be used.
99git archive $VERBOSE --format=tar --prefix="lttng-modules-${REL}/" "v${REL}" | bzip2 > "${OUTPUTDIR}/lttng-modules-${REL}.tar.bz2"
df79c0a0 100
5cfbaa8b
MJ
101pushd "${OUTPUTDIR}" >/dev/null
102# Generate the hashes
103md5sum "lttng-modules-${REL}.tar.bz2" > "lttng-modules-${REL}.tar.bz2.md5"
104sha256sum "lttng-modules-${REL}.tar.bz2" > "lttng-modules-${REL}.tar.bz2.sha256"
105
106if [ "x${SIGN}" = "xyes" ]; then
107 # Sign with the default key
108 gpg --armor -b "lttng-modules-${REL}.tar.bz2"
109fi
110popd >/dev/null
This page took 0.027708 seconds and 4 git commands to generate.