feat(ci): auto publish on main push

This commit is contained in:
Nan72 2025-02-16 12:25:55 +07:00
parent d6128c069f
commit cbe15d6671
No known key found for this signature in database

View File

@ -1,6 +1,10 @@
name: NPM Package Publish name: NPM Package Publish
on: on:
push:
branches: [main]
release:
types: [created]
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@ -17,12 +21,21 @@ jobs:
bun-version: latest bun-version: latest
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: '22.x' node-version: "22.x"
registry-url: 'https://registry.npmjs.org' registry-url: "https://registry.npmjs.org"
- run: bun install - run: bun install
- run: bun run build - run: bun run build
- name: Publish to NPM
- name: Check if version is already published
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
PACKAGE_NAME=$(jq -r '.name' package.json)
npm view $PACKAGE_NAME@$PACKAGE_VERSION
continue-on-error: true
id: check_version
- name: Publish
if: steps.check_version.outcome != 'success'
run: npm publish --provenance --access public run: npm publish --provenance --access public
env: env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_KEY}} NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_KEY}}