mirror of
https://github.com/kunkunsh/kunkun-ext-sqlite-browser.git
synced 2025-04-03 18:56:44 +00:00
add GitHub Actions workflow for NPM package publishing
This commit is contained in:
parent
fdeaa0f03e
commit
3870437c53
48
.github/workflows/npm-publish.yml
vendored
Normal file
48
.github/workflows/npm-publish.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
||||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
||||
|
||||
name: NPM Package Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
release:
|
||||
types: [created]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: latest
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
- run: pnpm install
|
||||
- run: pnpm build
|
||||
- run: |
|
||||
PACKAGE_NAME=$(jq -r '.name' package.json)
|
||||
PACKAGE_VERSION=$(jq -r '.version' package.json)
|
||||
|
||||
# Get the version from npm registry
|
||||
REGISTRY_VERSION=$(npm show "$PACKAGE_NAME" version)
|
||||
|
||||
# Compare versions
|
||||
if [ "$PACKAGE_VERSION" == "$REGISTRY_VERSION" ]; then
|
||||
echo "Version $PACKAGE_VERSION already exists in the npm registry."
|
||||
exit 0
|
||||
else
|
||||
echo "Version $PACKAGE_VERSION does not exist in the npm registry. Proceeding..."
|
||||
npm publish --provenance --access public
|
||||
fi
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
Loading…
x
Reference in New Issue
Block a user