Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update the release procedure #19

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,36 @@ Then, at the top of your `Rakefile`, add:
require 'voxpupuli-release'
```

To cut a new release of your module, ensure the `metadata.json` reflects the proper version. Also ensure that the `CHANGELOG.md` has a note about the release and that it actually is named Release or release, some old modules refer to it as Version, which won't work. Lastly check that no tag exists with that version number (format `v#.#.#`), and then run:
# Making a new release

## Preparations

First we prepare the release. Ensure you're on a clean branch. Also set ```CHANGELOG_GITHUB_TOKEN``` so you can generate the changelog without hitting rate limts.

```
bundle exec rake prepare_release[NEW_VERSION]
```

This will bump the version. You can either use `major`, `minor`, `patch` or specify a full version in the `X.Y.Z` format.

Next you commit this, push it to your remote and create a PR. The following code makes some assumptions about your layout:

```bash
VERSION="$(bundle exec rake module:version)"
git checkout -b release-$VERSION
git add metadata.json CHANGELOG.md
git commit -m "Release $VERSION"

# Push it to a remote that matches your username
git push $(whoami) HEAD -u

# Assumes you have hub installed
hub pull-request -m "Release $VERSION"
```

## Releasing

We'll assume that the preparation PR was acknowledged and merged.

```
bundle exec rake travis_release
Expand Down
64 changes: 47 additions & 17 deletions lib/voxpupuli/release/rake_tasks.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,57 @@
require 'github_changelog_generator/task'

desc 'Prepare a new release'
task :prepare_release, [:version] do |t, args|
unless args[:version]
puts 'you need to provide a version like: rake prepare_release[1.0.0]'
exit
end

version = args[:version]
if ['major', 'minor', 'patch'].include?(version)
bump_task = "module:bump:#{version}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch will need special treatment: Bumping version from 2.0.1-rc0 to 2.0.2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about allowing users to specify a specific version as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be supported in the elsif clause

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

voxpupuli/puppet-blacksmith#62 should handle the bumping issue.

elsif /^\d+\.\d+\.\d+$/.match(version)
bump_task = 'module:bump:full'
ENV['BLACKSMITH_FULL_VERSION'] = version
else
puts 'Version needs to be major, minor, patch or in the X.X.X format'
exit
end

Rake::Task[bump_task].invoke
Rake::Task['changelog'].invoke
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. The future version is read when the Rakefile is loaded, then bumped at runtime but not re-read.

end

desc 'release new version through Travis-ci'
task "travis_release" do
task "travis_release" => [:check_version, :check_changelog, 'module:clean'] do

require 'puppet_blacksmith/rake_tasks'
Blacksmith::RakeTask.new do |t|
t.build = false # do not build the module nor push it to the Forge
# just do the tagging [:clean, :tag, :bump_commit]
t.tag_message_pattern = "Version %s" # Use annotated commits
end

m = Blacksmith::Modulefile.new
v = m.version
raise "Refusing to release an RC or build-release (#{v}).\n" +
"Please set a semver *release* version." unless v =~ /^\d+\.\d+.\d+$/

Rake::Task[:check_changelog].invoke
# do a "manual" module:release (clean, tag, bump, commit, push tags)
Rake::Task["module:clean"].invoke

# idempotently create tags
m = Blacksmith::Modulefile.new
g = Blacksmith::Git.new
Rake::Task["module:tag"].invoke unless g.has_version_tag?(v)
Rake::Task["module:tag"].invoke unless g.has_version_tag?(m.version)

v_inc = m.increase_version(v)
v_new = "#{v_inc}-rc0"
# Bump to the next version as rc0
v_new = "#{m.increase_version(m.version)}-rc0"
ENV['BLACKSMITH_FULL_VERSION'] = v_new
Rake::Task["module:bump:full"].invoke
Rake::Task["module:bump_commit:full"].invoke

# push it out, and let travis do the release:
g.commit_modulefile!(v_new)
g.push!
end

desc 'Check if the version is a semver release version'
task :check_version do
m = Blacksmith::Modulefile.new
v = m.version
fail "Refusing to release an RC or build-release (#{v}).\n" +
"Please set a semver *release* version." unless v =~ /^\d+\.\d+.\d+$/
end

desc 'Check Changelog.'
task :check_changelog do
v = Blacksmith::Modulefile.new.version
Expand All @@ -42,3 +63,12 @@
fail "Unable to find a CHANGELOG.md entry for the #{v} release."
end
end

GitHubChangelogGenerator::RakeTask.new :changelog do |config|
modulefile = Blacksmith::Modulefile.new
config.user = 'voxpupuli'
config.project = modulefile.name
config.future_release = "v#{modulefile.version}" if modulefile.version =~ /^\d+\.\d+.\d+$/
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module."
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
end
2 changes: 2 additions & 0 deletions voxpupuli-release.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ Gem::Specification.new do |s|
# Runtime dependencies, but also probably dependencies of requiring projects
s.add_runtime_dependency 'rake'
s.add_runtime_dependency 'puppet-blacksmith', '>= 4.0.0'
# We actually want an unreleased version from it
s.add_runtime_dependency 'github_changelog_generator', '>= 1.14.0'
end