.github/workflows/nodejs.yml
name: Unit tests & Release
on:
push:
branches:
- master
- next
pull_request:
branches:
- master
- next
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
- name: install
run: yarn --frozen-lockfile
- name: run ESLint
run: yarn lint
test-node:
name: Test on Node.js v${{ matrix.node-version }}
strategy:
fail-fast: false
matrix:
node-version: [6.x, 8.x, 10.x, 12.x, 14.x, 16.x, 18.x, 20.x, 21.x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install --frozen-lockfile --ignore-engines
- uses: paambaati/codeclimate-action@v5
if: ${{ always() }}
env:
CC_TEST_REPORTER_ID: d3494c5bb5f3df7d98635dbc2aa962c7ce5e14c61f574a8c7304dfa9bc8783e4
with:
coverageCommand: yarn cover
- uses: coverallsapp/github-action@v2
if: ${{ always() }}
with:
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true
upload-coverage:
needs: test-node
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
test-ubuntu:
uses: ./.github/workflows/test.yml
with:
os: ubuntu-latest
test-macos:
uses: ./.github/workflows/test.yml
with:
os: macos-latest
test-windows:
uses: ./.github/workflows/test.yml
with:
os: windows-latest
release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/master' || github.event.ref == 'refs/heads/next') }}
name: Release new version
needs: [lint, test-node, test-ubuntu, test-macos, test-windows, upload-coverage]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: yarn
- name: install
run: yarn --frozen-lockfile
- run: npx semantic-release@22
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}