Skip to content

Commit 8e88590

Browse files
authored
Merge pull request #3680 from tenderlove/trusted-publishers
Trusted publishing workflows
2 parents 4848dbd + f224797 commit 8e88590

3 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to crates.io
2+
on:
3+
push:
4+
tags: ['v*'] # Triggers when pushing tags starting with 'v'
5+
jobs:
6+
publish:
7+
if: github.repository == 'ruby/prism'
8+
runs-on: ubuntu-latest
9+
environment: release # Optional: for enhanced security
10+
permissions:
11+
id-token: write # Required for OIDC token exchange
12+
steps:
13+
- name: Harden Runner
14+
uses: step-security/harden-runner@v2
15+
with:
16+
egress-policy: audit
17+
- uses: actions/checkout@v5
18+
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: "3.4"
23+
bundler-cache: true
24+
25+
- uses: rust-lang/crates-io-auth-action@v1
26+
id: auth
27+
28+
- run: bundle exec rake cargo:publish:real
29+
env:
30+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

.github/workflows/publish-gem.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 == 'ruby/prism'
14+
runs-on: ubuntu-latest
15+
16+
environment:
17+
name: rubygems.org
18+
url: https://rubygems.org/gems/prism
19+
20+
permissions:
21+
contents: write
22+
id-token: write
23+
24+
steps:
25+
- name: Harden Runner
26+
uses: step-security/harden-runner@v2
27+
with:
28+
egress-policy: audit
29+
30+
- uses: actions/checkout@v4
31+
32+
- name: Set up Ruby
33+
uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: "3.4"
36+
bundler-cache: true
37+
38+
- name: Publish to RubyGems
39+
uses: rubygems/release-gem@v1

.github/workflows/publish-npm.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish to npmjs.com
2+
on:
3+
push:
4+
tags: ['v*'] # Triggers when pushing tags starting with 'v'
5+
jobs:
6+
publish:
7+
if: github.repository == 'ruby/prism'
8+
runs-on: ubuntu-latest
9+
environment: release # Optional: for enhanced security
10+
permissions:
11+
id-token: write # Required for OIDC token exchange
12+
steps:
13+
- name: Harden Runner
14+
uses: step-security/harden-runner@v2
15+
with:
16+
egress-policy: audit
17+
- uses: actions/checkout@v5
18+
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: "3.4"
23+
bundler-cache: true
24+
25+
- name: Set up node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
registry-url: 'https://registry.npmjs.org'
30+
31+
- name: rake templates
32+
run: bundle exec rake templates
33+
34+
- name: Set up WASI-SDK
35+
run: |
36+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
37+
tar xvf wasi-sdk-25.0-x86_64-linux.tar.gz
38+
39+
- name: Build the project
40+
run: make wasm WASI_SDK_PATH=$(pwd)/wasi-sdk-25.0-x86_64-linux
41+
42+
- name: Update npm
43+
run: npm install -g npm@latest
44+
45+
- run: npm publish

0 commit comments

Comments
 (0)