Skip to content

Commit 5c22630

Browse files
committed
Release using RubyGems Trusted Publishing
1 parent 5459abb commit 5c22630

3 files changed

Lines changed: 14 additions & 22 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
steps:
2525
- name: Checkout code
2626
if: github.event_name == 'push'
27-
uses: actions/checkout@v4
27+
uses: actions/checkout@v5
28+
with:
29+
persist-credentials: false
2830

2931
- name: Checkout PR code
3032
if: github.event_name == 'pull_request_target'
@@ -50,7 +52,9 @@ jobs:
5052
steps:
5153
- name: Checkout code
5254
if: github.event_name == 'push'
53-
uses: actions/checkout@v4
55+
uses: actions/checkout@v5
56+
with:
57+
persist-credentials: false
5458

5559
- name: Checkout PR code
5660
if: github.event_name == 'pull_request_target'
@@ -69,4 +73,4 @@ jobs:
6973
run: bundle exec standardrb
7074

7175
- name: Build gem
72-
run: gem build daemon_controller.gemspec
76+
run: bundle exec rake release

.github/workflows/release.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ jobs:
1616
attestations: write
1717
steps:
1818
- name: Checkout code
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
20+
with:
21+
persist-credentials: false
2022

2123
- name: Set up Ruby
2224
uses: ruby/setup-ruby@v1
@@ -37,19 +39,13 @@ jobs:
3739
exit 1
3840
fi
3941
40-
- name: Build gem
41-
run: gem build daemon_controller.gemspec
42+
- uses: rubygems/release-gem@v1
4243

4344
- name: Create attestation
4445
uses: actions/attest-build-provenance@v2
4546
with:
4647
subject-path: "daemon_controller-*.gem"
4748

48-
- name: Push gem to RubyGems
49-
run: gem push daemon_controller-*.gem
50-
env:
51-
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
52-
5349
- name: Create GitHub release
5450
run: gh release create "$GITHUB_REF_NAME" *.gem --title "$GITHUB_REF_NAME" --notes-from-tag
5551
env:

Rakefile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ task :test do
88
ruby "-S rspec spec/*_spec.rb"
99
end
1010

11-
desc "Build & upload gem"
12-
task "package:release" do
13-
sh "git tag -s release-#{PACKAGE_VERSION}"
14-
sh "gem build #{PACKAGE_NAME}.gemspec"
15-
puts "Proceed with pushing tag to Github and uploading the gem? [y/n]"
16-
if $stdin.readline == "y\n"
17-
sh "git push origin release-#{PACKAGE_VERSION}"
18-
sh "gem push #{PACKAGE_NAME}-#{PACKAGE_VERSION}.gem"
19-
else
20-
puts "Did not upload the gem."
21-
end
11+
desc "Build release artifacts"
12+
task :release do
13+
sh "gem build daemon_controller.gemspec"
2214
end

0 commit comments

Comments
 (0)