Skip to content

First commit

First commit #6

Workflow file for this run

name: Publish NPM package
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
# - name: Test
# run: npm run test
- name: Check the version
id: check
run: |
CURRENT_VERSION=$(jq -r .version package.json)
echo "Current version: $CURRENT_VERSION"
LATEST_VERSION=$(npm show <package-name> version || echo "0.0.0")
echo "Latest version: $LATEST_VERSION"
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ];
then
echo "Version changed"
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
else
echo "Version not changed"
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
- name: Build
run: npm run build
if: steps.check.outputs.version_changed == 'true'
- name: Publish
if: steps.check.outputs.version_changed == 'true'
run: npm publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}