Skip to content

Commit 3c63d20

Browse files
committed
add github action workflow
1 parent da728e2 commit 3c63d20

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed

.github/workflows/ci.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
lint:
13+
name: Lint
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest]
17+
18+
runs-on: ${{ matrix.os }}
19+
20+
steps:
21+
- name: Checkout codes
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Lint codes
27+
run: bun run lint
28+
29+
build:
30+
name: Build
31+
strategy:
32+
matrix:
33+
os: [ubuntu-latest]
34+
node: [18.x]
35+
36+
runs-on: ${{ matrix.os }}
37+
38+
steps:
39+
- name: Checkout codes
40+
uses: actions/checkout@v4
41+
42+
- name: Setup bun
43+
uses: oven-sh/setup-bun@v1
44+
45+
- name: Enable corepack
46+
run: corepack enable
47+
48+
- name: Setup node
49+
uses: actions/setup-node@v3
50+
with:
51+
node-version: ${{ matrix.node }}
52+
53+
- name: Install dependencies
54+
run: bun install
55+
56+
- name: Build codes
57+
run: bun run build
58+
59+
test:
60+
name: Test
61+
strategy:
62+
matrix:
63+
os: [ubuntu-latest]
64+
node: [18.x]
65+
66+
runs-on: ${{ matrix.os }}
67+
68+
steps:
69+
- name: Checkout codes
70+
uses: actions/checkout@v4
71+
72+
- name: Setup bun
73+
uses: oven-sh/setup-bun@v1
74+
75+
- name: Setup node
76+
uses: actions/setup-node@v3
77+
with:
78+
node-version: ${{ matrix.node }}
79+
80+
- name: Enable corepack
81+
run: corepack enable
82+
83+
- name: Install dependencies
84+
run: bun install
85+
86+
- name: Build codes
87+
run: bun run test
88+
89+
edge-release:
90+
name: Edge Release
91+
needs:
92+
- lint
93+
- build
94+
- test
95+
runs-on: ${{ matrix.os }}
96+
strategy:
97+
matrix:
98+
os: [ubuntu-latest]
99+
node: [18]
100+
steps:
101+
- name: Checkout codes
102+
uses: actions/checkout@v4
103+
104+
- name: Setup bun
105+
uses: oven-sh/setup-bun@v1
106+
107+
- uses: actions/setup-node@v3
108+
with:
109+
node-version: ${{ matrix.node }}
110+
111+
- name: Enable corepack
112+
run: corepack enable
113+
114+
- name: Install dependencies
115+
run: bun install
116+
117+
- name: Build
118+
run: bun run build
119+
120+
- name: Release Edge
121+
if: |
122+
github.event_name == 'push' &&
123+
!startsWith(github.event.head_commit.message, '[skip-release]') &&
124+
!startsWith(github.event.head_commit.message, 'chore') &&
125+
!startsWith(github.event.head_commit.message, 'release') &&
126+
!startsWith(github.event.head_commit.message, 'docs')
127+
run: ./scripts/release.sh
128+
env:
129+
NPM_TOKEN: ${{secrets.NPM_ORG_TOKEN}}
130+
EDGE_RELEASE: 'true'

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- '**'
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout codes
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.head_ref }}
19+
20+
- name: Setup bun
21+
uses: oven-sh/setup-bun@v1
22+
23+
- name: Setup Node
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: 18
27+
28+
- name: Enable corepack
29+
run: corepack enable
30+
31+
- name: Extract version tag
32+
if: startsWith( github.ref, 'refs/tags/v' )
33+
uses: jungwinter/split@v2
34+
id: split
35+
with:
36+
msg: ${{ github.ref }}
37+
separator: '/'
38+
39+
- name: Create Github Release
40+
run: gh release create ${{ steps.split.outputs._2 }} --generate-notes
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Generate changelog
45+
run: |
46+
git restore --source=HEAD --staged --worktree -- package.json bun.lockb
47+
bun install
48+
bun run build
49+
bun run changelog -- --tag=${{ steps.split.outputs._2 }}
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Commit changelog
54+
uses: stefanzweifel/git-auto-commit-action@v4
55+
with:
56+
branch: main
57+
file_pattern: '*.md'
58+
commit_message: 'chore: sync changelog'
59+
60+
- name: Publish package
61+
run: ./scripts/release.sh
62+
env:
63+
NPM_TOKEN: ${{secrets.NPM_ORG_TOKEN}}

0 commit comments

Comments
 (0)