Skip to content

Commit 1081953

Browse files
committed
ci: add GitHub workflow for automated NPM package publishing
1 parent a16c9e3 commit 1081953

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/node-publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish Package to npmjs
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
id-token: write
13+
steps:
14+
- name: ⬇️ Check out code
15+
uses: actions/checkout@v4
16+
17+
- name: 🟢 Enable Corepack
18+
run: corepack enable
19+
20+
- name: 🟢 Set up Node 20
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20.x
24+
cache: yarn
25+
registry-url: 'https://registry.npmjs.org'
26+
27+
- name: Build and Publish
28+
run: |
29+
yarn install --frozen-lockfile
30+
31+
yarn build
32+
33+
# print the NPM user name for validation
34+
npm whoami
35+
36+
VERSION=$(node -p "require('./package.json').version" )
37+
38+
# Only publish stable versions to the latest tag
39+
if [[ "$VERSION" =~ ^[^-]+$ ]]; then
40+
NPM_TAG="latest"
41+
else
42+
NPM_TAG="beta"
43+
fi
44+
45+
echo "Publishing $VERSION with $NPM_TAG tag."
46+
47+
yarn workspace @imagekit/editor npm publish --tag "$NPM_TAG" --provenance --access public
48+
49+
env:
50+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
51+
CI: true

0 commit comments

Comments
 (0)