Skip to content

Commit ccd41cf

Browse files
committed
ci: add CI and release workflows for automated testing and deployment
1 parent c2184ac commit ccd41cf

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: pnpm/action-setup@v2
21+
with:
22+
version: 8
23+
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: 'pnpm'
29+
30+
- name: Install dependencies
31+
run: pnpm install --frozen-lockfile
32+
33+
- name: Run linter
34+
run: pnpm lint:ci
35+
36+
- name: Run type check
37+
run: pnpm tsc
38+
39+
- name: Run tests
40+
run: pnpm test:ci
41+
42+
- name: Upload coverage reports
43+
uses: codecov/codecov-action@v3
44+
if: matrix.node-version == '20.x'
45+
with:
46+
file: ./coverage/clover.xml
47+
flags: unittests
48+
name: codecov-umbrella
49+
50+
- name: Build package
51+
run: pnpm build

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
id-token: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- uses: pnpm/action-setup@v2
22+
with:
23+
version: 8
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: '20.x'
28+
registry-url: 'https://registry.npmjs.org'
29+
cache: 'pnpm'
30+
31+
- name: Install dependencies
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Run tests
35+
run: pnpm test:ci
36+
37+
- name: Build package
38+
run: pnpm build
39+
40+
- name: Publish to npm
41+
run: pnpm publish --no-git-checks --access public
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)