Skip to content

Commit

Permalink
Merge pull request #8 from TheODI-UD2D/feature-add-task-to-publish-gem
Browse files Browse the repository at this point in the history
Add task to publish gem
  • Loading branch information
Sam Pikesley committed Nov 11, 2015
2 parents e0d3b2b + 076928a commit b08b8be
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [v0.2.2](https://github.com/TheODI-UD2D/blocktrain/tree/v0.2.2) (2015-11-11)
[Full Changelog](https://github.com/TheODI-UD2D/blocktrain/compare/v0.2.1...v0.2.2)

## [v0.2.1](https://github.com/TheODI-UD2D/blocktrain/tree/v0.2.1) (2015-11-10)
[Full Changelog](https://github.com/TheODI-UD2D/blocktrain/compare/v0.2.0...v0.2.1)

**Merged pull requests:**

- Auto-detect available signals from Elasticsearch [\#7](https://github.com/TheODI-UD2D/blocktrain/pull/7) ([Floppy](https://github.com/Floppy))

## [v0.2.0](https://github.com/TheODI-UD2D/blocktrain/tree/v0.2.0) (2015-11-10)
[Full Changelog](https://github.com/TheODI-UD2D/blocktrain/compare/v0.1.4...v0.2.0)

Expand Down
43 changes: 43 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'blocktrain'

require 'github_changelog_generator'
require 'erb'
require 'git'
require 'semver'

class GemPublisher
def initialize
@version = SemVer.parse(Blocktrain::VERSION)
end

def publish
push_tag
create_changelog
bump_version
end

def push_tag
g = Git.open('.')
g.add_tag(@version.to_s)
g.push('origin', 'master', tags: true)
end

def create_changelog
ARGV[0] = "TheODI-UD2D"
ARGV[1] = "blocktrain"
GitHubChangelogGenerator::ChangelogGenerator.new.run
end

def bump_version
@version.patch += 1
@new_version = @version.format("%M.%m.%p%s%d")
template = File.read('version.rb.erb')
renderer = ERB.new(template)
version_file = File.open File.join('lib', 'blocktrain', 'version.rb'), 'w'
version_file.write renderer.result(binding)
end
end

RSpec::Core::RakeTask.new

task :default => [:spec]

task :publish do
GemPublisher.new.publish
end
2 changes: 2 additions & 0 deletions blocktrain.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'webmock', '~> 1.21'
spec.add_development_dependency 'coveralls', '~> 0.8'
spec.add_development_dependency 'terminal-notifier-guard', '~> 1.6'
spec.add_development_dependency 'git', '~> 1.2'
spec.add_development_dependency 'github_changelog_generator', '~> 1.9'
spec.add_development_dependency 'semver2', '~> 3.4'
end
3 changes: 3 additions & 0 deletions version.rb.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Blocktrain
VERSION = '<%= @new_version %>'
end

0 comments on commit b08b8be

Please sign in to comment.