Skip to content

Commit 819739e

Browse files
committed
refactor(workflow): 合并相似构建作业以提升效率
合并了Windows安装包和便携包的构建作业,以及Python zipapp和wheel的构建作业, 通过条件判断实现单一工作流处理多个构建类型,从而加快构建速度并节约成本。
1 parent 3fdc088 commit 819739e

1 file changed

Lines changed: 25 additions & 42 deletions

File tree

.github/workflows/build.yml

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ permissions:
4242
contents: read
4343

4444
jobs:
45-
build-windows-installer:
46-
if: ${{ inputs.build-windows-installer }}
47-
name: Build Windows Installer
45+
# 合并相似的构建以加快速度、节约成本。
46+
build-windows-installer-and-portable:
47+
if: ${{ inputs.build-windows-installer || inputs.build-windows-portable }}
48+
name: Build Windows Installer and Portable
4849
runs-on: windows-latest
4950
env:
5051
UV_NO_DEFAULT_GROUPS: true
@@ -55,44 +56,35 @@ jobs:
5556
with:
5657
python-version-file: ".python-version"
5758

58-
- name: Build Portable Package
59+
- name: Build Installer
60+
if: ${{ inputs.build-windows-installer }}
5961
run: uv run --group build --group basic poe build-installer
6062

61-
- name: Upload Package
63+
- name: Build Portable Package
64+
if: ${{ inputs.build-windows-portable }}
65+
run: uv run --group build --group basic poe build-portable
66+
67+
- name: Upload Installer
6268
id: upload-package
69+
if: ${{ inputs.build-windows-installer }}
6370
uses: actions/upload-artifact@v7
6471
with:
6572
name: windows-installer
6673
path: dist/*-setup.exe
6774
if-no-files-found: error
6875

69-
build-windows-portable:
70-
if: ${{ inputs.build-windows-portable }}
71-
name: Build Windows Portable Package
72-
runs-on: windows-latest
73-
env:
74-
UV_NO_DEFAULT_GROUPS: true
75-
steps:
76-
- uses: actions/checkout@v6
77-
- uses: astral-sh/setup-uv@v8.0.0
78-
- uses: actions/setup-python@v6
79-
with:
80-
python-version-file: ".python-version"
81-
82-
- name: Build Portable Package
83-
run: uv run --group build --group basic poe build-portable
84-
85-
- name: Upload Package
76+
- name: Upload Portable Package
8677
id: upload-package
78+
if: ${{ inputs.build-windows-portable }}
8779
uses: actions/upload-artifact@v7
8880
with:
8981
name: windows-portable
9082
path: dist/*-portable.zip
9183
if-no-files-found: error
9284

93-
build-python3-zipapp:
94-
if: ${{ inputs.build-python3-zipapp }}
95-
name: Build Python 3 Zip Application
85+
build-python3-zipapp-and-wheel:
86+
if: ${{ inputs.build-python3-zipapp || inputs.build-python3-wheel }}
87+
name: Build Python 3 ZIP Application and Wheel
9688
runs-on: ubuntu-latest
9789
env:
9890
UV_NO_DEFAULT_GROUPS: true
@@ -104,34 +96,25 @@ jobs:
10496
python-version-file: ".python-version"
10597

10698
- name: Build Zipapp
99+
if: ${{ inputs.build-python3-zipapp }}
107100
run: uv run --group build --group basic poe build-zipapp
108101

109-
- name: Upload Package
102+
- name: Build Wheel
103+
if: ${{ inputs.build-python3-wheel }}
104+
run: uv run --group build --group basic poe build-wheel
105+
106+
- name: Upload Zipapp
110107
id: upload-package
108+
if: ${{ inputs.build-python3-zipapp }}
111109
uses: actions/upload-artifact@v7
112110
with:
113111
name: python3-zipapp
114112
path: dist/*.pyzw
115113
if-no-files-found: error
116114

117-
build-python3-wheel:
118-
if: ${{ inputs.build-python3-wheel }}
119-
name: Build Python 3 Wheel
120-
runs-on: ubuntu-latest
121-
env:
122-
UV_NO_DEFAULT_GROUPS: true
123-
steps:
124-
- uses: actions/checkout@v6
125-
- uses: astral-sh/setup-uv@v8.0.0
126-
- uses: actions/setup-python@v6
127-
with:
128-
python-version-file: ".python-version"
129-
130-
- name: Build Wheel
131-
run: uv run --group build --group basic poe build-wheel
132-
133115
- name: Upload Wheel
134116
id: upload-wheel
117+
if: ${{ inputs.build-python3-wheel }}
135118
uses: actions/upload-artifact@v7
136119
with:
137120
name: python3-wheel

0 commit comments

Comments
 (0)