Add CI
This commit is contained in:
parent
c6438a9e21
commit
974a97c134
3 changed files with 139 additions and 1 deletions
45
.forgejo/workflows/check.yml
Normal file
45
.forgejo/workflows/check.yml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
name: Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
pull_request:
|
||||
branches: ['main']
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: docker
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22.x'
|
||||
check-latest: true
|
||||
|
||||
# package-lock.json is gitignored, so cache the global npm download cache
|
||||
# keyed on package.json rather than relying on `npm ci` + a lockfile.
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v4
|
||||
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
|
||||
run: npm run build
|
||||
88
.forgejo/workflows/publish.yml
Normal file
88
.forgejo/workflows/publish.yml
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
tags: ['*']
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: 'pages'
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22.x'
|
||||
check-latest: true
|
||||
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v4
|
||||
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: Deploy docs to pages mount
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
uses: http://forgejo:3000/andras/ci-actions/deploy-pages@main
|
||||
with:
|
||||
source: docs
|
||||
target: sdf-2d-docs
|
||||
|
||||
publish-npm:
|
||||
needs: build
|
||||
runs-on: docker
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '22.x'
|
||||
check-latest: true
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v4
|
||||
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 }}
|
||||
|
|
@ -35,7 +35,12 @@
|
|||
"scripts": {
|
||||
"start": "rm -rf lib/* && webpack --mode development -w",
|
||||
"build": "rm -rf lib/* docs/* && npx typedoc && webpack --mode production",
|
||||
"lint": "eslint src --fix && prettier --write \"src/**/*.{ts,json}\""
|
||||
"test": "tsc --noEmit",
|
||||
"format": "prettier --check \"src/**/*.{ts,json}\"",
|
||||
"format:fix": "prettier --write \"src/**/*.{ts,json}\"",
|
||||
"lint": "eslint src",
|
||||
"lint:fix": "eslint src --fix",
|
||||
"fix": "npm run lint:fix && npm run format:fix"
|
||||
},
|
||||
"main": "lib/main.js",
|
||||
"types": "lib/src/main.d.ts",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue