1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#!/bin/bash
# Edit the version string in the gemspec, then execute this script to:
#
# 1. Commit the version change
# 2. Tag the release
# 3. Push the tag and the current branch to GitHub
# 4. Publish the gem to RubyGems
#
set -eu
fields=( $(gem build *.gemspec | awk '/Name:|Version:/ {print $2}') )
name="${fields[0]}"
version="${fields[1]}"
gem="${name}-${version}.gem"
[ -n "$version" ] || exit 1
trap "rm -f '$gem'" EXIT
bundle install
script/test
if ! git rev-parse --verify --quiet "refs/tags/v${version}" >/dev/null; then
git commit --allow-empty -a -m "$name $version"
git tag "v${version}"
fi
git push origin HEAD "v${version}"
gem push "$gem"
|