From 860d89aade4ae90fd59e60769f7294cf2d8fac20 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Mon, 5 Aug 2013 10:24:20 +0300 Subject: [PATCH] make_a_release.sh: a script for cutting releases Not complete, but a good start anyway. Intended to be used by me. Change-Id: I64b7ef72ac8fe729f234f5d74847dc85225ccee0 Signed-off-by: Artem Bityutskiy --- make_a_release.sh | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 make_a_release.sh diff --git a/make_a_release.sh b/make_a_release.sh new file mode 100755 index 0000000..393d19d --- /dev/null +++ b/make_a_release.sh @@ -0,0 +1,117 @@ +#!/bin/sh -euf +# +# Copyright (c) 2012-2013 Intel, Inc. +# License: GPLv2 +# Author: Artem Bityutskiy +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License, version 2, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. + +# This script automates the process of releasing the bmap-tools project. The +# idea is that it should be enough to run this script with few parameters and +# the release is ready. + +# +# This script is supposed to be executed in the root of the bmap-tools +# project's source code tree. +# +# TODO: +# * support -rc releases; +# * update the version field in all places, the rpm/deb changelog and commit +# that. + +fatal() { + printf "Error: %s\n" "$1" >&2 + exit 1 +} + +usage() { + cat < + + - new bmap-tools version to make in X.Y format +EOF + exit 0 +} + +[ $# -eq 0 ] && usage +[ $# -eq 1 ] || fatal "insufficient or too many argumetns" + +new_ver="$1"; shift + +# Validate the new version +printf "%s" "$new_ver" | egrep -q -x '[[:digit:]]+\.[[:digit:]]+' || + fatal "please, provide new version in X.Y format" + +# Get the name of the release branch corresponding to this version +release_branch="release-$(printf "%s" "$new_ver" | sed -e 's/\(.*\)\..*/\1.0/')" + +# Make sure that a release branch branch is currently checked out +current_branch="$(git branch | sed -n -e '/^*/ s/^* //p')" +if [ "$current_branch" != "$release_branch" ]; then + fatal "current branch is '$current_branch' but must be '$release_branch'" +fi + +# Make sure the git index is up-to-date +[ -z "$(git status --porcelain)" ] || fatal "git index is not up-to-date" + +outdir="." +tag_name="v$new_ver" +release_name="bmap-tools-$new_ver" + +# Create new signed tag +echo "Signing tag $tag_name" +git tag -m "$release_name" -s "$tag_name" + +# Prepare a signed tarball +git archive --format=tar --prefix="$release_name/" "$tag_name" | \ + gzip > "$outdir/$release_name.tgz" +echo "Signing the tarball" +gpg -o "$outdir/$release_name.tgz.asc" --detach-sign -a "$outdir/$release_name.tgz" + +# Get the name of the release branch corresponding to this version +release_branch="release-$(printf "%s" "$new_ver" | sed -e 's/\(.*\)\..*/\1.0/')" + +cat < +To: bmap-tools@lists.infradead.org +Subject: Announcement: $release_name is out! + +Bmap-tools version $new_ver is out! + +Release notes: http://git.infradead.org/users/dedekind/bmap-tools.git/blob/refs/heads/$release_branch:/docs/RELEASE_NOTES +Tarball: ftp://ftp.infradead.org/pub/bmap-tools/ +END_OF_EMAIL +EOF