-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6166ab8
commit 89cf54c
Showing
3 changed files
with
107 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
.*.sw? | ||
.rbenv-version | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
doc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,103 @@ | ||
|
||
desc 'Run specs' | ||
task :spec do | ||
sh "bacon #{specs('**')}" | ||
end | ||
|
||
task :default => :spec | ||
|
||
#-----------------------------------------------------------------------------# | ||
|
||
desc 'Generate yardoc' | ||
task :doc do | ||
sh "rm -rf yardoc" | ||
sh "yardoc" | ||
end | ||
|
||
desc 'Run specs' | ||
task :spec do | ||
sh "bacon #{specs('**')}" | ||
#-----------------------------------------------------------------------------# | ||
|
||
namespace :bundler do | ||
require "bundler/gem_tasks" | ||
end | ||
|
||
task :default => :spec | ||
#-----------------------------------------------------------------------------# | ||
|
||
desc "Run all specs, build and install gem, commit version change, tag version change, and push everything" | ||
task :release do | ||
|
||
unless ENV['SKIP_CHECKS'] | ||
if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master' | ||
$stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release." | ||
exit 1 | ||
end | ||
|
||
if `git tag`.strip.split("\n").include?(gem_version) | ||
$stderr.puts "[!] A tag for version `#{gem_version}' already exists. Change the version in lib/claide.rb" | ||
exit 1 | ||
end | ||
|
||
puts "You are about to release `#{gem_version}', is that correct? [y/n]" | ||
exit if $stdin.gets.strip.downcase != 'y' | ||
|
||
diff_lines = `git diff --name-only`.strip.split("\n") | ||
|
||
diff_lines.delete('Gemfile.lock') | ||
diff_lines.delete('Changelog.md') | ||
if diff_lines != ['lib/claide.rb'] | ||
$stderr.puts "[!] Only change the version number in a release commit!" | ||
$stderr.puts diff_lines | ||
exit 1 | ||
end | ||
end | ||
|
||
require 'date' | ||
|
||
# Ensure that the branches are up to date with the remote | ||
sh "git pull" | ||
|
||
puts "* Running specs" | ||
silent_sh('rake spec') | ||
|
||
tmp = File.expand_path('../tmp', __FILE__) | ||
tmp_gems = File.join(tmp, 'gems') | ||
|
||
Rake::Task['bundler:build'].invoke | ||
|
||
puts "* Testing gem installation (tmp/gems)" | ||
silent_sh "rm -rf '#{tmp}'" | ||
silent_sh "gem install --install-dir='#{tmp_gems}' #{gem_pkg_path}" | ||
|
||
# Then release | ||
sh "git commit lib/claide.rb -m 'Release #{gem_version}'" | ||
sh "git tag -a #{gem_version} -m 'Release #{gem_version}'" | ||
sh "git push origin master" | ||
sh "git push origin --tags" | ||
|
||
Rake::Task['bundler:release'].invoke | ||
|
||
end | ||
|
||
#-----------------------------------------------------------------------------# | ||
|
||
def gem_version | ||
require File.expand_path('../lib/claide', __FILE__) | ||
CLAide::VERSION | ||
end | ||
|
||
def gem_pkg_path | ||
"pkg/claide-#{gem_version}.gem" | ||
end | ||
|
||
def silent_sh(command) | ||
output = `#{command} 2>&1` | ||
unless $?.success? | ||
puts output | ||
exit 1 | ||
end | ||
output | ||
end | ||
|
||
def specs(dir) | ||
FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ') | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters