Skip to content

Commit cbebb41

Browse files
committed
ci: 优化 workflow (check + build + release)
1 parent 64d5a4a commit cbebb41

1 file changed

Lines changed: 97 additions & 80 deletions

File tree

.github/workflows/build.yml

Lines changed: 97 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,112 @@
1-
name: Build & Release
1+
name: CI
22

33
on:
44
push:
5-
tags: ['v*']
6-
workflow_dispatch:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
79

810
jobs:
9-
build-frontend:
10-
name: Build Frontend
11+
check-frontend:
12+
name: Check Frontend
1113
runs-on: ubuntu-latest
1214
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v4
15-
with:
16-
submodules: recursive
17-
18-
- name: Setup Node.js
19-
uses: actions/setup-node@v4
20-
with:
21-
node-version: '22'
22-
23-
- name: Install pnpm
24-
uses: pnpm/action-setup@v4
25-
with:
26-
version: 10
27-
28-
- name: Install and Build
29-
working-directory: ChuChartManager/Front
30-
run: |
31-
pnpm install
32-
pnpm build
33-
34-
- name: Upload wwwroot
35-
uses: actions/upload-artifact@v4
36-
with:
37-
name: wwwroot
38-
path: ChuChartManager/wwwroot
39-
40-
build-backend:
41-
name: Build Backend
15+
- uses: actions/checkout@v4
16+
with:
17+
submodules: recursive
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: "22"
22+
23+
- uses: pnpm/action-setup@v4
24+
with:
25+
version: 10
26+
27+
- name: Install
28+
working-directory: ChuChartManager/Front
29+
run: pnpm install
30+
31+
- name: Type Check
32+
working-directory: ChuChartManager/Front
33+
run: pnpm vue-tsc --noEmit
34+
35+
- name: Build
36+
working-directory: ChuChartManager/Front
37+
run: pnpm build
38+
39+
check-backend:
40+
name: Check Backend
41+
runs-on: windows-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
with:
45+
submodules: recursive
46+
47+
- uses: actions/setup-dotnet@v4
48+
with:
49+
dotnet-version: "10.0.x"
50+
dotnet-quality: "preview"
51+
52+
- name: Build
53+
run: dotnet build ChuChartManager/ChuChartManager.csproj -c Release
54+
55+
build:
56+
name: Build
4257
runs-on: windows-latest
43-
needs: build-frontend
58+
needs: [check-frontend, check-backend]
4459
steps:
45-
- name: Checkout
46-
uses: actions/checkout@v4
47-
with:
48-
submodules: recursive
49-
50-
- name: Setup .NET
51-
uses: actions/setup-dotnet@v4
52-
with:
53-
dotnet-version: '10.0.x'
54-
dotnet-quality: 'preview'
55-
56-
- name: Download wwwroot
57-
uses: actions/download-artifact@v4
58-
with:
59-
name: wwwroot
60-
path: ChuChartManager/wwwroot
61-
62-
- name: Publish
63-
run: |
64-
dotnet publish ChuChartManager/ChuChartManager.csproj -c Release -r win-x64 --self-contained -o publish /p:PublishSingleFile=false
65-
66-
- name: Package
67-
shell: pwsh
68-
run: |
69-
Compress-Archive -Path publish/* -DestinationPath ChuChartManager-win-x64.zip
70-
71-
- name: Upload artifact
72-
uses: actions/upload-artifact@v4
73-
with:
74-
name: ChuChartManager-win-x64
75-
path: ChuChartManager-win-x64.zip
60+
- uses: actions/checkout@v4
61+
with:
62+
submodules: recursive
63+
64+
- uses: actions/setup-node@v4
65+
with:
66+
node-version: "22"
67+
68+
- uses: pnpm/action-setup@v4
69+
with:
70+
version: 10
71+
72+
- uses: actions/setup-dotnet@v4
73+
with:
74+
dotnet-version: "10.0.x"
75+
dotnet-quality: "preview"
76+
77+
- name: Build Frontend
78+
working-directory: ChuChartManager/Front
79+
run: |
80+
pnpm install
81+
pnpm build
82+
83+
- name: Publish
84+
run: dotnet publish ChuChartManager/ChuChartManager.csproj -c Release -r win-x64 --self-contained -o publish /p:PublishSingleFile=false
85+
86+
- name: Package
87+
shell: pwsh
88+
run: Compress-Archive -Path publish/* -DestinationPath ChuChartManager-win-x64.zip
89+
90+
- name: Upload artifact
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: ChuChartManager-win-x64
94+
path: ChuChartManager-win-x64.zip
7695

7796
release:
78-
name: Create Release
79-
runs-on: ubuntu-latest
80-
needs: build-backend
97+
name: Release
8198
if: startsWith(github.ref, 'refs/tags/v')
99+
needs: build
100+
runs-on: ubuntu-latest
82101
permissions:
83102
contents: write
84103
steps:
85-
- name: Download artifact
86-
uses: actions/download-artifact@v4
87-
with:
88-
name: ChuChartManager-win-x64
89-
90-
- name: Create Release
91-
uses: softprops/action-gh-release@v2
92-
with:
93-
files: ChuChartManager-win-x64.zip
94-
generate_release_notes: true
95-
prerelease: true
104+
- uses: actions/download-artifact@v4
105+
with:
106+
name: ChuChartManager-win-x64
107+
108+
- uses: softprops/action-gh-release@v2
109+
with:
110+
files: ChuChartManager-win-x64.zip
111+
generate_release_notes: true
112+
prerelease: false

0 commit comments

Comments
 (0)