Skip to content

Commit dc89b73

Browse files
committed
ci: documentation deployment, and npm publishing workflows
1 parent a1a5a58 commit dc89b73

3 files changed

Lines changed: 172 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [18, 20, 22]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Install Playwright
30+
run: npx playwright install --with-deps
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Run tests
36+
run: npm test
37+
38+
lint:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: '20'
48+
49+
- name: Install dependencies
50+
run: npm ci
51+
52+
- name: Type check
53+
run: npx tsc --noEmit

.github/workflows/docs.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**'
9+
- 'mkdocs.yml'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: "pages"
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.x'
32+
33+
- name: Install MkDocs and dependencies
34+
run: |
35+
pip install mkdocs mkdocs-material
36+
37+
- name: Build documentation
38+
run: mkdocs build
39+
40+
- name: Setup Pages
41+
uses: actions/configure-pages@v4
42+
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: 'site'
47+
48+
deploy:
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
runs-on: ubuntu-latest
53+
needs: build
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

.github/workflows/publish.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
id-token: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Install Playwright
28+
run: npx playwright install --with-deps
29+
30+
- name: Build
31+
run: npm run build
32+
33+
- name: Run tests
34+
run: npm test
35+
36+
- name: Determine npm tag and release type
37+
id: release-info
38+
run: |
39+
TAG=${GITHUB_REF#refs/tags/v}
40+
if [[ "$TAG" == *"-"* ]]; then
41+
NPM_TAG=$(echo "$TAG" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
42+
PRERELEASE=true
43+
else
44+
NPM_TAG="latest"
45+
PRERELEASE=false
46+
fi
47+
echo "tag=$NPM_TAG" >> $GITHUB_OUTPUT
48+
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
49+
echo "version=$TAG" >> $GITHUB_OUTPUT
50+
51+
- name: Publish to npm
52+
run: npm publish --tag ${{ steps.release-info.outputs.tag }} --provenance --access public
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
56+
- name: Create GitHub Release
57+
uses: softprops/action-gh-release@v2
58+
with:
59+
generate_release_notes: true
60+
prerelease: ${{ steps.release-info.outputs.prerelease == 'true' }}
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)