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 12usage() 13{ 14 echo "Usage: $0 prepare|publish VERS" 1>&2 15 echo " e.g. $0 prepare 1.0" 1>&2 16 echo " $0 publish 1.0" 1>&2 17 exit 2 18} 19 20if [ $# != 2 ]; then 21 usage 22fi 23 24PUBLISH=false 25case $1 in 26publish) 27 PUBLISH=true 28 ;; 29prepare) 30 ;; 31*) 32 usage 33 ;; 34esac 35VERS=$2 36PKG=fsverity-utils-$VERS 37 38prepare_release() 39{ 40 git checkout -f 41 git clean -fdx 42 ./scripts/run-tests.sh 43 git clean -fdx 44 45 major=$(echo "$VERS" | cut -d. -f1) 46 minor=$(echo "$VERS" | cut -d. -f2) 47 month=$(LC_ALL=C date +%B) 48 year=$(LC_ALL=C date +%Y) 49 50 sed -E -i -e "/FSVERITY_UTILS_MAJOR_VERSION/s/[0-9]+/$major/" \ 51 -e "/FSVERITY_UTILS_MINOR_VERSION/s/[0-9]+/$minor/" \ 52 include/libfsverity.h 53 sed -E -i "/Version:/s/[0-9]+\.[0-9]+/$VERS/" \ 54 lib/libfsverity.pc.in 55 sed -E -i -e "/^\.TH /s/fsverity-utils v[0-9]+(\.[0-9]+)+/fsverity-utils v$VERS/" \ 56 -e "/^\.TH /s/[a-zA-Z]+ 2[0-9]{3}/$month $year/" \ 57 man/*.[1-9] 58 git commit -a --signoff --message="v$VERS" 59 git tag --sign "v$VERS" --message="$PKG" 60 61 git archive "v$VERS" --prefix="$PKG/" > "$PKG.tar" 62 tar xf "$PKG.tar" 63 ( cd "$PKG" && make check ) 64 rm -r "$PKG" 65} 66 67publish_release() 68{ 69 gpg --detach-sign --armor "$PKG.tar" 70 DESTDIR=/pub/linux/kernel/people/ebiggers/fsverity-utils/v$VERS 71 kup mkdir "$DESTDIR" 72 kup put "$PKG.tar" "$PKG.tar.asc" "$DESTDIR/$PKG.tar.gz" 73 git push 74 git push --tags 75} 76 77if $PUBLISH; then 78 publish_release 79else 80 prepare_release 81fi 82