Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
# 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
- uses: actions/setup-node@v4
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 "[email protected]"
- 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 }}