From 2069bc39d2d2d8eb770385f6f398e3e20d7a258a Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Tue, 19 Dec 2023 11:45:10 +1000 Subject: [PATCH] Use github release notes generator for changelogs Signed-off-by: Jimmy Tanagra --- .github/release.yml | 11 ++++++ .github/workflows/release.yml | 46 ++++++++++++------------ Gemfile.lock | 67 ----------------------------------- openhab-scripting.gemspec | 1 - rakelib/changelog.rake | 29 +++------------ 5 files changed, 39 insertions(+), 115 deletions(-) create mode 100644 .github/release.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000000..63fc7c1131 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,11 @@ +changelog: + categories: + - title: Breaking Changes + labels: + - breaking + - title: Features + labels: + - enhancement + - title: Bug Fixes + labels: + - bug diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2282b72d45..3bf92282d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,31 +47,33 @@ jobs: ruby -Ilib/openhab/dsl -r version -e 'puts "new_version=#{OpenHAB::DSL::VERSION}"' >> $GITHUB_OUTPUT - name: Generate CHANGELOG env: - CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }} run: | bin/rake update_doc_links[${{ env.OLD_VERSION }},${{ env.NEW_VERSION }}] + + gh release create v${{ env.NEW_VERSION }} --generate-notes --draft + gh release view v${{ env.NEW_VERSION }} --json body | jq -r .body | sed '1,3d' > tmp/new_changes.md + gh release delete v${{ env.NEW_VERSION }} --cleanup-tag --yes` + bin/rake changelog[${{ env.OLD_VERSION }},${{ env.NEW_VERSION }},tmp/new_changes.md] git add Gemfile.lock CHANGELOG.md USAGE.md templates .known_good_references - - name: Release Gem - env: - GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} - run: | git commit --amend --no-edit - bin/rake release || (git status; false) - - name: Create Github Release - env: - GH_TOKEN: ${{ github.token }} - run: | gh release create v${{ env.NEW_VERSION }} --notes-file tmp/new_changes.md - publish_main_docs: - needs: release - uses: ./.github/workflows/yardoc.yml - with: - ref_name: main - ref_type: branch - publish_tag_docs: - needs: release - uses: ./.github/workflows/yardoc.yml - with: - ref_name: v${{needs.release.outputs.NEW_VERSION}} - ref_type: tag + + # - name: Release Gem + # env: + # GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} + # run: | + # bin/rake release || (git status; false) + # publish_main_docs: + # needs: release + # uses: ./.github/workflows/yardoc.yml + # with: + # ref_name: main + # ref_type: branch + # publish_tag_docs: + # needs: release + # uses: ./.github/workflows/yardoc.yml + # with: + # ref_name: v${{needs.release.outputs.NEW_VERSION}} + # ref_type: tag diff --git a/Gemfile.lock b/Gemfile.lock index ee8a44f152..60e34ab17c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,41 +18,12 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.1.7.6) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.5) - public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - async (1.31.0) - console (~> 1.10) - nio4r (~> 2.3) - timers (~> 4.1) - async-http (0.59.5) - async (>= 1.25) - async-io (>= 1.28) - async-pool (>= 0.2) - protocol-http (~> 0.23) - protocol-http1 (~> 0.14.0) - protocol-http2 (~> 0.14.0) - traces (>= 0.8.0) - async-http-faraday (0.12.0) - async-http (~> 0.42) - faraday - async-io (1.35.0) - async - async-pool (0.4.0) - async (>= 1.25) builder (3.2.4) byebug (11.1.3) coderay (1.1.3) commonmarker (0.23.10) concurrent-ruby (1.2.2) - console (1.15.3) - fiber-local cucumber (8.0.0) builder (~> 3.2, >= 3.2.4) cucumber-ci-environment (~> 9.0, >= 9.0.4) @@ -88,27 +59,15 @@ GEM faraday (2.7.10) faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) - faraday-http-cache (2.5.0) - faraday (>= 0.8) faraday-net_http (3.0.2) faraday-retry (2.2.0) faraday (~> 2.0) ffi (1.15.5) ffi (1.15.5-java) - fiber-local (1.0.0) formatador (1.1.0) gem-release (2.2.2) gene_pool (1.5.0) concurrent-ruby (>= 1.0) - github_changelog_generator (1.16.4) - activesupport - async (>= 1.25.0) - async-http-faraday - faraday-http-cache - multi_json - octokit (~> 4.6) - rainbow (>= 2.2.1) - rake (>= 10.0) guard (2.18.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -131,8 +90,6 @@ GEM httparty (0.21.0) mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) - i18n (1.14.1) - concurrent-ruby (~> 1.0) io-console (0.6.0) io-console (0.6.0-java) irb (1.6.3) @@ -149,13 +106,9 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2023.0808) mini_mime (1.1.5) - minitest (5.20.0) - multi_json (1.15.0) multi_test (1.1.0) multi_xml (0.6.0) nenv (0.3.0) - nio4r (2.5.9) - nio4r (2.5.9-java) nokogiri (1.13.10-arm64-darwin) racc (~> 1.4) nokogiri (1.13.10-java) @@ -167,9 +120,6 @@ GEM notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - octokit (4.25.1) - faraday (>= 1, < 3) - sawyer (~> 0.9) parallel (1.23.0) parser (3.2.2.3) ast (~> 2.4.1) @@ -182,13 +132,6 @@ GEM httparty (~> 0.9) persistent_http (< 2) process_exists (0.2.0) - protocol-hpack (1.4.2) - protocol-http (0.24.4) - protocol-http1 (0.14.6) - protocol-http (~> 0.22) - protocol-http2 (0.14.2) - protocol-hpack (~> 1.4) - protocol-http (~> 0.18) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -196,7 +139,6 @@ GEM coderay (~> 1.1) method_source (~> 1.0) spoon (~> 0.0) - public_suffix (5.0.3) racc (1.7.1) racc (1.7.1-java) rack (2.2.8) @@ -249,9 +191,6 @@ GEM rubocop-capybara (~> 2.17) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) - sawyer (0.9.2) - addressable (>= 2.3.5) - faraday (>= 0.17.3, < 3) shellany (0.0.1) spoon (0.0.6) ffi @@ -263,17 +202,12 @@ GEM rack (>= 1, < 3) thor (1.2.2) timecop (0.9.8) - timers (4.3.5) - traces (0.11.1) tty-color (0.6.0) tty-command (0.10.1) pastel (~> 0.8) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) unicode-display_width (2.4.2) webrick (1.7.0) yaml-lint (0.1.2) - zeitwerk (2.6.11) PLATFORMS arm64-darwin-21 @@ -290,7 +224,6 @@ DEPENDENCIES cuke_linter (~> 1.2) faraday-retry (~> 2.1) gem-release (~> 2.2) - github_changelog_generator (~> 1.16) guard-rubocop (~> 1.5) guard-shell (~> 0.7) guard-yard (~> 2.2) diff --git a/openhab-scripting.gemspec b/openhab-scripting.gemspec index 6cc1b41e50..2cabad83d2 100644 --- a/openhab-scripting.gemspec +++ b/openhab-scripting.gemspec @@ -30,7 +30,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency "cuke_linter", "~> 1.2" spec.add_development_dependency "faraday-retry", "~> 2.1" spec.add_development_dependency "gem-release", "~> 2.2" - spec.add_development_dependency "github_changelog_generator", "~> 1.16" spec.add_development_dependency "guard-rubocop", "~> 1.5" spec.add_development_dependency "guard-shell", "~> 0.7" spec.add_development_dependency "guard-yard", "~> 2.2" diff --git a/rakelib/changelog.rake b/rakelib/changelog.rake index 8c0991b44a..63f3d6fcc1 100644 --- a/rakelib/changelog.rake +++ b/rakelib/changelog.rake @@ -1,16 +1,5 @@ # frozen_string_literal: true -require "github_changelog_generator/task" - -module GitHubChangelogGenerator - class Generator - # Don't add any header or footer - def insert_fixed_string(log) - log - end - end -end - directory "tmp" desc "Generate Changelog" @@ -20,21 +9,11 @@ task :changelog, %i[old_version new_version output] => ["tmp"] do |_task, args| raise ArgumentError, "old_version, new_version, and output arguments must be specified" end - GitHubChangelogGenerator::RakeTask.new :new_changelog do |config| - config.user = "openhab" - config.project = "openhab-jruby" - config.since_tag = "v#{old_version}" - config.future_release = "v#{new_version}" - config.bug_prefix = "### Bug Fixes" - config.enhancement_prefix = "### Features" - config.issues = true - config.add_pr_wo_labels = false - config.add_issues_wo_labels = false - config.exclude_labels = ["documentation"] - config.output = new_filename - end + today = Time.now.strftime("%Y-%m-%d") + header = "## [v#{new_version}](https://github.com/openhab/openhab-jruby/tree/v#{new_version}) (#{today})\n\n" - Rake::Task["new_changelog"].execute + release_notes = File.read(new_filename) + File.write(new_filename, "#{header}\n\n#{release_notes}") insert_new_changelog(new_filename, main_filename: "CHANGELOG.md") end