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