make: Release pipeline

This commit adds new make targets for rpm, deb, and pacman packages.
It also adds a phony target that uploads tarballs of the packages,
along with their signed (and unsigned) checksums to the github release
page. Once the current commit is tagged as a release, run `make release`
to build the packages and upload them to github.
This commit is contained in:
Jonathan Gold
2018-11-27 09:15:43 -05:00
parent cc02e96a13
commit 80931e1cb4
7 changed files with 243 additions and 90 deletions

65
misc/fpm-pack.sh Executable file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
# This script packages rpm, deb, and pacman packages of mgmt with fpm. The
# first argument is the package type, and all subsequent arguments are the
# dependencies. Example usage: `./fpm-pack.sh deb dependency1 dependency2`
# the binary to package
BINARY="mgmt"
# git tag pointing to the current commit
TAG=$(git tag -l --points-at HEAD)
# maintainer email
MAINTAINER="mgmt@noreply.github.com"
# project url
URL="https://github.com/purpleidea/mgmt/"
# project description
DESCRIPTION="Next generation distributed, event-driven, parallel config management!"
# project license
LICENSE="GPLv3"
# location to install the binary
PREFIX="/usr/bin"
# release directory
DIR="releases"
# placeholder for dependencies to be read from arguments
DEPS=
# placeholder for changelog argument parsed from the package type
CHANGELOG=
# make sure we're on a tagged commit
if [ "$TAG" == "" ]; then
echo "cannot release an untagged commit"
exit 1
fi
# make sure the package type is valid
if [ "$1" != "deb" ] && [ "$1" != "rpm" ] && [ "$1" != "pacman" ]; then
echo "invalid package type"
exit 1
fi
# there are no changelogs for pacman packages
if [ "$1" != "pacman" ]; then
CHANGELOG="--${1}-changelog=${DIR}/${1}/changelog"
fi
# arguments after the first one are deps
for i in "${@:2}"; do
DEPS="$DEPS -d $i"
done
# build the package
fpm \
--log error \
--name "$BINARY" \
--version "$TAG" \
--maintainer "$MAINTAINER" \
--url "$URL" \
--description "$DESCRIPTION" \
--license "$LICENSE" \
--input-type dir \
--output-type "$1" \
--package "${DIR}/${1}/" \
${CHANGELOG} \
${DEPS} \
--prefix "$PREFIX" \
"$BINARY"