Skip to content

Commit 344ca59

Browse files
committed
Configure trusted publishing
This way we can just push a tag and let GitHub actions do the release
1 parent ca9cea1 commit 344ca59

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish gem to rubygems.org
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
push:
13+
if: github.repository == 'bcrypt-ruby/bcrypt-ruby'
14+
runs-on: ubuntu-latest
15+
16+
environment:
17+
name: rubygems.org
18+
url: https://rubygems.org/gems/bcrypt-ruby
19+
20+
permissions:
21+
contents: write
22+
id-token: write
23+
24+
strategy:
25+
matrix:
26+
ruby: ["ruby", "jruby"]
27+
28+
steps:
29+
- name: Harden Runner
30+
uses: step-security/harden-runner@v2
31+
with:
32+
egress-policy: audit
33+
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Ruby
37+
uses: ruby/setup-ruby@v1
38+
with:
39+
ruby-version: ${{ matrix.ruby }}
40+
41+
# https://github.com/rubygems/rubygems/issues/5882
42+
- name: Install dependencies and build for JRuby
43+
run: |
44+
sudo apt install default-jdk maven
45+
gem update --system
46+
gem install ruby-maven rake-compiler --no-document
47+
rake compile
48+
if: matrix.ruby == 'jruby'
49+
50+
- name: Install dependencies
51+
run: bundle install --jobs 4 --retry 3
52+
53+
- name: Publish to RubyGems
54+
uses: rubygems/release-gem@v1
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 }}
62+
if: matrix.ruby != 'jruby'

0 commit comments

Comments
 (0)