-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from TheODI-UD2D/feature-add-task-to-publish-gem
Add task to publish gem
- Loading branch information
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Blocktrain | ||
VERSION = '<%= @new_version %>' | ||
end |