Skip to content

Commit cc3100d

Browse files
author
Kevin Paulisse
committed
Allow alternate version to be specified from command line
1 parent 13f0cb7 commit cc3100d

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

octocatalog-diff.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 2.0.0'
77

88
s.name = 'octocatalog-diff'
9-
s.version = OctocatalogDiff::Version::VERSION
9+
s.version = ENV['OCTOCATALOG_DIFF_VERSION'] || OctocatalogDiff::Version::VERSION
1010
s.license = 'MIT'
1111
s.authors = ['GitHub, Inc.', 'Kevin Paulisse']
1212
s.email = 'opensource+octocatalog-diff@github.com'

rake/gem.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@
66
module OctocatalogDiff
77
# A class to contain methods and constants for cleaner code
88
class Gem
9+
# Override version number from the environment
10+
def self.version
11+
version = ENV['OCTOCATALOG_DIFF_VERSION'] || OctocatalogDiff::Version::VERSION
12+
unless version == OctocatalogDiff::Version::VERSION
13+
warn "WARNING: Using version #{version}, not #{OctocatalogDiff::Version::VERSION}"
14+
end
15+
version
16+
end
17+
918
BASEDIR = File.expand_path('..', File.dirname(__FILE__)).freeze
10-
VERSION = OctocatalogDiff::Version::VERSION
19+
VERSION = version.freeze
1120
GEMFILE = "octocatalog-diff-#{VERSION}.gem".freeze
1221
PKGDIR = File.join(BASEDIR, 'pkg').freeze
1322
OUTFILE = File.join(BASEDIR, GEMFILE).freeze
@@ -77,8 +86,12 @@ def self.exec_command(command)
7786

7887
task 'force-build' do
7988
branch = OctocatalogDiff::Gem.branch
80-
warn "WARNING: Force-building from non-master branch #{branch}" unless branch == 'master'
81-
OctocatalogDiff::Gem.build("octocatalog-diff-#{OctocatalogDiff::Gem::VERSION}-#{branch}.gem")
89+
unless branch == 'master'
90+
warn "WARNING: Force-building from non-master branch #{branch}"
91+
end
92+
93+
version = OctocatalogDiff::Gem.version
94+
OctocatalogDiff::Gem.build("octocatalog-diff-#{version}-#{branch}.gem")
8295
end
8396

8497
task 'push' do
@@ -127,7 +140,7 @@ def self.exec_command(command)
127140

128141
# Make sure the gem has been built
129142
branch = OctocatalogDiff::Gem.branch
130-
version = OctocatalogDiff::Gem::VERSION
143+
version = OctocatalogDiff::Gem.version
131144
gemfile = if branch == 'master'
132145
OctocatalogDiff::Gem::FINAL_GEMFILE
133146
else

0 commit comments

Comments
 (0)