-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create GH release with notes on CI gem publishing
Adds a new rake task, `rake create_release_notes` which generates a relnotes.md file. When CI creates and publishes a new gem version, it will now also create a release on GitHub, with the content of relnotes.md being used as release notes.
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ coverage | |
|
||
# vscode generated | ||
.vscode | ||
|
||
/relnotes.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
desc 'Create release notes for the most recent version.' | ||
task :create_release_notes do | ||
CreateReleaseNotes.call | ||
end | ||
|
||
# Create release notes from the most recent version in the CHANGELOG.md file. | ||
module CreateReleaseNotes | ||
module_function | ||
|
||
def call | ||
release_notes = new_version_changes.strip | ||
contributor_links = user_links(release_notes) | ||
|
||
File.open('relnotes.md', 'w') do |file| | ||
file << release_notes | ||
file << "\n\n" | ||
file << contributor_links | ||
file << "\n" | ||
end | ||
end | ||
|
||
def new_version_changes | ||
changelog = File.read('CHANGELOG.md') | ||
_, _, new_changes, _older_changes = changelog.split(/^## .*$/, 4) | ||
new_changes | ||
end | ||
|
||
def user_links(text) | ||
names = text.scan(/\[@(\S+)\]/).map(&:first).uniq.sort | ||
names.map { |name| "[@#{name}]: https://github.com/#{name}" }.join("\n") | ||
end | ||
end |