Skip to content

Commit 1a0ab6d

Browse files
navinkarkera0x29a
authored andcommitted
feat: workflow to publish package to opencraft npm
(cherry picked from commit 80a4960)
1 parent 9f6e537 commit 1a0ab6d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/npm-publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
name: Verify
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Setup Nodejs Env
20+
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ env.NODE_VER }}
25+
- name: Install dependencies
26+
run: npm ci
27+
- name: Lint
28+
run: npm run lint
29+
- name: Test
30+
run: npm run test
31+
32+
publish-npm:
33+
needs: build
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
- name: Setup Nodejs Env
41+
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: ${{ env.NODE_VER }}
46+
registry-url: 'https://registry.npmjs.org'
47+
- run: npm ci
48+
- run: git config --global user.name "${{ github.actor }}"
49+
- run: git config --global user.email "github-action-${{ github.actor }}@users.noreply.github.com"
50+
- run: npm version --no-git-tag-version ${{ github.event.release.tag_name }}
51+
- run: npm run build
52+
- run: npm publish --access public
53+
env:
54+
NODE_AUTH_TOKEN: ${{secrets.SEMANTIC_RELEASE_NPM_TOKEN}}

0 commit comments

Comments
 (0)