lw-build-system/scripts/release.sh

99 lines
2.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# lw-build-system/scripts/release.sh
#
# Copyright: ©20062010, Laurence Withers
# Author: Laurence Withers <l@lwithers.me.uk>
# License: GPLv3
#
# Prepares package for release. Expects the version number on the
# command line.
# Get the directory of the repository (needed to include functions file)
cd "$(dirname $0)"
REPOS=$(dirname "$(pwd)")
[ -z "${VERBOSE}" ] && VERBOSE=0
source "${REPOS}/scripts/functions.sh" || exit 1
# Get version etc.
if [ $# -ne 2 ]
then
echo "Usage: $0 <version> <output_dir>"
exit 1
fi
VER=$1
DIR=$2
PKGNAME="$(basename ${REPOS})-${VER}"
# move to output directory and clone git repository
echo "Cloning repository..."
do_cmd cd "${DIR}" || exit 1
do_cmd rm -rf "${PKGNAME}" "${PKGNAME}-doc" || exit 1
do_cmd git clone --local --shared -n "${REPOS}" "${PKGNAME}" || exit 1
do_cmd cd "${PKGNAME}" || exit 1
print_success "Done"
# Check out a new copy of the library from git
echo "Checking out tag ${VER}..."
do_cmd git checkout -b releaseprivate "${VER}" || exit 1
print_success "Done"
# Check that the default build operation runs
#do_cmd ./make.sh || exit 1
rm -f docs/*.pdf
# build and save the documentation, if required
BUILD_DOCS=""
test_params_for_doxygen() {
[ "$2" == "doxygen" ] && BUILD_DOCS="1"
}
for params in src/*/.params
do
test_params_for_doxygen $(cat ${params})
done
if [ ! -z ${BUILD_DOCS} ]
then
do_cmd ./make.sh docs || exit 1
do_cmd mv html "../${PKGNAME}-doc" || exit 1
fi
# Clean up
do_cmd ./make.sh clean || exit 1
do_cmd rm -rf .git || exit 1
# Build archive, md5sum and signature
cd ..
tar c "${PKGNAME}" | bzip2 > "${PKGNAME}.tar.bz2"
sha1sum "${PKGNAME}.tar.bz2" > "${PKGNAME}.sha1"
gpg -a -b "${PKGNAME}.tar.bz2"
if [ ! -z ${BUILD_DOCS} ]
then
tar c "${PKGNAME}-doc" | bzip2 > "${PKGNAME}-doc.tar.bz2"
sha1sum "${PKGNAME}-doc.tar.bz2" > "${PKGNAME}-doc.sha1"
gpg -a -b "${PKGNAME}-doc.tar.bz2"
fi
# clean up
rm -rf "${PKGNAME}" "${PKGNAME}-doc"
# vim: syntax=sh:ts=4:sw=4:expandtab