-
Notifications
You must be signed in to change notification settings - Fork 4
254 lines (224 loc) · 7.86 KB
/
build-windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: Build Windows Executable
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: './dweam_web/pnpm-lock.yaml'
# TODO figure out how properly format the key for this without introducing weird bugs again
# - name: Cache frontend build
# uses: actions/cache@v4
# with:
# path: ./dweam_web/dist
# key: ${{ runner.os }}-pnpm-build-${{ hashFiles('dweam_web/src/**') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-build-
- name: Install frontend
working-directory: dweam_web
shell: cmd
run: |
pnpm install
- name: Build frontend
working-directory: dweam_web
shell: cmd
run: |
pnpm build
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Visual Studio Build Tools
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- name: Install Poetry
run: |
pipx install poetry==1.8.1
poetry config installer.parallel false
- name: Inject Poetry PyInstaller Plugin
run: |
pipx inject poetry poetry-pyinstaller-plugin
- name: Cache Poetry dependencies
uses: actions/cache@v4
with:
path: |
./.venv
C:\Users\runneradmin\AppData\Local\pypoetry\Cache
C:\Users\runneradmin\AppData\Local\pip\Cache
key: ${{ runner.os }}-poetry-deps-${{ hashFiles('poetry.lock', '.github/workflows/build-windows.yml') }}
- name: Install Python dependencies
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction -E local
poetry run pip install pyinstaller
- name: Prepare Node.js
shell: cmd
run: |
echo Copying Node.js executable...
copy "C:\Program Files\nodejs\node.exe" "node.exe"
if not exist node.exe (
echo Failed to copy node.exe
exit 1
)
echo Installing production dependencies...
copy dweam_web\package.json package.json
copy dweam_web\pnpm-lock.yaml pnpm-lock.yaml
pnpm install --prod --frozen-lockfile --shamefully-hoist
echo Copying Node.js built-in modules...
robocopy "C:\Program Files\nodejs\node_modules" "node_modules" /E /NFL /NDL /NJH /NJS /nc /ns /np || exit 0
echo Verifying critical dependencies...
if not exist "node_modules\react" (
echo ERROR: React module is missing!
dir /s node_modules
exit 1
)
if not exist "node_modules\@astrojs" (
echo ERROR: Astro modules are missing!
dir /s node_modules
exit 1
)
echo Pruning unnecessary files...
for /d %%d in (node_modules\*) do (
if exist "%%d\.git" rmdir /s /q "%%d\.git"
if exist "%%d\test" rmdir /s /q "%%d\test"
if exist "%%d\tests" rmdir /s /q "%%d\tests"
if exist "%%d\docs" rmdir /s /q "%%d\docs"
if exist "%%d\example" rmdir /s /q "%%d\example"
if exist "%%d\examples" rmdir /s /q "%%d\examples"
)
- name: Prepare build environment
shell: cmd
run: |
echo Preparing package structure...
mkdir dweam_pkg
copy pyproject.toml dweam_pkg\
copy poetry.lock dweam_pkg\
copy README.md dweam_pkg\
xcopy /E /I dweam dweam_pkg\dweam
- name: Build Windows debug executable
shell: cmd
run: |
echo Building debug version...
poetry run pyinstaller main.py --name dweam-debug ^
--console ^
--add-data "dweam_web\dist\server;frontend\server" ^
--add-data "dweam_web\dist\client;frontend\client" ^
--add-binary "node.exe;." ^
--add-data "node_modules;node_modules" ^
--add-data "%pythonLocation%;python" ^
--add-data "dweam_pkg;dweam" ^
--add-data "assets;assets" ^
--icon "assets\icon.ico" ^
--hidden-import venv ^
--hidden-import ensurepip ^
--hidden-import pip ^
--hidden-import setuptools ^
--hidden-import wheel ^
--hidden-import dweam ^
--log-level INFO > pyinstaller_build_debug.log 2>&1
echo Verifying debug build output...
dir dist\dweam-debug\_internal\frontend /s
dir dist\dweam-debug\_internal\dweam /s
if not exist "dist\dweam-debug\_internal\frontend\client" (
echo ERROR: Frontend client files are missing from debug build output!
exit 1
)
if not exist "dist\dweam-debug\_internal\frontend\server" (
echo ERROR: Frontend server files are missing from debug build output!
exit 1
)
type pyinstaller_build_debug.log
- name: Upload debug artifact
uses: actions/upload-artifact@v4
with:
name: dweam-windows-debug
path: dist/dweam-debug/*
- name: Build Windows release executable
shell: cmd
run: |
echo Building release version...
poetry run pyinstaller main.py --name dweam ^
--noconsole ^
--add-data "dweam_web\dist\server;frontend\server" ^
--add-data "dweam_web\dist\client;frontend\client" ^
--add-binary "node.exe;." ^
--add-data "node_modules;node_modules" ^
--add-data "%pythonLocation%;python" ^
--add-data "dweam_pkg;dweam" ^
--add-data "assets;assets" ^
--icon "assets\icon.ico" ^
--hidden-import venv ^
--hidden-import ensurepip ^
--hidden-import pip ^
--hidden-import setuptools ^
--hidden-import wheel ^
--hidden-import dweam ^
--log-level INFO > pyinstaller_build_release.log 2>&1
echo Verifying release build output...
# if not exist "dist\dweam.exe" (
# echo ERROR: Release executable is missing!
# exit 1
# )
dir dist\dweam\_internal\frontend /s
dir dist\dweam\_internal\dweam /s
if not exist "dist\dweam\_internal\frontend\client" (
echo ERROR: Frontend client files are missing from release build output!
exit 1
)
if not exist "dist\dweam\_internal\frontend\server" (
echo ERROR: Frontend server files are missing from release build output!
exit 1
)
type pyinstaller_build_release.log
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: dweam-windows
# path: dist/dweam.exe
path: dist/dweam/*
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Zip release artifacts
run: |
cd artifacts
zip -r dweam-windows.zip dweam-windows/
zip -r dweam-windows-debug.zip dweam-windows-debug/
- name: Create Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Release 0.0.${{ github.run_number }}
tag_name: v0.0.${{ github.run_number }}
draft: false
prerelease: false
files: |
artifacts/dweam-windows.zip
artifacts/dweam-windows-debug.zip
generate_release_notes: true