ci: add ci to build, dependabot and release #1
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: Build | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: [latest, 18, 20, 22] | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
permissions: | |
# Required to checkout the code | |
contents: read | |
# Required to put a comment into the pull-request | |
pull-requests: write | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "pnpm" | |
- name: Install dependencies | |
run: pnpm install | |
- name: Lint check | |
run: pnpm run lint-check | |
- name: Format check | |
run: pnpm run format-check | |
- name: Run tests | |
run: pnpm run coverage | |
- name: Report Coverage | |
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 'latest' && github.event_name == 'pull_request' | |
uses: davelosert/vitest-coverage-report-action@v2 | |
- name: Build | |
run: pnpm run build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-assets-${{ matrix.os }}-${{ matrix.node-version }} | |
path: dist | |
publish: | |
if: github.event_name == 'release' && github.event.action == 'published' | |
runs-on: ubuntu-latest | |
needs: test | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
registry-url: https://registry.npmjs.org/ | |
node-version: lts/* | |
cache: "pnpm" | |
- name: Install dependencies | |
run: pnpm install | |
- run: pnpm publish --provenance --no-git-checks --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: published-assets | |
path: dist |