#!/bin/sh ORIGIN_URL=$(git config --get remote.origin.url) CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) PACKAGE='@PACKAGE@' PACKAGE_VERSION='@PACKAGE_VERSION@' abs_srcdir='@abs_srcdir@' srcdir='@srcdir@' abs_top_builddir='@abs_top_builddir@' dist_man_MANS='lsrc.1 mkrc.1 rcdn.1 rcup.1 rcrc.5 rcm.7' edit_package() { sed \ -e "s|@PACKAGE[@]|$PACKAGE|g" \ -e "s|@PACKAGE_VERSION[@]|$PACKAGE_VERSION|g" \ -e "s|@DIST_ARCHIVES[@]|$DIST_ARCHIVES|g" \ -e "s|@DIST_SHA[@]|$DIST_SHA|g" \ "$1" } # Tarball release_build_tarball() { ([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \ ([ -d gh-pages/dist ] || mkdir gh-pages/dist) && \ cp $DIST_ARCHIVES gh-pages/dist && \ cd gh-pages && \ git add dist/$DIST_ARCHIVES && \ git commit -m "Release version $PACKAGE_VERSION tarball" } release_push_tarball() { cd gh-pages && \ git push } release_clean_tarball() { rm -rf gh-pages rm -rf $DIST_ARCHIVES } # Homebrew release_build_homebrew() { ([ -d homebrew-formulae ] || git clone git@github.com:thoughtbot/homebrew-formulae.git homebrew-formulae) && \ generate_dist_sha && \ edit_package homebrew/$PACKAGE.rb.in > homebrew-formulae/Formula/$PACKAGE.rb && \ cd homebrew-formulae && \ git add Formula/$PACKAGE.rb && \ git commit -m "$PACKAGE: Release version $PACKAGE_VERSION" } release_push_homebrew() { cd homebrew-formulae && \ git push } release_clean_homebrew() { rm -rf homebrew-formulae rm -rf $DIST_ARCHIVES } # Arch release_build_arch() { ([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \ ([ -d gh-pages/arch ] || mkdir gh-pages/arch) && \ generate_dist_sha && \ edit_package arch/PKGBUILD.in > gh-pages/arch/PKGBUILD &&\ cd gh-pages &&\ git add arch/PKGBUILD &&\ git commit -m "Release version $PACKAGE_VERSION Arch package" } release_push_arch() { cd gh-pages && \ git push } release_clean_arch() { rm -rf gh-pages rm -rf $DIST_ARCHIVES } # Deb release_build_deb() { mkdir deb-build && \ cp ${DIST_ARCHIVES} deb-build/${PACKAGE}_${PACKAGE_VERSION}.orig.tar.gz && \ tar -C deb-build -xf deb-build/${PACKAGE}_${PACKAGE_VERSION}.orig.tar.gz && \ cp -R debian deb-build/${PACKAGE}-${PACKAGE_VERSION} && \ cd deb-build/${PACKAGE}-${PACKAGE_VERSION} && \ dch -d "New upstream release" && dch -r "" && \ debuild --prepend-path=/usr/local/bin -F && \ cd ${abs_top_builddir} && \ ([ -d gh-pages ] || git clone --branch gh-pages ${ORIGIN_URL} gh-pages) && \ mkdir gh-pages/debs && \ mkdir gh-pages/deb-src && \ cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.deb gh-pages/debs && \ cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.dsc gh-pages/deb-src && \ cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.orig.tar.?z gh-pages/deb-src && \ cp deb-build/${PACKAGE}_${PACKAGE_VERSION}*.debian.tar.?z gh-pages/deb-src && \ cd gh-pages && \ git add debs/${PACKAGE}_${PACKAGE_VERSION}*deb && \ git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*dsc && \ git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*orig.tar.?z && \ git add deb-src/${PACKAGE}_${PACKAGE_VERSION}*debian.tar.?z && \ git commit -m "Release version ${PACKAGE_VERSION} for Debian" -- debs/${PACKAGE}_${PACKAGE_VERSION}*deb } release_push_deb() { cd gh-pages && \ git push } release_clean_deb() { rm -rf gh-pages rm -rf deb-build rm -rf $DIST_ARCHIVES } # Tag release_build_tag() { git tag -s v$PACKAGE_VERSION -m "Release $PACKAGE_VERSION" } release_push_tag() { git push origin --tags } release_clean_tag() { : } generate_dist_sha() { export DIST_SHA=$(openssl sha256 $srcdir/$DIST_ARCHIVES | cut -d' ' -f2) } # manpages as HTML release_build_man_html() { ([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \ for i in $dist_man_MANS; do \ mandoc -Thtml -Oman=%N.%S.html man/$i > $abs_top_builddir/gh-pages/$i.html ; \ done && \ cd $abs_top_builddir/gh-pages && \ cp rcm.7.html index.html && \ git add -A && \ git commit -m "HTML documentation for $PACKAGE_VERSION" } release_push_man_html() { cd $abs_top_builddir/gh-pages && \ git push -f $ORIGIN_URL gh-pages } release_clean_man_html() { rm -rf $abs_top_builddir/gh-pages } # Main: if [ $# -lt 3 ]; then echo "Usage: release (build|push|clean) (tarball|homebrew|arch|deb|tag|man_html) DIST_ARCHIVES" >&2 exit 64 fi verb="$1" noun="$2" DIST_ARCHIVES="$3" cmd="release_${verb}_${noun}" ${cmd}