Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- main
pull_request:
workflow_dispatch: null
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -23,7 +23,20 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run prepublishOnly
- run: npm publish --access public
- name: Check if version is already published
id: version-check
if: github.event_name != 'pull_request'
run: |
PKG_NAME=$(node -p "require('./package.json').name")
PKG_VERSION=$(node -p "require('./package.json').version")
if npm view "$PKG_NAME@$PKG_VERSION" version > /dev/null 2>&1; then
echo "Version $PKG_VERSION of $PKG_NAME is already published, skipping publish."
echo "should-publish=false" >> "$GITHUB_OUTPUT"
else
echo "Version $PKG_VERSION of $PKG_NAME is new, will publish."
echo "should-publish=true" >> "$GITHUB_OUTPUT"
fi
- run: npm publish --access public
if: github.event_name != 'pull_request' && steps.version-check.outputs.should-publish == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Loading