78 lines
2.4 KiB
YAML
78 lines
2.4 KiB
YAML
name: Publish
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
tags:
|
|
- '*'
|
|
workflow_dispatch:
|
|
jobs:
|
|
build:
|
|
runs-on: docker
|
|
|
|
steps:
|
|
- uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Node
|
|
uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
|
|
with:
|
|
node-version: 22.x
|
|
check-latest: true
|
|
- name: Cache npm dependencies
|
|
uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-npm-${{ hashFiles('package.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-npm-
|
|
- name: Install dependencies
|
|
run: npm install
|
|
- name: Check formatting
|
|
run: npm run format
|
|
- name: Lint
|
|
run: npm run lint
|
|
- name: Type-check
|
|
run: npm test
|
|
- name: Build library and docs
|
|
run: npm run build
|
|
- name: Upload static site artifact 1
|
|
if: ${{ github.ref == 'refs/heads/main' }}
|
|
uses: https://github.com/actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5
|
|
with:
|
|
name: pages-build-0
|
|
path: docs
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
publish-npm:
|
|
needs: build
|
|
runs-on: docker
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
steps:
|
|
- uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
|
with:
|
|
persist-credentials: false
|
|
- name: Setup Node
|
|
uses: https://github.com/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
|
|
with:
|
|
node-version: 22.x
|
|
check-latest: true
|
|
registry-url: https://registry.npmjs.org
|
|
- name: Cache npm dependencies
|
|
uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-npm-${{ hashFiles('package.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-npm-
|
|
- name: Install dependencies
|
|
run: npm install
|
|
- name: Build library
|
|
run: npm run build
|
|
- name: Publish to NPM
|
|
run: npm publish
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ (secrets.NPM_TOKEN || '') }}
|
|
if: ${{ (github.ref == 'refs/heads/main' || github.ref_type == 'tag') }}
|