Skip to content

Commit cfefdcd

Browse files
authored
ci: Set up trusted publishing (#962)
- closes #907
1 parent d600a8b commit cfefdcd

File tree

3 files changed

+77
-74
lines changed

3 files changed

+77
-74
lines changed

.github/workflows/pre_release.yaml

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -220,44 +220,13 @@ jobs:
220220
needs: [update_changelog]
221221
runs-on: ubuntu-latest
222222

223-
# Required for --provenances to work
224-
permissions:
225-
id-token: write
226-
227223
steps:
228-
- uses: actions/checkout@v5
229-
with:
230-
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
231-
232-
- name: Use Node.js
233-
uses: actions/setup-node@v6
234-
with:
235-
node-version: 24
236-
registry-url: https://registry.npmjs.org
237-
package-manager-cache: false
238-
239-
- name: Enable corepack
240-
run: |
241-
corepack enable
242-
corepack prepare yarn@stable --activate
243-
244-
- name: Activate cache for yarn
245-
uses: actions/setup-node@v6
246-
with:
247-
cache: yarn
248-
249-
- name: Install dependencies
250-
run: yarn
251-
252-
# Check version consistency and increment pre-release version number for beta only.
253-
- name: Bump pre-release version
254-
run: yarn tsx ./.github/scripts/before-beta-release.ts
255-
256-
- name: Build module
257-
run: yarn build
258-
259-
- name: Publish to NPM
260-
run: |
261-
yarn npm publish --provenance --access public --tag beta
262-
env:
263-
YARN_NPM_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
224+
- name: Execute publish workflow
225+
uses: apify/workflows/execute-workflow@main
226+
with:
227+
workflow: publish_to_npm.yaml
228+
inputs: >
229+
{
230+
"ref": "${{ needs.update_changelog.outputs.changelog_commitish }}",
231+
"tag": "beta"
232+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish to NPM
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: Git ref to publish (branch, tag, or commit SHA)
8+
required: true
9+
type: string
10+
tag:
11+
description: NPM dist-tag
12+
required: true
13+
type: choice
14+
default: latest
15+
options:
16+
- latest
17+
- beta
18+
19+
permissions:
20+
id-token: write # Required for OIDC
21+
contents: read
22+
23+
jobs:
24+
publish_to_npm:
25+
name: Publish to NPM
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v5
29+
with:
30+
ref: ${{ inputs.ref }}
31+
32+
- name: Use Node.js
33+
uses: actions/setup-node@v6
34+
with:
35+
node-version: 24
36+
registry-url: "https://registry.npmjs.org"
37+
package-manager-cache: false
38+
39+
- name: Enable corepack
40+
run: |
41+
corepack enable
42+
corepack prepare yarn@stable --activate
43+
44+
- name: Activate cache for yarn
45+
uses: actions/setup-node@v6
46+
with:
47+
cache: yarn
48+
49+
- name: Install dependencies
50+
run: yarn
51+
52+
- name: Check version consistency and bump pre-release version (beta only)
53+
if: ${{ inputs.tag == 'beta' }}
54+
run: yarn tsx ./.github/scripts/before-beta-release.ts
55+
56+
- name: Build module
57+
run: yarn build
58+
59+
- name: Publish to NPM
60+
run: yarn npm publish --provenance --access public --tag ${{ inputs.tag }}

.github/workflows/release.yaml

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -250,41 +250,15 @@ jobs:
250250
contents: write
251251
id-token: write
252252
steps:
253-
- uses: actions/checkout@v5
253+
- name: Execute publish workflow
254+
uses: apify/workflows/execute-workflow@main
254255
with:
255-
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
256-
257-
- name: Use Node.js
258-
uses: actions/setup-node@v6
259-
with:
260-
node-version: 24
261-
registry-url: https://registry.npmjs.org
262-
package-manager-cache: false
263-
264-
- name: Enable corepack
265-
run: |
266-
corepack enable
267-
corepack prepare yarn@stable --activate
268-
269-
- name: Activate cache for yarn
270-
uses: actions/setup-node@v6
271-
with:
272-
cache: yarn
273-
274-
- name: Install dependencies
275-
run: yarn
276-
277-
- name: Build module
278-
run: yarn build
279-
280-
- name: Pack with yarn
281-
run: yarn pack
282-
283-
- name: Publish to NPM
284-
run: |
285-
yarn npm publish --provenance --access public
286-
env:
287-
YARN_NPM_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
256+
workflow: publish_to_npm.yaml
257+
inputs: >
258+
{
259+
"ref": "${{ needs.update_changelog.outputs.changelog_commitish }}",
260+
"tag": "latest"
261+
}
288262
289263
update_homebrew_formula:
290264
name: Update Homebrew Formula

0 commit comments

Comments
 (0)