Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate release notes #1897

Merged
merged 24 commits into from
Mar 27, 2023
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
67 changes: 67 additions & 0 deletions .github/workflows/scripts/generate_release_notes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/ruby
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require 'date'
require_relative '../../../lib/new_relic/version'

class GenerateReleaseNotes
DIVIDER = '---'
SUPPORT_STATEMENT = <<~SUPPORT_STATEMENT
<Callout variant="important">
We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version at most 90 days old. Read more about [keeping agents up to date](/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/).

See the New Relic Ruby agent [EOL policy](https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-eol-policy/) for information about agent releases and support dates.
</Callout>
SUPPORT_STATEMENT

def build_metadata
changelog = File.read('CHANGELOG.md')
latest_entry = changelog.split('##')[1].prepend('##')
titles = latest_entry.scan(/^- \*{2}(.*?)\*{2}$/).flatten # Match strings between sets of '**'
metadata = Hash.new { |h, k| h[k] = [] }

titles.each do |t|
category = t.split(':').first
case category
when 'Feature'
metadata[:features] << t.delete_prefix('Feature: ')
when 'Bugfix'
metadata[:bugs] << t.delete_prefix('Bugfix: ')
when 'Security'
metadata[:security] << t.delete_prefix('Security: ')
end
end

return metadata, latest_entry
end

def build_release_content
metadata, latest_entry = build_metadata
frontmatter = <<~FRONTMATTER
hannahramadan marked this conversation as resolved.
Show resolved Hide resolved
#{DIVIDER}
subject: Ruby agent
date: #{Date.today}
version: #{NewRelic::VERSION::STRING}
downloadLink: https://rubygems.org/downloads/newrelic_rpm-#{NewRelic::VERSION::STRING}.gem
features: #{metadata[:features]}
bugs: #{metadata[:bugs]}
security: #{metadata[:security]}
#{DIVIDER}

#{SUPPORT_STATEMENT}
#{latest_entry}
FRONTMATTER
end

def write_filename
"ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx"
end

def write_output_file
File.write(write_filename, build_release_content)
end
end

GenerateReleaseNotes.new.write_output_file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the only method ever being invoked from outside of the class itself is write_output_file, you can have that method be public and all the others be private.