xn_gem_release_tasks 0.1.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86046bab22ff9bbf11df93e18a01f0950a92ef52
4
+ data.tar.gz: 9b06d6e41626bc29b729c182aa955ffdde654d03
5
+ SHA512:
6
+ metadata.gz: 8727c76cacd176b7b77d7cd547b3d085fb4610db402eddd4f7e28088616aff586904d8d11a1be7eaec2037735f5f7c7f7dba486dcda4c8128211eb14e7d81032
7
+ data.tar.gz: 20eb0241049bec175385238b4344b0fc8970e5c8b26d3d4e5593700ac52639e8a409bb0aaec78374472ff2c3d0b92ac48d2da1744471174d40efb4e52f91f87e
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in xn_gem_release_tasks.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Darrick Wiebe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # GemReleaseTasks
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gem_release_tasks'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gem_release_tasks
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/gem_release_tasks/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'xn_gem_release_tasks'
3
+
4
+ XNGemReleaseTasks.setup XNGemReleaseTasks, 'lib/xn_gem_release_tasks/version.rb'
@@ -0,0 +1,257 @@
1
+ require "xn_gem_release_tasks/version"
2
+ require 'rake'
3
+ require 'yaml'
4
+
5
+ module Bundler
6
+ class GemHelper
7
+ def perform_git_push(options = '')
8
+ cmd = "git push origin master:master #{options}"
9
+ out, code = sh_with_code(cmd)
10
+ raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0
11
+ end
12
+
13
+ def version
14
+ XNGemReleaseTasks::NAMESPACE::VERSION
15
+ end
16
+ end
17
+ end
18
+
19
+
20
+ module XNGemReleaseTasks
21
+ V = /(?<before>\s*\bVERSION\s*=\s*")(?<major>\d+)\.(?<minor>\d+)\.(?<point>\d+)(?:\.(?<pre>\w+))?(?<after>".*)/
22
+
23
+ def self.ensure_setup
24
+ raise "Must run XNGemReleaseTasks.setup(LibModule, 'path/to/version.rb') first" unless NAMESPACE
25
+ end
26
+
27
+ def self.change_version
28
+ ensure_setup
29
+ f = File.read(NAMESPACE::VERSION_FILE)
30
+ lines = f.each_line.map do |line|
31
+ match = V.match line
32
+ if match
33
+ yield line, match[:before], match[:major], match[:minor], match[:point], match[:pre], match[:after]
34
+ else
35
+ line
36
+ end
37
+ end
38
+ File.open(NAMESPACE::VERSION_FILE, 'w') do |f|
39
+ f.puts lines.join
40
+ end
41
+ end
42
+
43
+ def self.reload_version
44
+ ensure_setup
45
+ NAMESPACE.send :remove_const, :VERSION
46
+ load NAMESPACE::VERSION_FILE
47
+ NAMESPACE::VERSION
48
+ end
49
+
50
+ def self.setup(namespace, version_file)
51
+ raise "namespace must be a module" unless namespace.is_a? Module
52
+ raise "namespace does not have a current version" unless namespace::VERSION
53
+ raise "#{ version_file } file does not exist" unless File.exist? version_file
54
+ raise "You may not set up XNGemReleaseTasks multiple times" if defined? NAMESPACE
55
+ self.const_set :NAMESPACE, namespace
56
+ namespace.const_set :VERSION_FILE, version_file
57
+ end
58
+
59
+ def self.gemspec
60
+ eval(File.read(Dir['*.gemspec'].first))
61
+ end
62
+ end
63
+
64
+ task :validate_gemspec do
65
+ gemspec = XNGemReleaseTasks.gemspec
66
+ gemspec.validate
67
+ end
68
+
69
+ def command(task_name, name, &block)
70
+ s = `which #{name}`
71
+ if s == ""
72
+ task(task_name, &block)
73
+ else
74
+ task task_name do
75
+ # noop
76
+ end
77
+ end
78
+ end
79
+
80
+ desc "Ensures we are on a relesae version, and increments if we already are."
81
+ task :increment_release_version do
82
+ XNGemReleaseTasks.change_version do |line, before, major, minor, point, pre, after|
83
+ if pre
84
+ "#{before}#{major}.#{minor}.#{point}#{after}\n"
85
+ else
86
+ "#{before}#{major}.#{minor}.#{point.next}#{after}\n"
87
+ end
88
+ end
89
+ end
90
+
91
+ desc "Ensures we are on a release version, but does not increment version number"
92
+ task :set_release_version do
93
+ XNGemReleaseTasks.change_version do |line, before, major, minor, point, pre, after|
94
+ "#{before}#{major}.#{minor}.#{point}#{after}\n"
95
+ end
96
+ end
97
+
98
+ desc "Increments a release version number and adds .pre. Does not increment a version that is already .pre."
99
+ task :set_development_version do
100
+ XNGemReleaseTasks.change_version do |line, before, major, minor, point, pre, after|
101
+ if pre
102
+ line
103
+ else
104
+ "#{before}#{major}.#{minor}.#{point.next}.pre#{after}\n"
105
+ end
106
+ end
107
+ end
108
+
109
+ task :is_clean do
110
+ if ENV['TRAVIS_BRANCH'] == 'master'
111
+ true
112
+ else
113
+ sh "git status | grep 'working directory clean'"
114
+ end
115
+ end
116
+
117
+ task :is_on_master do
118
+ if ENV['TRAVIS_BRANCH'] == 'master'
119
+ true
120
+ else
121
+ unless ENV['IGNORE_BRANCH'] == 'true'
122
+ sh "git status | grep 'On branch master'"
123
+ end
124
+ end
125
+ end
126
+
127
+ task :is_on_origin_master do
128
+ if ENV['TRAVIS_BRANCH'] == 'master'
129
+ true
130
+ else
131
+ unless ENV['IGNORE_BRANCH'] == 'true'
132
+ result = `git log HEAD...origin/master | grep . || echo ok`
133
+ fail "Not on origin/master" unless result.chomp == 'ok'
134
+ end
135
+ end
136
+ end
137
+
138
+ task :is_up_to_date do
139
+ if ENV['TRAVIS_BRANCH'] == 'master'
140
+ true
141
+ else
142
+ sh "git pull | grep 'Already up-to-date.'"
143
+ end
144
+ end
145
+
146
+ task :is_release_version do
147
+ unless XNGemReleaseTasks.reload_version =~ /^\d+\.\d+\.\d+$/
148
+ fail "Not on a release version: #{ XNGemReleaseTasks::NAMESPACE::VERSION }"
149
+ end
150
+ end
151
+
152
+ task :prepare_release_push => [:is_clean, :is_on_master, :is_up_to_date, :set_release_version]
153
+
154
+ task :_only_push_release do
155
+ XNGemReleaseTasks.reload_version
156
+ if `git status | grep 'working directory clean'` == ''
157
+ skip_ci = '[skip ci] ' if ENV['TRAVIS_SECURE_ENV_VARS']
158
+ if sh "git add #{XNGemReleaseTasks::NAMESPACE::VERSION_FILE} && git commit -m '#{skip_ci}Version #{ XNGemReleaseTasks::NAMESPACE::VERSION }'"
159
+ sh "git push"
160
+ end
161
+ end
162
+ end
163
+
164
+ task :only_push_release => [:prepare_release_push, :_only_push_release]
165
+
166
+ task :next_dev_cycle => [:is_clean, :set_development_version] do
167
+ XNGemReleaseTasks.reload_version
168
+ sh "git add #{XNGemReleaseTasks::NAMESPACE::VERSION_FILE} && git commit -m '[skip ci] New development cycle with version #{ XNGemReleaseTasks::NAMESPACE::VERSION }' && git push"
169
+ end
170
+
171
+ desc "Configure environment"
172
+ task :env do
173
+ path = `echo $PATH`
174
+ home = `echo $HOME`
175
+ unless path.include? "#{home}/bin"
176
+ puts "Configuring path..."
177
+ `mkdir -p $HOME/bin`
178
+ if File.exist? "#{home}/.zshrc"
179
+ profile = "#{home}/.zshrc"
180
+ else
181
+ profile = "#{home}/.bashrc"
182
+ end
183
+ `echo 'export PATH="$PATH:$HOME/bin"' >> #{profile} && source #{profile}`
184
+ end
185
+ end
186
+
187
+ desc "Install Leiningen, the clojure build tool"
188
+ command(:install_lein, '$HOME/bin/lein') do
189
+ if File.exist? 'project.clj'
190
+ Rake::Task['env'].invoke
191
+ puts "Installing Leiningen..."
192
+ `curl "https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein" -o "$HOME/bin/lein"`
193
+ `chmod a+x $HOME/bin/lein`
194
+ `lein`
195
+ end
196
+ end
197
+
198
+ desc "Run Leiningen tests"
199
+ task :lein_test => [:install_lein] do
200
+ if File.exist? 'project.clj'
201
+ puts "Running Leiningen tests..."
202
+ `lein test`
203
+ else
204
+ puts "Not a Clojure project"
205
+ end
206
+ end
207
+
208
+ task :validate_major_push do
209
+ gemspec = XNGemReleaseTasks.gemspec
210
+ unless gemspec.version.to_s.include? "pre"
211
+ Rake::Task['is_clean'].invoke
212
+ Rake::Task['is_on_master'].invoke
213
+ Rake::Task['is_up_to_date'].invoke
214
+ end
215
+ end
216
+
217
+ desc "Build gem and push to s3"
218
+ task :up => [:validate_gemspec, :validate_major_push, :lein_test, :build, :spec, :_up]
219
+
220
+ task :_up do
221
+ gemspec = XNGemReleaseTasks.gemspec
222
+ if defined?(gemspec.platform) and gemspec.platform != '' and gemspec.platform != 'ruby'
223
+ gem = "#{gemspec.name}-#{gemspec.version}-#{gemspec.platform}.gem"
224
+ else
225
+ gem = "#{gemspec.name}-#{gemspec.version}.gem"
226
+ end
227
+ source = ENV['GEMINABOX']
228
+ unless source
229
+ config = YAML.load_file("#{ENV['HOME']}/.gemrc") rescue {}
230
+ sources = config[:sources] || config['sources'] || []
231
+ source = sources.grep(/^https:\/\/\w+:\w+@gems.xnlogic.com\/?$/).first
232
+ end
233
+ overwrite = "-o" if gemspec.version =~ /\.pre/
234
+ raise "No authorized source pointing to https://gems.xnlogic.com found in your gem config" unless source
235
+ sh "gem inabox #{overwrite} -g #{source} pkg/#{gem}"
236
+ end
237
+
238
+ # Set a dependency to replace the :release task. For example, the following would cause :up to be used to
239
+ # release instead of :release. That allows the local_release task to work in either case.
240
+ #
241
+ # task release_with: :up
242
+ #
243
+ task :release_with do |this|
244
+ if this.prerequisites.empty?
245
+ Rake::Task[:release].invoke
246
+ end
247
+ end
248
+
249
+ desc "Release a new version locally rather than after a successful Travis build"
250
+ task :local_release => [:only_push_release, :release_with, :next_dev_cycle, :after_release]
251
+
252
+ desc "Push a release candidate to Travis CI to release if it builds successfully"
253
+ task :push_release => [:only_push_release, :next_dev_cycle, :after_release]
254
+
255
+ task :release => [:is_clean, :is_on_origin_master, :is_release_version]
256
+
257
+ task :after_release
@@ -0,0 +1,3 @@
1
+ module XNGemReleaseTasks
2
+ VERSION = "0.1.32"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xn_gem_release_tasks/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xn_gem_release_tasks"
8
+ spec.version = XNGemReleaseTasks::VERSION
9
+ spec.authors = ["Darrick Wiebe"]
10
+ spec.email = ["dw@xnlogic.com"]
11
+ spec.summary = %q{Simple set of rake tasks for enforcing development and release consistency}
12
+ spec.description =
13
+ %q{Develop on .pre branches, only allow releases from non-.pre clean, up-to-date master. Designed to allow Travis CI to do the
14
+ push when on a release version, after passing tests.}
15
+ spec.homepage = "https://xnlogic.com"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "geminabox"
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "travis"
27
+ spec.add_development_dependency "builder"
28
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xn_gem_release_tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.32
5
+ platform: ruby
6
+ authors:
7
+ - Darrick Wiebe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: geminabox
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: travis
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: builder
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |-
84
+ Develop on .pre branches, only allow releases from non-.pre clean, up-to-date master. Designed to allow Travis CI to do the
85
+ push when on a release version, after passing tests.
86
+ email:
87
+ - dw@xnlogic.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/xn_gem_release_tasks.rb
98
+ - lib/xn_gem_release_tasks/version.rb
99
+ - xn_gem_release_tasks.gemspec
100
+ homepage: https://xnlogic.com
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.4.5
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: Simple set of rake tasks for enforcing development and release consistency
124
+ test_files: []