Skip to content

Commit 81a15a6

Browse files
authored
Merge pull request #41 from github/kpaulisse-version-variable
Allow alternate version to be specified from command line
2 parents 13f0cb7 + 14b25f7 commit 81a15a6

3 files changed

Lines changed: 61 additions & 7 deletions

File tree

doc/dev/releasing.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,47 @@
22

33
The project maintainers are responsible for bumping the version number, regenerating auto-generated documentation, tagging the release, and uploading to rubygems.
44

5-
0. Ensure that all changes have been merged to master.
5+
## Local testing
6+
7+
To test the new version of `octocatalog-diff` in the Puppet repository:
8+
9+
0. In the Puppet checkout, start a new branch based off master.
10+
0. In the `octocatalog-diff` checkout:
11+
- Ensure that the desired branch is checked out.
12+
- Choose a unique internal version number which has never been used in CI. A good guideline is that if you're planning to release a version `0.6.0` then for these tests, use `0.6.0a`, `0.6.0b`, ...
13+
- Build the gem using your internal version number:
14+
15+
```
16+
OCTOCATALOG_DIFF_VERSION=0.6.0a rake gem:force-build
17+
```
18+
- Run the task to install the gem into your Puppet checkout:
19+
20+
```
21+
OCTOCATALOG_DIFF_VERSION=0.6.0a rake gem:localinstall
22+
```
23+
24+
0. Back in the Puppet checkout, ensure that the changes are as expected (updates to Gemfile / Gemfile.lock, addition of new gem). Push the change and build appropriate CI job(s) to validate the changes.
25+
26+
## Merging
27+
628
0. If necessary, complete a Pull Request to update the [version file](/.version).
29+
0. If necessary, auto-generate the build documentation.
30+
31+
```
32+
rake doc:build
33+
```
34+
35+
0. Ensure that CI tests are all passing.
36+
0. Merge and delete the branch.
37+
38+
## Releasing
39+
40+
Generally, a new release will correspond to a merge to master of one or more Pull Requests.
41+
42+
0. Ensure that all changes associated with the release have been merged to master.
43+
- Merge all Pull Requests associated with release.
44+
- If necessary, complete a Pull Request to update the [change log](/doc/CHANGELOG.md).
45+
- If necessary (for significant changes), complete a Pull Request to update the top-level README file.
746
0. Ensure the the master branch is checked out on your system.
847
0. Run the release procedure:
948
@@ -13,7 +52,6 @@ The project maintainers are responsible for bumping the version number, regenera
1352
1453
This rake task handles the following:
1554
16-
- Auto-generates the [options reference](/doc/optionsref.md) (`rake doc:build`)
1755
- Build the gem file (`rake gem:build`)
1856
- Tag the release in the repository (`rake gem:tag`)
1957
- Upload the gem file to rubygems (`rake gem:push`)

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: 20 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
@@ -34,12 +43,15 @@ def self.build(target = GEMFILE)
3443

3544
# Push the gem to rubygems
3645
def self.push
46+
raise 'Cannot push version that does not match .version file' unless version == OctocatalogDiff::Version::VERSION
3747
raise "The gem file doesn't exist: #{FINAL_GEMFILE}" unless File.file?(FINAL_GEMFILE)
3848
exec_command("gem push #{Shellwords.escape(FINAL_GEMFILE)}")
3949
end
4050

4151
# Tag the release on GitHub
4252
def self.tag
53+
raise 'Cannot tag version that does not match .version file' unless version == OctocatalogDiff::Version::VERSION
54+
4355
# Make sure we have not released this version before
4456
exec_command('git fetch -t origin')
4557
tags = exec_command('git tag -l').split(/\n/)
@@ -77,8 +89,12 @@ def self.exec_command(command)
7789

7890
task 'force-build' do
7991
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")
92+
unless branch == 'master'
93+
warn "WARNING: Force-building from non-master branch #{branch}"
94+
end
95+
96+
version = OctocatalogDiff::Gem.version
97+
OctocatalogDiff::Gem.build("octocatalog-diff-#{version}-#{branch}.gem")
8298
end
8399

84100
task 'push' do
@@ -127,7 +143,7 @@ def self.exec_command(command)
127143

128144
# Make sure the gem has been built
129145
branch = OctocatalogDiff::Gem.branch
130-
version = OctocatalogDiff::Gem::VERSION
146+
version = OctocatalogDiff::Gem.version
131147
gemfile = if branch == 'master'
132148
OctocatalogDiff::Gem::FINAL_GEMFILE
133149
else

0 commit comments

Comments
 (0)