Skip to content

Commit 29f67a5

Browse files
ci: add SDK npm publish workflows and manual operations
1 parent 9ee9505 commit 29f67a5

File tree

4 files changed

+265
-0
lines changed

4 files changed

+265
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: npm publish latest
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
npm-publish:
9+
uses: ./.github/workflows/reusable-npm.yml
10+
with:
11+
tag: 'latest'
12+
secrets:
13+
npm-token: ${{ secrets.NPM_TOKEN }}

.github/workflows/reusable-npm.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: npm publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
dry-run:
7+
description: 'Run in dry-run mode (the package will not be published)'
8+
default: false
9+
type: boolean
10+
version:
11+
description: 'Version to publish (leave empty to use package.json version)'
12+
default: ''
13+
type: string
14+
tag:
15+
description: 'npm publish tag (e.g., latest, nightly)'
16+
default: ''
17+
type: string
18+
secrets:
19+
npm-token:
20+
description: 'NPM auth token (required unless `dry-run: true`)'
21+
required: false
22+
23+
jobs:
24+
npm-publish:
25+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/[email protected]
26+
with:
27+
install-command: npm ci
28+
build-command: npm run build
29+
dry-run: ${{ inputs.dry-run }}
30+
tag: ${{ inputs.tag }}
31+
version: ${{ inputs.version }}
32+
environment: ${{ (inputs.dry-run && '') || inputs.tag }}
33+
provenance: ${{ !inputs.dry-run }}
34+
secrets:
35+
npm-token: ${{ secrets.NPM_TOKEN }}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Manual SDK Operations
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
operation:
7+
description: 'Operation to perform'
8+
required: true
9+
type: choice
10+
options:
11+
- publish-nightly
12+
- publish-latest
13+
- deprecate-version
14+
- undeprecate-version
15+
- build-test
16+
version:
17+
description: 'Version to publish/deprecate'
18+
required: false
19+
type: string
20+
default: ''
21+
tag:
22+
description: 'npm publish tag (e.g., latest, nightly)'
23+
required: false
24+
type: string
25+
default: 'nightly'
26+
27+
jobs:
28+
build-test:
29+
runs-on: ubuntu-latest
30+
if: ${{ github.event.inputs.operation == 'build-test' }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
cache: 'npm'
38+
cache-dependency-path: package-lock.json
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Unit tests
44+
run: npm run test:unit
45+
46+
- name: Build
47+
run: npm run build
48+
49+
- name: NPM dry run
50+
run: npm publish --dry-run
51+
52+
publish-nightly:
53+
runs-on: ubuntu-latest
54+
if: ${{ github.event.inputs.operation == 'publish-nightly' }}
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- uses: actions/setup-node@v4
59+
with:
60+
node-version: 20
61+
cache: 'npm'
62+
cache-dependency-path: package-lock.json
63+
64+
- name: Install dependencies
65+
run: npm ci
66+
67+
- name: Build
68+
run: npm run build
69+
70+
- name: Set version nightly
71+
run: |
72+
CURRENT_VERSION=$(npm pkg get version | sed 's/"//g')
73+
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-$(date +%Y%m%d-%H%M%S)"
74+
npm pkg set version="$NIGHTLY_VERSION"
75+
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> $GITHUB_ENV
76+
77+
- name: Deprecate previous nightly version
78+
run: |
79+
PREVIOUS_NIGHTLY=$(npm view @iexec/web3mail dist-tags --json | jq '."nightly"' | sed 's/"//g')
80+
if [ "$PREVIOUS_NIGHTLY" != "null" ] && [ -n "$PREVIOUS_NIGHTLY" ]; then
81+
npm deprecate @iexec/web3mail@$PREVIOUS_NIGHTLY "Deprecate $PREVIOUS_NIGHTLY"
82+
fi
83+
84+
- name: Publish nightly
85+
env:
86+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
87+
run: npm publish --tag nightly
88+
89+
publish-latest:
90+
runs-on: ubuntu-latest
91+
if: ${{ github.event.inputs.operation == 'publish-latest' }}
92+
steps:
93+
- uses: actions/checkout@v4
94+
95+
- uses: actions/setup-node@v4
96+
with:
97+
node-version: 20
98+
cache: 'npm'
99+
cache-dependency-path: package-lock.json
100+
101+
- name: Install dependencies
102+
run: npm ci
103+
104+
- name: Build
105+
run: npm run build
106+
107+
- name: Publish latest
108+
env:
109+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
110+
run: npm publish --tag latest
111+
112+
deprecate-version:
113+
runs-on: ubuntu-latest
114+
if: ${{ github.event.inputs.operation == 'deprecate-version' }}
115+
steps:
116+
- uses: actions/checkout@v4
117+
118+
- uses: actions/setup-node@v4
119+
with:
120+
node-version: 20
121+
122+
- name: Deprecate version
123+
run: |
124+
VERSION="${{ github.event.inputs.version }}"
125+
if [ -n "$VERSION" ]; then
126+
npm deprecate @iexec/web3mail@$VERSION "deprecate $VERSION"
127+
else
128+
echo "VERSION is not set"
129+
fi
130+
env:
131+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
132+
133+
undeprecate-version:
134+
runs-on: ubuntu-latest
135+
if: ${{ github.event.inputs.operation == 'undeprecate-version' }}
136+
steps:
137+
- uses: actions/checkout@v4
138+
139+
- uses: actions/setup-node@v4
140+
with:
141+
node-version: 20
142+
143+
- name: Undeprecate version
144+
run: |
145+
VERSION="${{ github.event.inputs.version }}"
146+
if [ -n "$VERSION" ]; then
147+
npm deprecate @iexec/web3mail@$VERSION ""
148+
else
149+
echo "VERSION is not set"
150+
fi
151+
env:
152+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/sdk-pr-test.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: PR test
2+
3+
on: [pull_request]
4+
5+
concurrency:
6+
group: ${{ github.ref }}-pr-test
7+
cancel-in-progress: true
8+
9+
jobs:
10+
check-code:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
cache: 'npm'
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Check format
25+
run: npm run check-format
26+
27+
- name: Lint
28+
run: npm run lint
29+
30+
test:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: 20
38+
cache: 'npm'
39+
cache-dependency-path: package-lock.json
40+
41+
- name: Install dependencies
42+
working-directory: packages/sdk
43+
run: npm ci
44+
45+
- name: Unit tests
46+
working-directory: packages/sdk
47+
run: npm run test:unit
48+
49+
- name: x
50+
working-directory: packages/sdk
51+
run: npm run start-test-stack
52+
53+
- name: Test e2e
54+
working-directory: packages/sdk
55+
run: npm run test:e2e
56+
57+
- name: Stop e2e test stack
58+
working-directory: packages/sdk
59+
if: always()
60+
run: npm run stop-test-stack
61+
62+
npm-dry-run:
63+
uses: ./.github/workflows/reusable-npm.yml
64+
with:
65+
dry-run: true

0 commit comments

Comments
 (0)