diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 34616dc..b787414 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,24 +1,13 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages - -name: Node.js Package +name: Publish npm Package on: - release: - types: [created] + push: + branches: + - master + - main jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm test - publish-npm: - needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,14 +15,15 @@ jobs: with: node-version: 20 registry-url: https://registry.npmjs.org/ - - - name: Get release name - run: echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV - - - name: Update package.json version - run: | - npm version ${{ env.RELEASE_NAME }} --no-git-tag-version - - - run: npm publish + - run: git config --global user.name "GitHub CD bot" + - run: git config --global user.email "github-cd-bot@example.com" + - run: npm i && npm run test + - run: npm config set access public && npx semantic-release + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # push the version changes to GitHub + - run: git add package.json && git commit -m'update version' && git push env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} + # The secret is passed automatically. Nothing to configure. + github-token: ${{ secrets.GITHUB_TOKEN }}