Skip to content
Browse files

Bump version to 1.0.0, add version bumping task

  • Loading branch information...
1 parent fdbf47c commit 922dd549ddb31ee73cf9b15dbacfa835db0ec11d @hmarr hmarr committed Apr 24, 2012
Showing with 75 additions and 1 deletion.
  1. +11 −0 CHANGELOG.md
  2. +63 −0 Rakefile
  3. +1 −1 lib/gocardless/version.rb
View
11 CHANGELOG.md
@@ -1,3 +1,14 @@
+## 1.0.0 - April 24, 2012
+
+- Add plan_id to selected resources
+- Remove deprecated resource attributes
+- Fix sorting issue in Utils.normalize_params
+- Add rake console task
+- Add rake version:bump tasks
+- Fix user agent formatting
+- Relax multi_json dependency
+
+
## 0.2.0 - April 3, 2012
- Add `cancel!` method to `Subscription`
View
63 Rakefile
@@ -17,3 +17,66 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
end
+
+def generate_changelog(last_version, new_version)
+ commits = `git log v#{last_version}.. --oneline`.split("\n")
+ msgs = commits.map { |commit| commit.sub(/^[a-f0-9]+/, '-') }
+ date = Time.now.strftime("%B %d, %Y")
+ "## #{new_version} - #{date}\n\n#{msgs.join("\n")}\n\n\n"
+end
+
+def update_changelog(last_version, new_version)
+ contents = File.read('CHANGELOG.md')
+ if contents =~ /## #{new_version}/
+ puts "CHANGELOG already contains v#{new_version}, skipping"
+ return false
+ end
+ changelog = generate_changelog(last_version, new_version)
+ File.open('CHANGELOG.md', 'w') { |f| f.write(changelog + contents) }
+end
+
+def update_version_file(new_version)
+ path = "lib/#{Dir.glob('*.gemspec').first.split('.').first}/version.rb"
+ contents = File.read(path)
+ contents.sub!(/VERSION\s+=\s+["'][\d\.]+["']/, "VERSION = '#{new_version}'")
+ File.open(path, 'w') { |f| f.write(contents) }
+end
+
+def bump_version(part)
+ last_version = `git tag -l | tail -1`.strip.sub(/^v/, '')
+ major, minor, patch = last_version.scan(/\d+/).map(&:to_i)
+
+ case part
+ when :major
+ major += 1
+ minor = patch = 0
+ when :minor
+ minor += 1
+ patch = 0
+ when :patch
+ patch += 1
+ end
+ new_version = "#{major}.#{minor}.#{patch}"
+
+ update_changelog(last_version, new_version)
+ puts "Updated CHANGELOG"
+
+ update_version_file(new_version)
+ puts "Updated version.rb"
+end
+
+desc "Update the version, auto-generating the changelog"
+namespace :version do
+ namespace :bump do
+ task :major do
+ bump_version :major
+ end
+ task :minor do
+ bump_version :minor
+ end
+ task :patch do
+ bump_version :patch
+ end
+ end
+end
+
View
2 lib/gocardless/version.rb
@@ -1,3 +1,3 @@
module GoCardless
- VERSION = '0.2.0'.freeze
+ VERSION = '1.0.0'.freeze
end

0 comments on commit 922dd54

Please sign in to comment.
Something went wrong with that request. Please try again.