From 8d33e4c6f6c7dc46c308219d940707a1e61d3727 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 17 Apr 2024 09:31:33 +0900 Subject: [PATCH 1/3] [DOC] Update changelogse.rake - Exclude CI-skipped commits from changelogs - Make timestamps in a ISO 8601-like format --- rakelib/changelogs.rake | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/rakelib/changelogs.rake b/rakelib/changelogs.rake index a4eb83f..5e00c98 100644 --- a/rakelib/changelogs.rake +++ b/rakelib/changelogs.rake @@ -3,7 +3,10 @@ task "build" => "changelogs" changelog = proc do |output, ver = nil, prev = nil| ver &&= Gem::Version.new(ver) range = [[prev], [ver, "HEAD"]].map {|ver, branch| ver ? "v#{ver.to_s}" : branch}.compact.join("..") - IO.popen(%W[git log --format=fuller --topo-order --no-merges #{range}]) do |log| + cmd = %W[git log --date=iso --format=fuller --topo-order --no-merges + --invert-grep --fixed-strings --grep=#{'[ci skip]'} + #{range} --] + IO.popen(cmd) do |log| line = log.gets FileUtils.mkpath(File.dirname(output)) File.open(output, "wb") do |f| @@ -18,13 +21,13 @@ changelog = proc do |output, ver = nil, prev = nil| end tags = IO.popen(%w[git tag -l v[0-9]*]).grep(/v(.*)/) {$1} -tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)} -if !tags.empty? and IO.popen(%W[git log --format=%H v#{tags.last}..HEAD], &:read).empty? - tags.pop -end -tags.inject(nil) do |prev, tag| - task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]} - tag +unless tags.empty? + tags.sort_by! {|tag| tag.scan(/\d+/).map(&:to_i)} + tags.pop if IO.popen(%W[git log --format=%H v#{tags.last}..HEAD --], &:read).empty? + tags.inject(nil) do |prev, tag| + task("logs/ChangeLog-#{tag}") {|t| changelog[t.name, tag, prev]} + tag + end end desc "Make ChangeLog" From 445c9cd650e914c9a9a78b4ddbbd82a870ccdecd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 17 Apr 2024 09:59:48 +0900 Subject: [PATCH 2/3] [DOC] Exclude commits by bots from ChangeLogs --- rakelib/changelogs.rake | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rakelib/changelogs.rake b/rakelib/changelogs.rake index 5e00c98..d8daac6 100644 --- a/rakelib/changelogs.rake +++ b/rakelib/changelogs.rake @@ -1,20 +1,24 @@ +# Requires >= ruby 2.4, for `each(chomp: true)` + task "build" => "changelogs" changelog = proc do |output, ver = nil, prev = nil| ver &&= Gem::Version.new(ver) range = [[prev], [ver, "HEAD"]].map {|ver, branch| ver ? "v#{ver.to_s}" : branch}.compact.join("..") cmd = %W[git log --date=iso --format=fuller --topo-order --no-merges - --invert-grep --fixed-strings --grep=#{'[ci skip]'} + --invert-grep --fixed-strings --grep=#{'[ci skip]'} -z #{range} --] IO.popen(cmd) do |log| - line = log.gets + break unless c = log.read(1) + log.ungetbyte(c) FileUtils.mkpath(File.dirname(output)) File.open(output, "wb") do |f| - f.print "-*- coding: utf-8 -*-\n\n", line - log.each_line do |line| - line.sub!(/^(?!:)(?:Author|Commit)?(?:Date)?: /, ' \&') - line.sub!(/ +$/, '') - f.print(line) + f.print "-*- coding: utf-8 -*-\n" + log.each("\0", chomp: true) do |line| + next if /^Author: *\[bot\]@users\.noreply\.github\.com>/ =~ line + line.gsub!(/^(?!:)(?:Author|Commit)?(?:Date)?: /, ' \&') + line.gsub!(/ +$/, '') + f.print("\n", line) end end end From c8e0baf9836f160607d9b01464e25275e5b750c9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 17 Apr 2024 10:04:23 +0900 Subject: [PATCH 3/3] [DOC] Fetch deeper for changelogs --- .github/workflows/test.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ea97e7..e569b2e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,14 +33,23 @@ jobs: bundler-cache: true - name: Run test run: bundle exec rake compile test - - id: build + - id: fetch run: | + : Fetch deeper for changelogs + set -x git fetch --force --no-tags origin 'refs/tags/v*:refs/tags/v*' + tags=($(git tag --list --no-contains HEAD --sort -version:refname)) + git fetch --shallow-exclude=${tags[0]} origin + set +x + shell: bash + if: ${{ matrix.ruby == needs.ruby-versions.outputs.latest }} + - id: build + run: | bundle exec rake build echo "pkg=${GITHUB_REPOSITORY#*/}-${RUNNING_OS%-*}" >> $GITHUB_OUTPUT env: RUNNING_OS: ${{matrix.os}} - if: ${{ matrix.ruby == fromJson(needs.ruby-versions.outputs.latest) }} + if: ${{ steps.fetch.outcome == 'success' }} shell: bash # Ubuntu 20.04 still has libyaml 0.2.2 - name: Upload package