Skip to content

Commit 4c5a846

Browse files
committed
Switch gem push workflow to OIDC trusted publishing
1 parent 988106b commit 4c5a846

2 files changed

Lines changed: 61 additions & 39 deletions

File tree

.github/workflows/gem_push.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
name: Push Gem
3+
4+
"on":
5+
push:
6+
tags:
7+
- v*
8+
9+
jobs:
10+
push:
11+
if: github.repository == 'httprb/form_data'
12+
runs-on: ubuntu-latest
13+
14+
environment:
15+
name: rubygems.org
16+
url: https://rubygems.org/gems/http-form_data
17+
18+
permissions:
19+
contents: write
20+
id-token: write
21+
22+
steps:
23+
- uses: rubygems/configure-rubygems-credentials@main
24+
with:
25+
role-to-assume: rg_oidc_akr_3rf8drvjr69qfcx7ztf5
26+
27+
- uses: actions/checkout@v6
28+
with:
29+
persist-credentials: false
30+
31+
- name: Set remote URL
32+
run: |
33+
# Attribute commits to the last committer on HEAD
34+
git config --global user.email "$(git log -1 --pretty=format:'%ae')"
35+
git config --global user.name "$(git log -1 --pretty=format:'%an')"
36+
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY"
37+
38+
- uses: ruby/setup-ruby@v1
39+
with:
40+
ruby-version: ruby
41+
bundler-cache: true
42+
43+
- name: Release
44+
run: bundle exec rake release
45+
46+
- name: Wait for release to propagate
47+
run: |
48+
gem install rubygems-await
49+
gem_tuple="$(ruby -rbundler/setup -rbundler -e '
50+
spec = Bundler.definition.specs.find {|s| s.name == ARGV[0] }
51+
raise "No spec for #{ARGV[0]}" unless spec
52+
print [spec.name, spec.version, spec.platform].join(":")
53+
' "http-form_data")"
54+
gem await "${gem_tuple}"
55+
56+
- name: Create GitHub release
57+
run: |
58+
tag_name="$(git describe --tags --abbrev=0)"
59+
gh release create "${tag_name}" --verify-tag --generate-notes
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/push.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)