Skip to content

Fix publish-npm workflow #4

Fix publish-npm workflow

Fix publish-npm workflow #4

Workflow file for this run

name: Publish Package to npmjs
on:
push:
branches: [main]
jobs:
publish_to_npm:
runs-on: ubuntu-latest
steps:
-
name: Checkout repository
uses: actions/checkout@v4
-
name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.17.0'
registry-url: 'https://registry.npmjs.org'
-
name: Check if package version has changed
id: check
run: |
LATEST_VERSION=$(npm view . version)
CURRENT_VERSION=$(node -p "require('./package.json').version")
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
echo "Version changed from $LATEST_VERSION to $CURRENT_VERSION"
echo "VERSION_CHANGED=true" >> $GITHUB_OUTPUT
else
echo "Version unchanged"
echo "VERSION_CHANGED=false" >> $GITHUB_OUTPUT
fi
-
name: Cancelling
uses: andymckay/[email protected]
if: steps.check.outputs.VERSION_CHANGED == 'false'
-
name: Install dependencies
run: npm ci
-
name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}