Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add scripts to help with release process

  • Loading branch information...
commit 01df764eaf1879da05f76e4a627e7fb562995384 1 parent f33fb2e
Mislav Marohnić mislav authored
36 Rakefile
View
@@ -115,6 +115,12 @@ task :install => "hub" do
FileUtils.cp "man/hub.1", "#{prefix}/share/man/man1"
end
+#
+# Release
+#
+
+task :release => [:pages, :gem_release, :homebrew]
+
desc "Copy files to gh-pages branch, but don't publish"
task :gh_pages => [:check_dirty, "hub", "man/hub.1.html"] do
cp "man/hub.1.html", "html"
@@ -133,3 +139,33 @@ task :pages => :gh_pages do
sh "git checkout master"
puts "Done."
end
+
+task :gem_release do
+ sh "gem release -t"
+end
+
+desc "Publish to Homebrew"
+task :homebrew do
+ require File.expand_path('../lib/hub/version', __FILE__)
+ Dir.chdir `brew --prefix`.chomp do
+ sh 'git checkout -q master'
+ sh 'git pull -q origin master'
+
+ formula_file = 'Library/Formula/hub.rb'
+ md5 = `curl -#L https://github.com/defunkt/hub/tarball/v#{Hub::VERSION} | md5`.chomp
+ abort unless $?.success? and md5.length == 32
+
+ formula = File.read formula_file
+ formula.sub! /\bv\d+(\.\d+)*/, "v#{Hub::VERSION}"
+ formula.sub! /\b[0-9a-f]{32}\b/, md5
+ File.open(formula_file, 'w') {|f| f << formula }
+
+ branch = "hub-v#{Hub::VERSION}"
+ sh "git checkout -q -B #{branch}"
+ sh "git commit -m 'upgrade hub to v#{Hub::VERSION}' -- #{formula_file}"
+ sh "git push -u mislav #{branch}"
+ sh "hub pull-request 'upgrade hub to v#{Hub::VERSION}'"
+
+ sh "git checkout -q master"
+ end
+end
14 git-hooks/changed-version.sh
View
@@ -0,0 +1,14 @@
+#!/bin/bash
+## If version file is staged to be committed, display the new version number.
+
+version_file="${1:-lib/hub/version.rb}"
+
+if git rev-parse --verify HEAD >/dev/null 2>&1; then
+ if git diff-index --quiet --cached HEAD -- "$version_file"; then
+ exit 1
+ else
+ git cat-file blob ":$version_file" | grep VERSION | head -1 | cut -d\' -f2
+ fi
+else
+ exit 1
+fi
11 git-hooks/commit-msg.sh
View
@@ -0,0 +1,11 @@
+#!/bin/bash
+## Checks that commit that changes version number includes it in subject line.
+
+set -e
+
+new_version="$("$(dirname "$0")"/changed-version)" || exit 0
+
+head -1 "$1" | grep "$new_version" >/dev/null || {
+ echo "aborted: version $new_version not present in subject line"
+ exit 1
+}
16 git-hooks/install
View
@@ -0,0 +1,16 @@
+#!/bin/bash
+## Installs the provided hooks in the current git repo
+
+set -e
+
+hooks_dir="$(git rev-parse --git-dir)/hooks"
+source_dir="$(dirname "$0")"
+
+for file in "$source_dir"/*.sh; do
+ dest="${hooks_dir}/$(basename "$file" .sh)"
+ [[ ! $dest -nt $file ]] && \
+ cp -v "$file" "$dest" && \
+ chmod +x "$dest"
+done
+
+exit 0
13 git-hooks/pre-commit.sh
View
@@ -0,0 +1,13 @@
+#!/bin/bash
+## Prevents a commit that changes version but doesn't update HISTORY.md
+
+set -e
+
+new_version="$("$(dirname "$0")"/changed-version)" || exit 0
+
+if git cat-file blob :HISTORY.md | head -1 | grep $new_version >/dev/null; then
+ exit 0
+else
+ echo "aborted: History.md is out of date" >&2
+ exit 1
+fi
Please sign in to comment.
Something went wrong with that request. Please try again.