Skip to content
Merged
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
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 21 additions & 14 deletions rakelib/changelogs.rake
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
# 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("..")
IO.popen(%W[git log --format=fuller --topo-order --no-merges #{range}]) do |log|
line = log.gets
cmd = %W[git log --date=iso --format=fuller --topo-order --no-merges
--invert-grep --fixed-strings --grep=#{'[ci skip]'} -z
#{range} --]
IO.popen(cmd) do |log|
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
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"
Expand Down