Skip to content

Commit 8097c02

Browse files
authored
ci: use oidc publishing (#260)
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
1 parent 1817ac8 commit 8097c02

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

.github/workflows/gem-release.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ on:
99
type: string
1010

1111
name: Publish Gem
12+
1213
permissions:
1314
contents: read
15+
id-token: write
16+
1417
jobs:
1518
gem-release:
1619
runs-on: ubuntu-latest
@@ -20,17 +23,17 @@ jobs:
2023
with:
2124
ref: ${{ github.event.release.tag_name || inputs.tag }}
2225

23-
- uses: ruby/setup-ruby@v1
26+
- uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1.300.0
2427
- run: bundle install
2528

26-
- name: Release Gem
29+
- name: Build Gem
2730
run: |
28-
bundle config unset deployment
29-
mkdir -p $HOME/.gem
30-
touch $HOME/.gem/credentials
31-
chmod 0600 $HOME/.gem/credentials
32-
printf -- "---\n:rubygems_api_key: ${RUBY_GEM_API_TOKEN}\n" > $HOME/.gem/credentials
33-
gem build *.gemspec
34-
gem push *.gem
35-
env:
36-
RUBY_GEM_API_TOKEN: "${{secrets.RUBY_GEM_API_TOKEN}}"
31+
mapfile -t gemspecs < <(find . -maxdepth 1 -type f -name '*.gemspec' -printf '%f\n' | sort)
32+
if [ "${#gemspecs[@]}" -ne 1 ]; then
33+
echo "Expected exactly one gemspec in the repository root, found ${#gemspecs[@]}: ${gemspecs[*]}" >&2
34+
exit 1
35+
fi
36+
gem build "${gemspecs[0]}"
37+
38+
- name: Push Gem
39+
uses: rubygems/release-gem@6317d8d1f7e28c24d28f6eff169ea854948bd9f7 # v1.2.0

0 commit comments

Comments
 (0)