Skip to content

Commit 7d3f106

Browse files
committed
SBCOSS-524: workflow to publish package to npm
1 parent a65e844 commit 7d3f106

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish File Upload Library Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '22.15.0'
19+
cache: 'npm'
20+
21+
- name: Restore node_modules cache
22+
id: cache
23+
uses: actions/cache@v4
24+
with:
25+
path: node_modules
26+
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-modules-
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Save node_modules cache
34+
if: steps.cache.outputs.cache-hit != 'true'
35+
uses: actions/cache@v4
36+
with:
37+
path: node_modules
38+
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
39+
40+
- name: Build and publish package
41+
env:
42+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
43+
run: |
44+
npm run build
45+
cp package.json ./dist/package.json
46+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
47+
npm publish dist --access=public
48+

0 commit comments

Comments
 (0)