Skip to content

Commit eb156fa

Browse files
authored
Merge pull request #43 from ayomideadeniran/feature/18-npm-publish
[SDK]: Automate SDK NPM publishing via GitHub Actions
2 parents b8e16be + 87fd5a5 commit eb156fa

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/publish-sdk.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish SDK to NPM
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
push:
16+
tags:
17+
- 'sdk-v*'
18+
19+
jobs:
20+
publish:
21+
runs-on: ubuntu-latest
22+
defaults:
23+
run:
24+
working-directory: sdk
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: '20'
35+
registry-url: 'https://registry.npmjs.org'
36+
cache: 'npm'
37+
cache-dependency-path: sdk/package-lock.json
38+
39+
- name: Install dependencies
40+
run: npm ci
41+
42+
- name: Bump Version
43+
if: github.event_name == 'workflow_dispatch'
44+
run: |
45+
git config user.name "github-actions[bot]"
46+
git config user.email "github-actions[bot]@users.noreply.github.com"
47+
npm version ${{ github.event.inputs.bump }} -m "chore(sdk): bump version to %s"
48+
git push origin main --follow-tags
49+
50+
- name: Build
51+
run: npm run build
52+
53+
- name: Publish to NPM
54+
run: npm publish --access public
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)