make: Improve release pipeline

Hopefully this makes releases a little better for users.
In particular, this avoids listing old build artifacts in the SHA256SUMS
files when we make new releases, and users can now download them
directly.

Now to make a release you run: `make tag && make release`.
After the first make session ends, you'll have a new tag released
publicly, and then during the second make session, the release target
will notice this new tag, build some assets, and upload them!
This commit is contained in:
James Shubin
2018-11-30 18:49:52 -05:00
parent 80931e1cb4
commit 0ec00fe57f
5 changed files with 69 additions and 72 deletions

View File

@@ -8,7 +8,7 @@ BINARY="mgmt"
# git tag pointing to the current commit
TAG=$(git tag -l --points-at HEAD)
# maintainer email
MAINTAINER="mgmt@noreply.github.com"
MAINTAINER="mgmtconfig@purpleidea.com"
# project url
URL="https://github.com/purpleidea/mgmt/"
# project description
@@ -31,6 +31,17 @@ if [ "$TAG" == "" ]; then
exit 1
fi
if [ "$2" == "" ]; then
echo "version was not specified"
exit 1
fi
VERSION="$2"
if [ "$VERSION" != "$TAG" ]; then
echo "you must checkout the correct version before building (${VERSION} != ${TAG})"
exit 1
fi
# make sure the package type is valid
if [ "$1" != "deb" ] && [ "$1" != "rpm" ] && [ "$1" != "pacman" ]; then
echo "invalid package type"
@@ -39,11 +50,11 @@ fi
# there are no changelogs for pacman packages
if [ "$1" != "pacman" ]; then
CHANGELOG="--${1}-changelog=${DIR}/${1}/changelog"
CHANGELOG="--${1}-changelog=${DIR}/${VERSION}/${1}/changelog"
fi
# arguments after the first one are deps
for i in "${@:2}"; do
# arguments after the first two are deps
for i in "${@:3}"; do
DEPS="$DEPS -d $i"
done
@@ -58,7 +69,7 @@ fpm \
--license "$LICENSE" \
--input-type dir \
--output-type "$1" \
--package "${DIR}/${1}/" \
--package "${DIR}/${VERSION}/${1}/" \
${CHANGELOG} \
${DEPS} \
--prefix "$PREFIX" \

View File

@@ -1,8 +1,10 @@
#!/bin/bash
# This script generates a deb changelog from the project's git history.
# version we're releasing
VERSION="$1"
# path to store the changelog
CHANGELOG="releases/deb/changelog"
CHANGELOG="releases/${VERSION}/deb/changelog"
# input to format flag for git tag
TAG_FORMAT="-- %(creator) %(creatordate:format:%a, %d %b %Y %H:%M:%S %z) %(refname:lstrip=2)"
# a list of tags to be parsed in the loop

View File

@@ -1,8 +1,10 @@
#!/bin/bash
# This script generates an rpm changelog from the project's git history.
# version we're releasing
VERSION="$1"
# path to store the changelog
CHANGELOG="releases/rpm/changelog"
CHANGELOG="releases/${VERSION}/rpm/changelog"
# input to format flag for git tag
TAG_FORMAT="* %(creatordate:format:%a %b %d %Y) %(creator) %(refname:lstrip=2)"
# a list of tags to be parsed in the loop

50
misc/tag.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash
set -eEu
set -o pipefail
################################################################################
# Tag and push a new release of the git repo.
# There are no arguments for this script.
################################################################################
# Variables:
#
# v: the old tag version, such as 0.0.13
# t: the new tag version, such as 0.0.14
# h: the head version, such as 0.0.13-40-g62ca126-dirty
v=`git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --abbrev=0`
t=`echo "${v%.*}.$((${v##*.}+1))"` # increment version
h="$(git describe --tags --dirty --always)"
if [[ $# -gt 0 ]]; then
echo "ERR: $0 does not take arguments." >&2
exit 1
fi
# Never tag a dirty git tree.
if [[ "${h}" =~ dirty ]]; then
echo "ERR: git tree is dirty. Commit or stash changes before tagging." >&2
exit 1
fi
# Be idempotent.
if [[ "${h}" == "${v}" ]]; then
echo "INFO: HEAD \"${h}\" is equivalent to the current (old) version tag \"${v}\"; nothing to do."
exit 0
fi
# Give the user a chance to abort.
echo "WARN: About to tag \"${h}\" as \"${t}\" and push."
echo "Press ^C within 3s to abort."
sleep 3s
# Tag and push.
echo "release: tag $t" | git tag --file=- --sign $t
echo "INFO: Version $t is now tagged."
echo "INFO: Pushing $t to origin."
git push origin $t
# Be informative.
GIT_PAGER=cat git diff --stat "$v" "$t"
if command -v contrib.sh &>/dev/null; then contrib.sh "$v"; fi
echo -e "run 'git log $v..$t' to see what has changed since $v"