Skip to content

Commit 7aa7d87

Browse files
ci(sdk): automate publish on npm when a release is published
1 parent 9784b58 commit 7aa7d87

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: npm publish latest - dataprotector
2+
description: Publish on npm when a release is published
3+
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
publish-npm:
10+
# check tag is "sdk-v*"
11+
if: contains(github.ref_name,'sdk-v')
12+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
13+
with:
14+
scope: '@iexec/dataprotector-sdk'
15+
registry: 'https://registry.npmjs.org'
16+
node-version: '18'
17+
working-directory: packages/sdk
18+
tag: 'latest'
19+
install-command: |
20+
npm ci
21+
npm run codegen
22+
secrets:
23+
npm-token: ${{ secrets.NPM_TOKEN }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: npm publish staging - dataprotector
2+
description: Publish a staging version on npm
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
set-publish-version:
9+
# Run only on main branch
10+
if: github.ref == 'refs/heads/main'
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
- name: Set publish version
18+
id: set-publish-version
19+
working-directory: packages/sdk
20+
run: |
21+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
22+
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
23+
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
24+
outputs:
25+
VERSION: ${{ steps.set-publish-version.outputs.VERSION }}
26+
27+
publish-npm:
28+
# Run only on main branch
29+
if: github.ref == 'refs/heads/main'
30+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
31+
needs: set-publish-version
32+
with:
33+
scope: '@iexec/dataprotector-sdk'
34+
registry: 'https://registry.npmjs.org'
35+
node-version: '18'
36+
environment: 'staging'
37+
working-directory: packages/sdk
38+
tag: 'nightly'
39+
version: ${{ needs.set-publish-version.outputs.VERSION }}
40+
install-command: |
41+
npm ci
42+
npm run codegen
43+
secrets:
44+
npm-token: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)