Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to cut Asciidoctor EPUB3 release
#!/usr/bin/bash
# GEM_VERSION=1.5.0.alpha.10 NEXT_GEM_VERSION=1.5.0.alpha.11.dev ./cut-release.sh -p
PUSH=false
while getopts "p" option; do
case $option in
p) PUSH=true ;;
esac
done
if [ -z "$GEM_VERSION" ]; then
GEM_VERSION=$(bundle exec ruby -e "print (Gem::Version.new Asciidoctor::Epub3::VERSION).release")
fi
# TODO make sure copyright year is correct in README.adoc and LICENSE.adoc
sed -i "/VERSION/s/'[^']\+'/'$GEM_VERSION'/" lib/*/version.rb
sed -i "3i v$GEM_VERSION, $(date +%Y-%m-%d)" README.adoc
#sed -i "s/^:release-version:.*/:release-version: $GEM_VERSION/" README*.adoc
sed -i "s/^== Unreleased/== $GEM_VERSION ($(date +%Y-%m-%d)) - @mojavelinux/" CHANGELOG.adoc
git commit -a -m "Release $GEM_VERSION"
git tag -m "Version $GEM_VERSION" v$GEM_VERSION
if [ $PUSH == true ]; then
git push origin $(git describe --tags --exact-match)
fi
if [ -z "$NEXT_GEM_VERSION" ]; then
NEXT_GEM_VERSION=$(bundle exec ruby -e "print (Gem::Version.new Asciidoctor::Epub3::VERSION).segments.tap {|s| s.pop if s.size == 4; s[-1] += 1 }.join('.') + '.dev'")
fi
sed -i "/VERSION/s/'[^']\+'/'$NEXT_GEM_VERSION'/" lib/*/version.rb
sed -i 3d README.adoc
read -p 'Press <Enter> once release finishes...'
git commit -m "Begin development on next version [skip ci]" .
if [ $PUSH == true ]; then
git push origin $(git rev-parse --abbrev-ref HEAD)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment