Skip to content

Code refresh

Code refresh #217

name: Run tests and publish
on:
push:
branches:
- master
- main
- beta
# - feature/*
paths-ignore:
- 'docs/**'
- 'examples/**'
- 'README.md'
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
jobs:
test:
name: 'Build and test on node v${{ matrix.node }}'
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 18]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Build library
run: npm run build
- name: Run code linting
run: npm run lint
- name: Run tests
if: ${{ always() }}
run: npm run test:jest
- name: Send data to Coveralls
if: always() && matrix.node == 16
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
npm-release:
name: 'Release to npm'
runs-on: ubuntu-latest
needs: [test]
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use node 18
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Build library
run: npm run build
- uses: svrooij/secret-gate-action@v1
id: mygate
with:
inputsToCheck: 'NPM_TOKEN'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
if: steps.mygate.outputs.inputsChecked == 'true'
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup node for Github Registry
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: 'svrooij'
- name: Publish To GitHub Package Registry
if: steps.semantic.outputs.new_release_published == 'true'
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}