提交 01df764e 编写于 作者: M Mislav Marohnić

add scripts to help with release process

上级 f33fb2e9
......@@ -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
#!/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
#!/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
}
#!/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
#!/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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册