Skip to content

Commit c3150f5

Browse files
authored
Release herb gem via trusted publishing (#532)
Following up on our discussion. This should do it. What is also needed is: - add deployment env to your repo settings - configure truste publidhing in rubygems Please note I do not have a way to test it. I made it based on my: https://github.com/karafka/rdkafka-ruby/blob/main/.github/workflows/push_linux_x86_64_gnu.yml
1 parent a492b8c commit c3150f5

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/build-gems.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,68 @@ jobs:
100100
path: pkg/*.gem
101101
if-no-files-found: error
102102
retention-days: 7
103+
104+
push:
105+
name: Push gems with trusted publishing
106+
if: github.event_name == 'release' && github.repository_owner == 'marcoroth'
107+
needs: build
108+
timeout-minutes: 30
109+
runs-on: ubuntu-latest
110+
permissions:
111+
contents: write
112+
id-token: write
113+
strategy:
114+
fail-fast: false
115+
matrix:
116+
target:
117+
- default
118+
- aarch64-linux-gnu
119+
- x86_64-linux-gnu
120+
- x86_64-linux-musl
121+
- aarch64-linux-musl
122+
- x86_64-darwin
123+
- arm64-darwin
124+
- arm-linux-gnu
125+
- arm-linux-musl
126+
- x86-linux-gnu
127+
- x86-linux-musl
128+
steps:
129+
- uses: actions/checkout@v4
130+
with:
131+
fetch-depth: 0
132+
133+
# Vendor the attestation patch from rubygems/release-gem
134+
- name: Vendor release-gem patch
135+
uses: actions/checkout@v4
136+
with:
137+
repository: rubygems/release-gem
138+
ref: a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
139+
path: .github/_release-gem
140+
141+
- name: Setup Ruby
142+
uses: ruby/setup-ruby@v1
143+
with:
144+
ruby-version: '3.4'
145+
bundler-cache: false
146+
147+
- name: Download gem artifacts
148+
uses: actions/download-artifact@v4
149+
with:
150+
name: gem-${{ matrix.target }}
151+
path: pkg/
152+
153+
- name: Configure trusted publishing credentials
154+
uses: rubygems/configure-rubygems-credentials@v1.0.0
155+
156+
- name: Push gem with Sigstore attestation
157+
env:
158+
# Preload the attestation patch so `gem push` generates & attaches the bundle
159+
RUBYOPT: "-r${{ github.workspace }}/.github/_release-gem/rubygems-attestation-patch.rb"
160+
run: |
161+
cd pkg
162+
for gem_file in *.gem; do
163+
if [ -f "$gem_file" ]; then
164+
echo "Pushing $gem_file"
165+
gem push "$gem_file"
166+
fi
167+
done

0 commit comments

Comments
 (0)