Skip to content

Commit ae00c93

Browse files
ci: migrate to npm trusted publisher (#527)
* ci: migrate @iexec/dataprotector to trusted publisher * ci: migrate @iexec/dataprotector-deserializer to trusted publisher * style: update comment
1 parent 46e3c45 commit ae00c93

File tree

4 files changed

+103
-110
lines changed

4 files changed

+103
-110
lines changed
Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,59 @@
1+
# ⚠️ THIS WORKFLOW IS THE TRUSTED PUBLISHER CONFIGURED ON NPMJS.COM, DO NOT RENAME OR DELETE THIS FILE ⚠️
12
name: Deserializer - Publish NPM Package
23

34
on:
5+
# For staging releases
46
workflow_dispatch:
5-
inputs:
6-
tag:
7-
description: 'NPM tag to publish (latest or nightly)'
8-
required: true
9-
type: choice
10-
options:
11-
- latest
12-
- nightly
13-
- beta
14-
default: nightly
7+
# For latest releases
8+
release:
9+
types: [published]
10+
11+
permissions:
12+
id-token: write # Required for OIDC
13+
packages: write
14+
contents: read
1515

1616
jobs:
17-
set-publish-version:
18-
# Run only on main branch
19-
if: github.ref == 'refs/heads/main'
17+
set-staging-version:
18+
# Only run for manual dispatch on main branch
19+
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout code
2323
uses: actions/checkout@v4
2424
- name: Set up Node.js
2525
uses: actions/setup-node@v4
2626
- name: Set publish version
27-
id: set-publish-version
28-
if: github.event.inputs.tag == 'nightly'
27+
id: set-staging-version
2928
working-directory: packages/dataprotector-deserializer
3029
run: |
31-
if [ "${{ github.event.inputs.tag }}" == "nightly" ]; then
32-
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
33-
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
34-
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
35-
else
36-
echo "VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_OUTPUT
37-
fi
30+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
31+
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
32+
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
3833
outputs:
39-
VERSION: ${{ steps.set-publish-version.outputs.VERSION }}
34+
VERSION: ${{ steps.set-staging-version.outputs.VERSION }}
35+
36+
publish-npm-staging:
37+
# Only run for manual dispatch on main branch
38+
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
39+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
40+
needs: set-staging-version
41+
with:
42+
scope: '@iexec/dataprotector-deserializer'
43+
registry: 'https://registry.npmjs.org'
44+
node-version: '20'
45+
environment: 'staging'
46+
working-directory: packages/dataprotector-deserializer
47+
tag: 'nightly'
48+
version: ${{ needs.set-staging-version.outputs.VERSION }}
4049

41-
publish-npm:
42-
# Run only on main branch
43-
if: github.ref == 'refs/heads/main'
44-
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
45-
needs: set-publish-version
50+
publish-npm-latest:
51+
# # Only run for release published with tag "dataprotector-deserializer-v*"
52+
if: ${{ github.event_name == 'release' && startsWith(github.ref_name,'dataprotector-deserializer-v') }}
53+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
4654
with:
47-
scope: '@iexec/deserializer'
55+
scope: '@iexec/dataprotector-deserializer'
4856
registry: 'https://registry.npmjs.org'
49-
node-version: '18'
50-
tag: ${{ github.event.inputs.tag }}
51-
environment: production
57+
node-version: '20'
5258
working-directory: packages/dataprotector-deserializer
53-
version: ${{ needs.set-publish-version.outputs.VERSION }}
54-
install-command: |
55-
npm ci
56-
cd ../sdk
57-
npm ci
58-
npm run codegen
59-
npm run build
60-
cd ../dataprotector-deserializer
61-
npm run test:prepare
62-
secrets:
63-
npm-token: ${{ secrets.NPM_TOKEN }}
59+
tag: 'latest'

.github/workflows/sdk-publish-npm-latest.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/sdk-publish-npm-staging.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# ⚠️ THIS WORKFLOW IS THE TRUSTED PUBLISHER CONFIGURED ON NPMJS.COM, DO NOT RENAME OR DELETE THIS FILE ⚠️name: SDK - Publish NPM
2+
3+
on:
4+
# For staging releases
5+
workflow_dispatch:
6+
# For latest releases
7+
release:
8+
types: [published]
9+
10+
permissions:
11+
id-token: write # Required for OIDC
12+
packages: write
13+
contents: read
14+
15+
jobs:
16+
set-staging-version:
17+
# Only run for manual dispatch on main branch
18+
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
- name: Set publish version
26+
id: set-staging-version
27+
working-directory: packages/sdk
28+
run: |
29+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
30+
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
31+
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
32+
outputs:
33+
VERSION: ${{ steps.set-staging-version.outputs.VERSION }}
34+
35+
publish-npm-staging:
36+
# Only run for manual dispatch on main branch
37+
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
38+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
39+
needs: set-staging-version
40+
with:
41+
scope: '@iexec/dataprotector'
42+
registry: 'https://registry.npmjs.org'
43+
node-version: '18'
44+
environment: 'staging'
45+
working-directory: packages/sdk
46+
tag: 'nightly'
47+
version: ${{ needs.set-staging-version.outputs.VERSION }}
48+
install-command: |
49+
npm ci
50+
npm run codegen
51+
52+
publish-npm-latest:
53+
# # Only run for release published with tag "dataprotector-v*"
54+
if: ${{ github.event_name == 'release' && startsWith(github.ref_name,'dataprotector-v') }}
55+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
56+
with:
57+
scope: '@iexec/dataprotector'
58+
registry: 'https://registry.npmjs.org'
59+
node-version: '18'
60+
working-directory: packages/sdk
61+
tag: 'latest'
62+
install-command: |
63+
npm ci
64+
npm run codegen

0 commit comments

Comments
 (0)