From c7a511232bb4470e63321388a1f8fe227d7bc53d Mon Sep 17 00:00:00 2001 From: Lorenzo Mangani Date: Thu, 24 Oct 2024 14:22:52 +0200 Subject: [PATCH] Create npm_release.yml --- .github/workflows/npm_release.yml | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/npm_release.yml diff --git a/.github/workflows/npm_release.yml b/.github/workflows/npm_release.yml new file mode 100644 index 0000000..0cede8e --- /dev/null +++ b/.github/workflows/npm_release.yml @@ -0,0 +1,42 @@ +name: 'NPM CI+CD' + +on: + release: + types: [published] + +jobs: + build: + name: 'Build & Publish' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.1 + with: + ref: ${{ github.ref }} + - name: Update Package to Release version + uses: technote-space/package-version-check-action@v1.9.3 + - name: Check NPM secret presence + id: checksecrets + shell: bash + run: | + if [ "$SECRET" == "" ]; then + echo "secretspresent=false" >> $GITHUB_OUTPUT + else + echo "secretspresent=true" >> $GITHUB_OUTPUT + fi + env: + SECRET: ${{ secrets.NPM_TOKEN }} + - uses: actions/setup-node@v4.0.1 + if: ${{ steps.checksecrets.outputs.secretspresent }} + with: + node-version: 20 + - name: Publish to NPM + if: ${{ steps.checksecrets.outputs.secretspresent }} + continue-on-error: false + run: | + npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} + npm install + npm publish --access public + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + +