Skip to content

Commit b6873a9

Browse files
committed
Add trusted gem publishing workflow
1 parent baf034e commit b6873a9

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release gem
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
release:
10+
name: Push gem to RubyGems.org
11+
runs-on: ubuntu-latest
12+
environment: release
13+
14+
permissions:
15+
contents: write
16+
id-token: write
17+
18+
steps:
19+
- name: Check out repository
20+
uses: actions/checkout@v5
21+
with:
22+
persist-credentials: false
23+
24+
- name: Set up Ruby
25+
uses: ruby/setup-ruby@v1
26+
with:
27+
ruby-version: "3.3.0"
28+
bundler-cache: true
29+
30+
- name: Verify tag matches gem version
31+
run: |
32+
version="$(ruby -Ilib -rliberic/version -e 'print Liberic::VERSION')"
33+
if [ "$GITHUB_REF_NAME" != "v$version" ]; then
34+
echo "Tag $GITHUB_REF_NAME does not match gem version $version" >&2
35+
exit 1
36+
fi
37+
38+
- name: Release gem
39+
uses: rubygems/release-gem@v1

0 commit comments

Comments
 (0)