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

Automatically create release notes #1859

Merged
merged 1 commit into from
Apr 4, 2024
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
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
bundler-cache: true
ruby-version: ruby
- uses: rubygems/release-gem@v1
- name: Create a GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
bundle exec rake create_release_notes
gh release create $(git tag --points-at @) --notes-file relnotes.md
Copy link
Member

Choose a reason for hiding this comment

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

ask) Should we need to create a release version tag before this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. It’s created and pushed by line 20. And also, it should run before the git push below which would cause git tag --points-at @ to no longer return the current tag 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Thank ypu for the explanation! I understand😀

- name: Replace version in Antora config
run: |
sed -i 's/version:.*$/version: ~/' docs/antora.yml
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ coverage

# vscode generated
.vscode

/relnotes.md
34 changes: 34 additions & 0 deletions tasks/create_release_notes.rake
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