Skip to content

Commit f0c1d2e

Browse files
jeffwidmanNishnha
andauthored
Add sigstore attestations for our published gems (#12025)
This adds sigstore attestations for our published gems. We do not need to provide an OIDC token to the sigstore client because by default it will request the token from the GitHub Actions environment: https://github.com/sigstore/sigstore-ruby/blob/9ac72d3c27edcd791c8c831316447f0ab7dfb407/cli/lib/sigstore/cli/id_token.rb#L45-L68 The code inspiration for this change came from: * 84codes/rubocop-eightyfourcodes#16 * rubygems/release-gem#11 You can see an example of how this attestation will look on RubyGems here: https://rubygems.org/gems/sigstore/versions/0.2.1 Co-authored-by: Nish Sinha <nishnha@github.com>
1 parent a7c610f commit f0c1d2e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.github/workflows/gems-release-to-rubygems.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323

2424
# We can't use the https://github.com/rubygems/release-gem workflow because it calls `rake release` rather than `rake gems:release`.
2525
# `rake release` causes problems because it tries to push a git tag, but we've already manually tagged the release as part of the `gems-bump-version` workflow.
26-
- run: gem install rake && rake gems:release
26+
- run: gem exec rake gems:release

Rakefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ namespace :gems do
6868

6969
GEMSPECS.each do |gemspec_path|
7070
gem_name = File.basename(gemspec_path).sub(/\.gemspec$/, "")
71-
gem_path = "pkg/#{gem_name}-#{Dependabot::VERSION}.gem"
71+
gem_name_and_version = "#{gem_name}-#{Dependabot::VERSION}"
72+
gem_path = "pkg/#{gem_name_and_version}.gem"
73+
gem_attestation_path = "pkg/#{gem_name_and_version}.sigstore.json"
7274

7375
attempts = 0
7476
loop do
@@ -80,7 +82,8 @@ namespace :gems do
8082
attempts += 1
8183
sleep(2)
8284
begin
83-
sh "gem push #{gem_path}"
85+
sh "gem exec sigstore-cli:0.2.1 sign #{gem_path} --bundle #{gem_attestation_path}"
86+
sh "gem push #{gem_path} --attestation #{gem_attestation_path}"
8487
break
8588
rescue StandardError => e
8689
puts "! `gem push` failed with error: #{e}"
@@ -92,7 +95,7 @@ namespace :gems do
9295
end
9396

9497
task :clean do
95-
FileUtils.rm(Dir["pkg/*.gem"])
98+
FileUtils.rm(Dir["pkg/*.gem", "pkg/*.sigstore.json"])
9699
end
97100
end
98101

0 commit comments

Comments
 (0)