Skip to content

chore: update publish.yml #22

chore: update publish.yml

chore: update publish.yml #22

Workflow file for this run

name: Publish to npm
on:
push:
branches:
- main # Adjust this to your main branch
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
- name: Get package version
id: get-version
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
- name: Publish to npm
run: npm publish --access public --registry=https://registry.npmjs.org/ --tag=${{ steps.get-version.outputs.version }} --npm-token=${{ secrets.NPM_TOKEN }}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Bump version and push tag
if: success()
uses: laputansoft/github-tag-action@v4.6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ steps.get-version.outputs.version }}