From 196a4eeb73046097cec49bde74c1a32b6a0f975b Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 18 Dec 2017 19:24:18 +0100 Subject: [PATCH 1/4] Add a prepare_release Based on code by @bastelfreak --- lib/voxpupuli/release/rake_tasks.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/voxpupuli/release/rake_tasks.rb b/lib/voxpupuli/release/rake_tasks.rb index 70bb8b2..ff975cb 100644 --- a/lib/voxpupuli/release/rake_tasks.rb +++ b/lib/voxpupuli/release/rake_tasks.rb @@ -1,3 +1,24 @@ +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}" + 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 +end desc 'release new version through Travis-ci' task "travis_release" do From ac9a18275e0a1103a32b5055e9c4c8b396ad2575 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 18 Dec 2017 19:38:44 +0100 Subject: [PATCH 2/4] Add the changelog task --- lib/voxpupuli/release/rake_tasks.rb | 11 +++++++++++ voxpupuli-release.gemspec | 2 ++ 2 files changed, 13 insertions(+) diff --git a/lib/voxpupuli/release/rake_tasks.rb b/lib/voxpupuli/release/rake_tasks.rb index ff975cb..a0de02f 100644 --- a/lib/voxpupuli/release/rake_tasks.rb +++ b/lib/voxpupuli/release/rake_tasks.rb @@ -1,3 +1,5 @@ +require 'github_changelog_generator/task' + desc 'Prepare a new release' task :prepare_release, [:version] do |t, args| unless args[:version] @@ -63,3 +65,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 diff --git a/voxpupuli-release.gemspec b/voxpupuli-release.gemspec index e51a5a4..0b4c703 100644 --- a/voxpupuli-release.gemspec +++ b/voxpupuli-release.gemspec @@ -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 From b35c761a24f5da2a55d549d86959b8d5fa269477 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 18 Dec 2017 20:02:00 +0100 Subject: [PATCH 3/4] Update release documentation --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ab0bc8d..9c57a69 100644 --- a/README.md +++ b/README.md @@ -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 From 67163c24d4c979b7676f0f2ddee9af235499315b Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 18 Dec 2017 20:20:14 +0100 Subject: [PATCH 4/4] Update release steps --- lib/voxpupuli/release/rake_tasks.rb | 32 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/voxpupuli/release/rake_tasks.rb b/lib/voxpupuli/release/rake_tasks.rb index a0de02f..d8453d3 100644 --- a/lib/voxpupuli/release/rake_tasks.rb +++ b/lib/voxpupuli/release/rake_tasks.rb @@ -23,37 +23,35 @@ 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