diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-05-30 23:50:48 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-05-31 00:26:07 -0600 |
| commit | 4a4f3c8951db7bb1a95f5368328d30b053616495 (patch) | |
| tree | 4f5b316b78cf805e6520b32551817e6230cfba05 | |
| parent | 760c4343ca73ffd170aa9a02bd8303385861ed4c (diff) | |
automate the creation of the GitHub release [no ci]
| -rw-r--r-- | .github/workflows/release.yml | 5 | ||||
| -rwxr-xr-x | release.sh | 2 | ||||
| -rw-r--r-- | tasks/release-notes.rb | 59 |
3 files changed, 66 insertions, 0 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27466aa0..eff086dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,10 @@ on: release-version: description: Enter version to release (e.g., 2.0.1). required: false + release-beer: + default: TBD + description: Enter beer to mark the occasion. + required: false jobs: activate: runs-on: ubuntu-latest @@ -45,6 +49,7 @@ jobs: - name: Setup release environment run: | echo RELEASE_VERSION=${{ github.event.inputs.release-version }} >> $GITHUB_ENV + echo RELEASE_BEER=${{ github.event.inputs.release-beer }} >> $GITHUB_ENV echo RELEASE_RUBYGEMS_API_KEY=${{ secrets[format('RUBYGEMS_API_KEY_{0}', github.actor)] }} >> $GITHUB_ENV - name: Build, tag, and publish gem run: ./release.sh @@ -36,6 +36,8 @@ chmod 600 $HOME/.gem/credentials git push origin $(git describe --tags --exact-match) gem push $RELEASE_NAME-$RELEASE_VERSION.gem git push origin $RELEASE_BRANCH + ruby tasks/release-notes.rb + gh release create v$RELEASE_VERSION -F release-notes.md -d ) exit_code=$? diff --git a/tasks/release-notes.rb b/tasks/release-notes.rb new file mode 100644 index 00000000..6bd637c3 --- /dev/null +++ b/tasks/release-notes.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +require 'time' + +old_tz, ENV['TZ'] = ENV['TZ'], 'US/Mountain' +release_date = Time.now.strftime '%Y-%m-%d' +ENV['TZ'] = old_tz + +spec = Gem::Specification.load Dir['*.gemspec'].first +gem_name = spec.name +gem_version = spec.version +gem_dist_url = %(https://rubygems.org/gems/#{gem_name}) +release_actor = ENV['GITHUB_ACTOR'] || 'mojavelinux' +release_beer = ENV['RELEASE_BEER'] || 'TBD' +release_tag = %(v#{gem_version}) +previous_tag = (`git tag -l --sort -taggerdate`.each_line chomp: true) + .drop_while {|it| it != release_tag } + .reject {|it| it == release_tag } + .find {|it| (Gem::Version.new it.slice 1, it.length) < gem_version } +issues_url = spec.metadata['bug_tracker_uri'] +repo_url = spec.metadata['source_code_uri'] +changelog = (File.readlines 'CHANGELOG.adoc', chomp: true, mode: 'r:UTF-8').reduce nil do |accum, line| + if line == '=== Details' + accum.pop + break accum.join ?\n + elsif accum + line = %(### #{line.slice 0, line.length - 2}) if line.end_with? '::' + accum << line unless accum.empty? && line.empty? + elsif line.start_with? %(== #{gem_version} ) + accum = [] + end + accum +end + +notes = <<~EOS +Write summary... + +## Distribution + +- [RubyGem (#{gem_name})](#{gem_dist_url}) + +## Changelog + +#{changelog} + +## Release meta + +Released on: #{release_date} +Released by: @#{release_actor} +Release beer: #{release_beer} + +Logs: [resolved issues](#{issues_url}?q=is%3Aissue+label%3A#{release_tag}+is%3Aclosed) | [full diff](#{repo_url}/compare/#{previous_tag}...#{release_tag}) + +## Credits + +A very special thanks to all the **awesome** [supporters of the Asciidoctor OpenCollective campaign](https://opencollective.com/asciidoctor), who provide critical funding for the ongoing development of this project. +EOS + +File.write 'release-notes.md', notes, mode: 'w:UTF-8' |
