From e1f4df3fdcf574a482ce669a04134f8108f17ae4 Mon Sep 17 00:00:00 2001 From: Deryk DeGuzman Date: Thu, 2 May 2024 14:23:18 -0700 Subject: [PATCH] chore: set up NPM auto publish on commit --- .github/workflows/npm-publish.yml | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..2b17024 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,42 @@ +name: npm-publish +on: + push: + branches: + - chore/auto_publish # Change this to your default branch +jobs: + npm-publish: + name: npm-publish + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Check version changes + uses: EndBug/version-check@v2 + id: check + + - name: Version update detected + if: steps.check.outputs.changed == 'true' + run: 'echo "Version change found! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' + + - name: Draft release + if: steps.check.outputs.changed == 'true' + run: 'gh release create v${{ steps.check.outputs.version }} -d --notes ""' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Node.js for NPM + if: steps.check.outputs.changed == 'true' + uses: actions/setup-node@v4 + with: + registry-url: "https://registry.npmjs.org" + + - name: Build lib + if: steps.check.outputs.changed == 'true' + run: "npm i && npm buildLib" + + - name: Publish package to NPM + if: steps.check.outputs.changed == 'true' + run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}