#!/usr/bin/env bash # Usage: script/release # Build the package, tag a commit, push it to origin, and then release the # package to our private gem repository. # Let's source required ENV variables source .rbenv-vars set -e # Get latest tag # http://git-scm.com/docs/git-fetch # `-t`: Fetch all tags from the remote echo "Fetching origin with all remote tags..." git fetch -t origin latest_tag=$(git describe --always origin/master --abbrev=0 --match="v*") latest_release=${latest_tag:1} echo "Did you update the VERSION in lib/shipit-cli/version.rb ?" read -p "It should be > $latest_release [y/N]: " response if [[ $response =~ ^(y|Y)$ ]]; then # Build the gem echo "Preparing the gem package in pkg/*" # Output format: intello-shipit-cli 1.0.2 built to pkg/intello-shipit-cli-1.0.2.gem. version="$(script/package | grep Version: | awk '{print $2}')" # Did we get a version? if [ -z "$version" ]; then echo "You have to give me a semantic tag, like 1.0.0"; exit 1; fi echo "Tagging your code to v$version" echo "" echo "Make sure you are GPG ready." echo "You should have run this at one point:" echo "$ git config --global user.signingkey [gpg-key-id]" git tag -s "v$version" -m "Release v$version" git push origin git push origin "v$version" echo "" echo "Publishing to remote gem repository." gem push pkg/intello-shipit-cli-${version}.gem else echo "You canceled the operation, nothing was done." fi