docker-compose: Don't mount dweam_web in frontend #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |