1#!/bin/bash
2# SPDX-License-Identifier: MIT
3# Copyright 2020 Google LLC
4#
5# Use of this source code is governed by an MIT-style
6# license that can be found in the LICENSE file or at
7# https://opensource.org/licenses/MIT.
8
9set -e -u -o pipefail
10cd "$(dirname "$0")/.."
11
12if [ $# != 1 ]; then
13	echo "Usage: $0 VERS" 1>&2
14	echo "  e.g. $0 1.0" 1>&2
15	exit 2
16fi
17
18VERS=$1
19PKG=fsverity-utils-$VERS
20
21git checkout -f
22git clean -fdx
23./scripts/run-tests.sh
24git clean -fdx
25
26major=$(echo "$VERS" | cut -d. -f1)
27minor=$(echo "$VERS" | cut -d. -f2)
28sed -E -i -e "/FSVERITY_UTILS_MAJOR_VERSION/s/[0-9]+/$major/" \
29	  -e "/FSVERITY_UTILS_MINOR_VERSION/s/[0-9]+/$minor/" \
30	  include/libfsverity.h
31sed -E -i "/Version:/s/[0-9]+\.[0-9]+/$VERS/" \
32	  lib/libfsverity.pc.in
33git commit -a --signoff --message="v$VERS"
34git tag --sign "v$VERS" --message="$PKG"
35
36git archive "v$VERS" --prefix="$PKG/" > "$PKG.tar"
37tar xf "$PKG.tar"
38( cd "$PKG" && make check )
39rm -r "$PKG"
40
41gpg --detach-sign --armor "$PKG.tar"
42DESTDIR=/pub/linux/kernel/people/ebiggers/fsverity-utils/v$VERS
43kup mkdir "$DESTDIR"
44kup put "$PKG.tar" "$PKG.tar.asc" "$DESTDIR/$PKG.tar.gz"
45git push
46git push --tags
47