buildar 0.0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/MANIFEST.txt +4 -0
  2. data/README.md +29 -0
  3. data/VERSION +1 -0
  4. data/rakefile.rb +119 -0
  5. metadata +81 -0
data/MANIFEST.txt ADDED
@@ -0,0 +1,4 @@
1
+ MANIFEST.txt
2
+ VERSION
3
+ README.md
4
+ rakefile.rb
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ Buildar
2
+ =======
3
+ Buildar is a set of Rakefile methods and tasks to help automate versioning,
4
+ packaging, releasing, and publishing ruby gems.
5
+
6
+ Rake tasks
7
+ ----------
8
+ * version - show the current project version (./VERSION)
9
+ * manifest - show the files tracked by the gem (./MANIFEST.txt)
10
+ * build - build a .gem file inside pkg/
11
+ * bump_build - increment the 4th version number (1.2.3.4 -> 1.2.3.5)
12
+ * bump_patch - increment the 3rd version number (1.2.3.4 -> 1.2.4.0)
13
+ * bump_minor - increment the 2nd version number (1.2.3.4 -> 1.3.0.0)
14
+ * bump_major - increment the 1st version number (1.2.3.4 -> 2.0.0.0)
15
+ * tag - git tag according to current version, pushed to origin
16
+ * publish - gem push
17
+ * release - bump_build, tag, publish
18
+ * release_patch - bump_patch, tag, publish
19
+ * release_minor - bump_minor, tag, publish
20
+ * release_major - bump_major, tag, publish
21
+
22
+ Philosophy
23
+ ----------
24
+ * Track the release version in one place: ./VERSION
25
+ * The version only matters in the context of a release. For internal development, git SHAs vastly outclass version numbers.
26
+ * "The right version number" for the next release is a function of the current release version and the magnitude (or breakiness) of the change
27
+ * http://semver.org/
28
+ * Automate everything
29
+ * This does not absolve you from attentending to changelogs, etc.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1.2
data/rakefile.rb ADDED
@@ -0,0 +1,119 @@
1
+ require 'rubygems/package_task'
2
+
3
+ PROJECT_ROOT = File.dirname(__FILE__)
4
+ PROJECT_NAME = File.split(PROJECT_ROOT).last
5
+ VERSION_FILE = File.join(PROJECT_ROOT, 'VERSION')
6
+ MANIFEST_FILE = File.join(PROJECT_ROOT, 'MANIFEST.txt')
7
+
8
+ def version
9
+ File.read(VERSION_FILE).chomp
10
+ end
11
+
12
+ task :version do
13
+ puts "#{PROJECT_NAME} #{version}"
14
+ end
15
+
16
+ task :tag do
17
+ tagname = "v#{version}"
18
+ sh "git tag -a #{tagname} -m 'auto-tagged #{tagname} by Rake'"
19
+ sh "git push origin --tags"
20
+ end
21
+
22
+ def manifest
23
+ File.readlines(MANIFEST_FILE).map { |line| line.chomp }
24
+ end
25
+
26
+ task :manifest do
27
+ puts manifest.join("\n")
28
+ end
29
+
30
+ task :build => [:bump_build] do
31
+ spec = Gem::Specification.new do |s|
32
+ # Static assignments
33
+ s.name = PROJECT_NAME
34
+ s.summary = "FIX"
35
+ s.description = "FIX"
36
+ s.authors = ["FIX"]
37
+ s.email = "FIX@FIX.COM"
38
+ s.homepage = "http://FIX.COM/"
39
+ s.licenses = ['FIX']
40
+
41
+ # Dynamic assignments
42
+ s.files = manifest
43
+ s.version = version
44
+ s.date = Time.now.strftime("%Y-%m-%d")
45
+
46
+ # s.add_runtime_dependency "rest-client", ["~> 1"]
47
+ # s.add_runtime_dependency "json", ["~> 1"]
48
+ s.add_development_dependency "minitest", [">= 0"]
49
+ s.add_development_dependency "rake", [">= 0"]
50
+ end
51
+
52
+ # we're definining the task at runtime, rather than requiretime
53
+ # so that the gemspec will reflect any version bumping since requiretime
54
+ #
55
+ Gem::PackageTask.new(spec).define
56
+ Rake::Task["package"].invoke
57
+ end
58
+
59
+ # e.g. bump(:minor, '1.2.3') #=> '1.3.0'
60
+ # only works for integers delimited by periods (dots)
61
+ #
62
+ def bump(position, version)
63
+ pos = [:major, :minor, :patch, :build].index(position) || position
64
+ places = version.split('.')
65
+ raise "bad position: #{pos} (for version #{version})" unless places[pos]
66
+ places.map.with_index { |place, i|
67
+ if i < pos
68
+ place
69
+ elsif i == pos
70
+ place.to_i + 1
71
+ else
72
+ 0
73
+ end
74
+ }.join('.')
75
+ end
76
+
77
+ def write_version new_version
78
+ File.open(VERSION_FILE, 'w') { |f| f.write(new_version) }
79
+ end
80
+
81
+ [:major, :minor, :patch, :build].each { |v|
82
+ task "bump_#{v}" do
83
+ old_version = version
84
+ new_version = bump(v, old_version)
85
+ puts "bumping #{old_version} to #{new_version}"
86
+ write_version new_version
87
+ sh "git add VERSION"
88
+ sh "git commit -m 'rake bump_#{v}'"
89
+ end
90
+ }
91
+ task :bump => [:bump_patch]
92
+
93
+ task :verify_publish_credentials do
94
+ creds = '~/.gem/credentials'
95
+ fp = File.expand_path(creds)
96
+ raise "#{creds} does not exist" unless File.exists?(fp)
97
+ raise "can't read #{creds}" unless File.readable?(fp)
98
+ end
99
+
100
+ task :publish => [:verify_publish_credentials] do
101
+ fragment = "-#{version}.gem"
102
+ pkg_dir = File.join(PROJECT_ROOT, 'pkg')
103
+ Dir.chdir(pkg_dir) {
104
+ candidates = Dir.glob "*#{fragment}"
105
+ case candidates.length
106
+ when 0
107
+ raise "could not find .gem matching #{fragment}"
108
+ when 1
109
+ sh "gem push #{candidates.first}"
110
+ else
111
+ raise "multiple candidates found matching #{fragment}"
112
+ end
113
+ }
114
+ end
115
+
116
+ task :release => [:build, :tag, :publish]
117
+ task :release_patch => [:bump_patch, :release]
118
+ task :release_minor => [:bump_minor, :release]
119
+ task :release_major => [:bump_major, :release]
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buildar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - FIX
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: FIX
47
+ email: FIX@FIX.COM
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - MANIFEST.txt
53
+ - VERSION
54
+ - README.md
55
+ - rakefile.rb
56
+ homepage: http://FIX.COM/
57
+ licenses:
58
+ - FIX
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.23
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: FIX
81
+ test_files: []