Skip to content

Commit dacf2f9

Browse files
authored
Add workflows (#506)
1 parent cddc420 commit dacf2f9

File tree

5 files changed

+151
-14
lines changed

5 files changed

+151
-14
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- main
77
pull_request:
88

9+
permissions:
10+
contents: read # to fetch code (actions/checkout)
11+
912
jobs:
1013
build-and-test:
1114
runs-on: ${{ matrix.os }}
@@ -14,6 +17,7 @@ jobs:
1417
os: [ubuntu-latest, macos-latest, windows-latest]
1518
node_version: [20, 22]
1619
fail-fast: false
20+
timeout-minutes: 10
1721

1822
name: 'Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
1923
steps:
@@ -54,6 +58,7 @@ jobs:
5458

5559
lint:
5660
runs-on: ubuntu-latest
61+
timeout-minutes: 10
5762
name: 'Lint: node-20, ubuntu-latest'
5863
steps:
5964
- name: Checkout
@@ -81,6 +86,7 @@ jobs:
8186

8287
audit:
8388
runs-on: ubuntu-latest
89+
timeout-minutes: 10
8490
name: 'Audit: node-20, ubuntu-latest'
8591
steps:
8692
- name: Checkout

.github/workflows/coverage.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Coverage
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
# Required to checkout the code
8+
contents: read
9+
10+
jobs:
11+
coverage-pr:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
16+
17+
- name: Install pnpm
18+
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
19+
20+
- name: Set node version to 20
21+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
22+
with:
23+
node-version: 20
24+
cache: 'pnpm'
25+
26+
- name: Install dependencies
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Build
30+
run: pnpm run build
31+
32+
- name: Test
33+
run: pnpm run test:coverage
34+
continue-on-error: true
35+
36+
- name: Upload Coverage
37+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
38+
with:
39+
name: coverage-${{ github.run_id }}
40+
path: coverage
41+
retention-days: 15
42+
43+
coverage-main:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
48+
with:
49+
ref: main
50+
51+
- name: Install pnpm
52+
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
53+
54+
- name: Set node version to 20
55+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
56+
with:
57+
node-version: 20
58+
cache: 'pnpm'
59+
60+
- name: Install dependencies
61+
run: pnpm install --frozen-lockfile
62+
63+
- name: Build
64+
run: pnpm run build
65+
66+
- name: Test
67+
run: pnpm run test:coverage
68+
continue-on-error: true
69+
70+
- name: Upload Coverage
71+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
72+
with:
73+
name: coverage-main
74+
path: coverage

.github/workflows/docs.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,62 @@
1-
name: docs
1+
name: Deploy GitHub Pages
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [main]
67
paths:
78
- 'docs/**'
8-
workflow_dispatch:
9+
- '.github/workflows/docs.yml'
10+
- 'package.json'
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
920

1021
jobs:
11-
docs:
22+
build-docs:
1223
runs-on: ubuntu-latest
13-
1424
steps:
15-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
25+
- name: Checkout
26+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
1627
with:
1728
fetch-depth: 0
1829

1930
- name: Install pnpm
2031
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
2132

22-
- name: Setup Node.js
33+
- name: Set node version to 20
2334
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
2435
with:
2536
node-version: 20
2637
cache: 'pnpm'
2738

39+
- name: Setup Pages
40+
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
41+
2842
- name: Install dependencies
2943
run: pnpm install --frozen-lockfile
3044

31-
- name: Build VitePress site
45+
- name: Build with VitePress
3246
run: pnpm run docs:build
3347

34-
- name: Deploy to GitHub Pages
35-
uses: crazy-max/ghaction-github-pages@c05ee637ec73429400a359430db8e5629f3f2564 # v4.0.0
48+
- name: Upload artifact
49+
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
3650
with:
37-
target_branch: gh-pages
38-
build_dir: docs/.vitepress/dist
39-
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
path: ./docs/.vitepress/dist/
52+
53+
deploy-docs:
54+
runs-on: ubuntu-latest
55+
needs: build-docs
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
steps:
60+
- name: Deploy to GitHub Pages
61+
id: deployment
62+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
if: github.ref == 'refs/heads/main'
9+
runs-on: ubuntu-latest
10+
name: Release
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
14+
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
17+
18+
- name: Set node version to 20
19+
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
20+
with:
21+
node-version: 20
22+
cache: 'pnpm'
23+
24+
- name: Prepare
25+
run: pnpm install --frozen-lockfile
26+
27+
- name: Set publishing config
28+
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
29+
env:
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31+
32+
- name: Publish
33+
run: |
34+
PACKAGE_DIST_TAG=$(node -e "console.log(/^\d+\.\d+\.\d+(\-(\w+)\.\d+)$/.exec(require('./package.json').version)?.[2] || 'latest')")
35+
pnpm publish --access public --tag $PACKAGE_DIST_TAG

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"lint": "eslint --cache --cache-strategy content --report-unused-disable-directives .",
1515
"ts-check": "tsc",
1616
"test": "vitest",
17-
"coverage": "vitest run --coverage",
17+
"test:coverage": "vitest run --coverage",
1818
"prepublishOnly": "pnpm run clean && pnpm install && pnpm run build",
1919
"preflight": "pnpm install && run-s format lint build test ts-check"
2020
},

0 commit comments

Comments
 (0)