Commit | Line | Data |
---|---|---|
e52cf96b MJ |
1 | #!/bin/bash |
2 | ||
3 | set -eu | |
4 | set -o pipefail | |
5ce74f11 MD |
5 | |
6 | # invoke with do-release 2.N.M, or 2.N.M-rcXX | |
7 | ||
e52cf96b MJ |
8 | # Default maintainer values |
9 | SRCDIR="${HOME}/git/lttng-modules" | |
5ce74f11 | 10 | # The output files are created in ${HOME}/stable/ |
e52cf96b MJ |
11 | OUTPUTDIR="${HOME}/stable" |
12 | SIGN="yes" | |
13 | VERBOSE="" | |
14 | ||
15 | usage() { | |
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 | ||
25 | POS_ARGS=() | |
26 | while [[ $# -gt 0 ]] | |
27 | do | |
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 | |
62 | done | |
63 | set -- "${POS_ARGS[@]}" | |
5ce74f11 | 64 | |
e52cf96b MJ |
65 | REL=${1:-} |
66 | ||
67 | if [ x"${REL}" = x"" ]; then | |
68 | usage | |
5ce74f11 MD |
69 | exit 1; |
70 | fi | |
71 | ||
e52cf96b MJ |
72 | echo "Doing LTTng modules release ${REL}" |
73 | echo " Source dir: ${SRCDIR}" | |
74 | echo " Output dir: ${OUTPUTDIR}" | |
75 | echo " GPG sign: ${SIGN}" | |
5ce74f11 | 76 | |
e52cf96b MJ |
77 | # Make sure the output directory exists |
78 | if [ ! -d "${OUTPUTDIR}" ]; then | |
79 | echo "Output directory '${OUTPUTDIR}' doesn't exist." | |
80 | exit 1 | |
81 | fi | |
5ce74f11 | 82 | |
e52cf96b MJ |
83 | # Make sure the source directory is a git repository |
84 | if [ ! -r "${SRCDIR}/.git/config" ]; then | |
85 | echo "Source directory '${SRCDIR}' isn't a git repository." | |
86 | exit 1 | |
87 | fi | |
5ce74f11 | 88 | |
e52cf96b MJ |
89 | # Set the git repo directory for all further git commands |
90 | export GIT_DIR="${SRCDIR}/.git/" | |
5ce74f11 | 91 | |
e52cf96b MJ |
92 | # Check if the release tag exists |
93 | if ! git rev-parse "refs/tags/v${REL}" >/dev/null 2>&1; then | |
94 | echo "Release tag 'v${REL}' doesn't exist." | |
95 | exit 1 | |
96 | fi | |
97 | ||
98 | # Generate the compressed tar archive, the git attributes from the tag will be used. | |
99 | git archive $VERBOSE --format=tar --prefix="lttng-modules-${REL}/" "v${REL}" | bzip2 > "${OUTPUTDIR}/lttng-modules-${REL}.tar.bz2" | |
5ce74f11 | 100 | |
e52cf96b MJ |
101 | pushd "${OUTPUTDIR}" >/dev/null |
102 | # Generate the hashes | |
103 | md5sum "lttng-modules-${REL}.tar.bz2" > "lttng-modules-${REL}.tar.bz2.md5" | |
104 | sha256sum "lttng-modules-${REL}.tar.bz2" > "lttng-modules-${REL}.tar.bz2.sha256" | |
105 | ||
106 | if [ "x${SIGN}" = "xyes" ]; then | |
107 | # Sign with the default key | |
108 | gpg --armor -b "lttng-modules-${REL}.tar.bz2" | |
109 | fi | |
110 | popd >/dev/null |