ci: Publish npm package in CI #84
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: kizunapi | |
on: [push, pull_request] | |
env: | |
CI: true | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
continue-on-error: false | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: [16, 18, 20] | |
os: [ubuntu-22.04, windows-2022, macos-13] | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Test | |
run: | | |
npm install | |
npm run test | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Lint | |
run: | | |
yarn | |
yarn lint | |
publish: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: [build, lint] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set package version | |
run: | | |
npm config set git-tag-version=false | |
npm version $(git describe --tags) | |
- name: Publish npm package | |
uses: JS-DevTools/npm-publish@v2 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} |