1
1
# encoding: utf-8
2
+ # ruby_lib Rakefile
2
3
require 'rubygems'
3
4
require 'rake'
4
5
require 'date'
6
+ require 'posix/spawn'
5
7
6
8
# Defines gem name.
7
9
def repo_name ; 'appium_lib' end # ruby_lib published as appium_lib
@@ -63,6 +65,11 @@ task :dev do
63
65
sh 'gem install --no-rdoc --no-ri redcarpet'
64
66
end
65
67
68
+ def tag_exists tag_name
69
+ cmd = %Q(git branch -a --contains "#{ tag_name } ")
70
+ POSIX ::Spawn ::Child . new ( cmd ) . out . include? '* master'
71
+ end
72
+
66
73
# Inspired by Gollum's Rakefile
67
74
desc 'Build and release a new gem to rubygems.org'
68
75
task :release => :gem do
@@ -71,16 +78,20 @@ task :release => :gem do
71
78
exit!
72
79
end
73
80
81
+ # Commit then pull before pushing.
82
+ tag_name = "v#{ version } "
83
+ raise 'Tag already exists!' if tag_exists tag_name
84
+
74
85
# Commit then pull before pushing.
75
86
sh "git commit --allow-empty -am 'Release #{ version } '"
76
87
sh 'git pull'
77
- sh "git tag v #{ version } "
78
- # update notes and docs now that there's a new tag
88
+ sh "git tag #{ tag_name } "
89
+ # update notes now that there's a new tag
79
90
Rake ::Task [ 'notes' ] . execute
80
91
Rake ::Task [ 'docs' ] . execute
81
92
sh "git commit --allow-empty -am 'Update release notes'"
82
93
sh 'git push origin master'
83
- sh "git push origin v #{ version } "
94
+ sh "git push origin #{ tag_name } "
84
95
sh "gem push #{ repo_name } -#{ version } .gem"
85
96
end
86
97
0 commit comments