File: release-notes.rb

package info (click to toggle)
ruby-asciidoctor-pdf 2.3.19-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,972 kB
  • sloc: ruby: 44,316; sh: 133; java: 45; makefile: 4
file content (65 lines) | stat: -rw-r--r-- 2,176 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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_notes_file = 'pkg/release-notes.md'
release_user = ENV['RELEASE_USER'] || 'mojavelinux'
release_beer = ENV['RELEASE_BEER'] || 'TBD'
release_tag = %(v#{gem_version})
previous_tag = (`git -c versionsort.suffix=. -c versionsort.suffix=- ls-remote --tags --refs --sort -v:refname origin`.each_line chomp: true)
  .map {|it| (it.rpartition '/')[-1] }
  .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
    if line.end_with? '::'
      line = %(### #{line.slice 0, line.length - 2})
    elsif line.start_with? '  * '
      line = line.lstrip
    end
    accum << line unless accum.empty? && line.empty?
  elsif line.start_with? %(== #{gem_version} )
    accum = []
  end
  accum
end

release_notes = <<~EOS.chomp
Write summary...

## Distribution

- [RubyGem (#{gem_name})](#{gem_dist_url})

## Changelog

#{changelog}

## Release meta

Released on: #{release_date}
Released by: @#{release_user}
Release beer: #{release_beer}

Logs: [resolved issues](#{issues_url}?q=is%3Aissue+label%3A#{release_tag}+is%3Aclosed)#{previous_tag ? %( | [source diff](#{repo_url}/compare/#{previous_tag}...#{release_tag}) | [gem diff](https://my.diffend.io/gems/asciidoctor/#{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_file, release_notes, mode: 'w:UTF-8'