Skip to content

Commit 8feb4bb

Browse files
ci(workflows): build and cache package before running other workflows
1 parent c69de40 commit 8feb4bb

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-5
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build Package
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
jobs:
8+
build:
9+
name: Build the package
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@9a9194f87191a7e9055e3e9b95b8cfb13023bb08
14+
15+
- name: Setup Bun
16+
uses: oven-sh/setup-bun@b9d34de66d2a7faee36a22446c434b7c959e48d2
17+
18+
- name: Install dependencies
19+
run: bun install --frozen-lockfile
20+
21+
- name: Build package
22+
run: bun run build
23+
24+
- name: Upload package build
25+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
26+
with:
27+
name: dist@${{ github.sha }}
28+
path: dist
29+
overwrite: true

.github/workflows/check.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66

77
jobs:
8+
build:
9+
name: Build package
10+
uses: ./.github/workflows/build.yml
11+
812
check_format:
913
name: Check formatting
1014
runs-on: ubuntu-latest
@@ -23,6 +27,7 @@ jobs:
2327

2428
check_types:
2529
name: Check types
30+
needs: build
2631
runs-on: ubuntu-latest
2732
steps:
2833
- name: Checkout repo
@@ -34,11 +39,18 @@ jobs:
3439
- name: Install dependencies
3540
run: bun install --frozen-lockfile
3641

42+
- name: Download package build
43+
uses: actions/download-artifact@v4
44+
with:
45+
name: dist@${{ github.sha }}
46+
path: dist
47+
3748
- name: Run types check
3849
run: bun run type-check
3950

4051
lint:
4152
name: Lint code
53+
needs: build
4254
runs-on: ubuntu-latest
4355
steps:
4456
- name: Checkout repo
@@ -50,11 +62,18 @@ jobs:
5062
- name: Install dependencies
5163
run: bun install --frozen-lockfile
5264

65+
- name: Download package build
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: dist@${{ github.sha }}
69+
path: dist
70+
5371
- name: Run linter
5472
run: bun run lint
5573

5674
test:
57-
name: Test code
75+
name: Test package
76+
needs: build
5877
runs-on: ubuntu-latest
5978
steps:
6079
- name: Checkout repo
@@ -66,5 +85,11 @@ jobs:
6685
- name: Install dependencies
6786
run: bun install --frozen-lockfile
6887

88+
- name: Download package build
89+
uses: actions/download-artifact@v4
90+
with:
91+
name: dist@${{ github.sha }}
92+
path: dist
93+
6994
- name: Run tests
7095
run: bun run test

.github/workflows/publish.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ jobs:
3131
- name: Install dependencies
3232
run: bun install --frozen-lockfile
3333

34-
- name: Build package
35-
run: bun run build
34+
- name: Download package build
35+
uses: actions/download-artifact@d0ce8fd1167ed839810201de977912a090ab10a7
36+
with:
37+
name: dist@${{ github.sha }}
38+
path: dist
3639

3740
- name: Publish package
3841
env:
3942
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4043
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
run: bunx --bun semantic-release
44+
run: bun run publish

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@
3838
"scripts": {
3939
"build": "bun --bun tsup",
4040
"check-all": "bun --bun concurrently --kill-others=failure 'bun run test' 'bun lint' 'bun type-check' 'bun format:check'",
41-
"test": "bun run build && bun test",
41+
"test": "bun test",
4242
"format": "bun format:base --write",
4343
"format:check": "bun format:base --check",
4444
"format:base": "bun --bun prettier . --cache",
4545
"lint": "bun --bun eslint . --cache",
4646
"type-check": "bun --bun tsc",
47+
"publish": "bun --bun semantic-release",
4748
"postinstall": "bun --bun husky"
4849
},
4950
"dependencies": {

0 commit comments

Comments
 (0)