From dedc404e043e732e5f4bdfe5b2826d8fa6096498 Mon Sep 17 00:00:00 2001 From: John Barnette Date: Thu, 8 Aug 2013 12:18:51 -0700 Subject: [PATCH] Teach github-pages how to release --- README.md | 4 ++-- script/build | 6 ------ script/release | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) delete mode 100755 script/build create mode 100755 script/release diff --git a/README.md b/README.md index 4dcac25c..0044e593 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Alternatively, you can add the following to your project's Gemfile: To update to the latest version of Jekyll and associated dependencies, simply run `gem update github-pages`, or if you've installed via Bundler, `bundle update github-pages`. -## Building +## Releasing -To build a new version of the gem, run `script/build` +To release a new version of this gem, run `script/release` from the `master` branch. ## License diff --git a/script/build b/script/build deleted file mode 100755 index 5b6cb745..00000000 --- a/script/build +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# Build the Ruby gem - -set -e - -gem build github-pages.gemspec \ No newline at end of file diff --git a/script/release b/script/release new file mode 100755 index 00000000..836e799d --- /dev/null +++ b/script/release @@ -0,0 +1,38 @@ +#!/bin/sh +# Tag and push a release. + +set -e + +# Make sure we're in the project root. + +cd $(dirname "$0")/.. + +# Build a new gem archive. + +rm -rf github-pages-*.gem +gem build -q github-pages.gemspec + +# Make sure we're on the master branch. + +(git branch | grep -q '* master') || { + echo "Only release from the master branch." + exit 1 +} + +# Figure out what version we're releasing. + +tag=v`ls github-pages-*.gem | sed 's/^github-pages-\(.*\)\.gem$/\1/'` + +# Make sure we haven't released this version before. + +git fetch -t origin + +(git tag -l | grep -q "$tag") && { + echo "Whoops, there's already a '${tag}' tag." + exit 1 +} + +# Tag it and bag it. + +gem push github-pages-*.gem && git tag "$tag" && + git push origin master && git push origin "$tag"