-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from rubocop/trusted-publishing
Use Rubygems Trusted Publishers to publish
- Loading branch information
Showing
3 changed files
with
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: master | ||
paths: lib/rubocop/rspec/version.rb | ||
jobs: | ||
publish: | ||
name: Publish to RubyGems | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
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 @) \ | ||
--title "RuboCop RSpec $(git tag --points-at @)" \ | ||
--notes-file relnotes.md | ||
- name: Replace version in Antora config | ||
run: | | ||
sed -i 's/version:.*$/version: ~/' docs/antora.yml | ||
if ! git diff --exit-code docs/antora.yml; then | ||
git config user.name "${GITHUB_ACTOR}" | ||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
git checkout -b switch-docs-version | ||
git add docs/antora.yml | ||
git commit -m "Switch docs version back" | ||
git push -u origin switch-docs-version | ||
gh pr create --fill --head switch-docs-version | ||
fi |
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 |