chore(build): update action version of coveralls #294
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: Lint, Test, Build and optionally Publish | |
on: | |
# push only for branches (ignore tags) | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- '**' | |
# pull request only for branches (ignore tags) | |
pull_request: | |
branches: | |
- '**' | |
tags-ignore: | |
- '**' | |
jobs: | |
test: | |
strategy: | |
matrix: | |
# Test with Node.js v18 (maintenance), v20 (LTS) and v21 current | |
node: | |
- 18 | |
- 20 | |
- 21 | |
name: Node.js v${{ matrix.node }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- uses: actions/cache@v4 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
# Print current Node.js version | |
- run: node --version | |
# Print current Yarn version | |
- run: npm --version | |
# Print current Git version | |
- run: git --version | |
# Install node_modules | |
- run: HUSKY=0 npm ci | |
# Run tests | |
- run: npm run test:ci | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Node v18 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- uses: actions/cache@v4 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: install | |
run: HUSKY=0 npm ci | |
- name: lint, test, and build | |
run: | | |
npm run lint:ci | |
npm run test:ci | |
npm run build | |
env: | |
CI: true | |
# report coverage only for non PR | |
- name: coveralls | |
if: ${{ startsWith(github.ref, 'refs/pull/') == false }} | |
uses: coverallsapp/github-action@v2 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
# publish to latest if on master branch | |
- name: release master | |
if: ${{ github.ref == 'master' }} | |
run: | | |
npm run docs:build | |
npx semantic-release | |
npm run docs:deploy | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# publish pre-release if non master branch and allowed by .releaserc.yml configuration (only for non-PR branches) | |
- name: release non-master version | |
if: ${{ github.ref != 'master' && startsWith(github.ref, 'refs/pull/') == false }} | |
run: npx semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |