diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml deleted file mode 100644 index fbd0d55..0000000 --- a/.github/workflows/npm-publish.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Publish Package To Npm - -permissions: - contents: read - packages: write - -on: - push: - branches: [main] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: "20" - - run: npm i - - run: npm run build - - uses: JS-DevTools/npm-publish@v2 - with: - token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af8be38..c685036 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,4 +17,20 @@ jobs: - uses: google-github-actions/release-please-action@v3 with: release-type: node - package-name: mtk-tool \ No newline at end of file + package-name: mtk-tool + # The logic below handles the npm publication: + - uses: actions/checkout@v2 + # these if statements ensure that a publication only occurs when + # a new release is created: + if: ${{ steps.release.outputs.release_created }} + - uses: actions/setup-node@v1 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' + if: ${{ steps.release.outputs.release_created }} + - run: npm ci + if: ${{ steps.release.outputs.release_created }} + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if: ${{ steps.release.outputs.release_created }} \ No newline at end of file