Skip to content

Commit 52827bc

Browse files
committed
Fix cross-platform World Builder release packaging
1 parent 5b842c0 commit 52827bc

1 file changed

Lines changed: 104 additions & 74 deletions

File tree

.github/workflows/release.yml

Lines changed: 104 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,119 @@ on:
77
workflow_dispatch:
88
inputs:
99
version:
10-
description: 'Version to release (e.g., v1.0.0)'
10+
description: 'Version to release (e.g. v1.0.4)'
1111
required: true
1212

1313
permissions:
1414
contents: write
1515

16+
env:
17+
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.version || github.ref_name }}
18+
1619
jobs:
17-
build-and-release:
20+
build:
21+
name: Build ${{ matrix.platform }}
1822
runs-on: ${{ matrix.os }}
19-
permissions:
20-
contents: write
2123
strategy:
24+
fail-fast: false
2225
matrix:
2326
include:
24-
- os: ubuntu-latest
25-
artifact_name: world-builder-linux
26-
asset_name: world-builder-linux
27-
asset_path: dist/world-builder-linux
28-
- os: windows-latest
29-
artifact_name: world-builder-windows.exe
30-
asset_name: world-builder-windows.exe
31-
asset_path: dist/world-builder-windows.exe
32-
- os: macos-latest
33-
artifact_name: world-builder-macos
34-
asset_name: world-builder-macos
35-
asset_path: dist/world-builder-macos
27+
- platform: linux
28+
os: ubuntu-latest
29+
asset: world-builder-linux
30+
- platform: windows
31+
os: windows-latest
32+
asset: world-builder-windows.exe
33+
- platform: macos
34+
os: macos-latest
35+
asset: world-builder-macos.zip
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Set up Python
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: '3.11'
45+
46+
- name: Install Linux system dependencies
47+
if: runner.os == 'Linux'
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install -y python3-tk python3-dev libjpeg-dev libpng-dev
51+
52+
- name: Install Python dependencies
53+
run: |
54+
python -m pip install --upgrade pip
55+
python -m pip install -r requirements.txt
56+
57+
- name: Verify imports and syntax
58+
run: |
59+
python -m py_compile world_builder.py
60+
python -c "import world_builder; print('Import successful')"
3661
62+
- name: Build Linux executable
63+
if: runner.os == 'Linux'
64+
run: |
65+
pyinstaller --noconfirm --clean --onefile --name world-builder-linux --add-data="BZONE.ttf:." world_builder.py
66+
test "$(stat -c%s dist/world-builder-linux)" -gt 1000000
67+
68+
- name: Build Windows executable
69+
if: runner.os == 'Windows'
70+
shell: pwsh
71+
run: |
72+
pyinstaller --noconfirm --clean --onefile --windowed --icon=wb.ico --name world-builder-windows --add-data="BZONE.ttf;." world_builder.py
73+
$asset = Get-Item .\dist\world-builder-windows.exe
74+
if ($asset.Length -lt 1000000) { throw "Windows release asset is unexpectedly small: $($asset.Length) bytes" }
75+
76+
- name: Build and package macOS app
77+
if: runner.os == 'macOS'
78+
run: |
79+
pyinstaller --noconfirm --clean --onedir --windowed --name world_builder --add-data="BZONE.ttf:." world_builder.py
80+
test -d dist/world_builder.app
81+
ditto -c -k --sequesterRsrc --keepParent dist/world_builder.app dist/world-builder-macos.zip
82+
test "$(stat -f%z dist/world-builder-macos.zip)" -gt 1000000
83+
84+
- name: Upload packaged asset
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: world-builder-${{ matrix.platform }}
88+
path: dist/${{ matrix.asset }}
89+
if-no-files-found: error
90+
retention-days: 7
91+
92+
release:
93+
name: Publish ${{ env.RELEASE_TAG }}
94+
needs: build
95+
runs-on: ubuntu-latest
3796
steps:
38-
- uses: actions/checkout@v3
39-
40-
- name: Install system dependencies (Linux)
41-
if: runner.os == 'Linux'
42-
run: |
43-
sudo apt-get update
44-
sudo apt-get install -y python3-tk python3-dev python3-pip
45-
46-
- name: Set up Python
47-
uses: actions/setup-python@v4
48-
with:
49-
python-version: '3.11'
50-
51-
- name: Install Python dependencies
52-
run: |
53-
python -m pip install --upgrade pip
54-
pip install -r requirements.txt
55-
56-
- name: Install PIL/Pillow optional dependencies (Linux)
57-
if: runner.os == 'Linux'
58-
run: |
59-
sudo apt-get install -y libjpeg-dev libpng-dev
60-
61-
- name: Build with PyInstaller (Linux)
62-
if: runner.os == 'Linux'
63-
run: |
64-
pyinstaller --onefile \
65-
--icon=wb.ico \
66-
--name=${{ matrix.asset_name }} \
67-
--add-data="BZONE.ttf:." \
68-
world_builder.py
69-
70-
- name: Build with PyInstaller (macOS)
71-
if: runner.os == 'macOS'
72-
run: |
73-
pyinstaller --onedir \
74-
--icon=wb.ico \
75-
--name=world_builder \
76-
--add-data="BZONE.ttf:." \
77-
world_builder.py
78-
# Create a wrapper script executable
79-
cat > dist/world_builder_app << 'EOF'
80-
#!/bin/bash
81-
"$(dirname "$0")"/world_builder.app/Contents/MacOS/world_builder
82-
EOF
83-
chmod +x dist/world_builder_app
84-
mv dist/world_builder_app ${{ matrix.asset_path }}
85-
86-
- name: Build with PyInstaller (Windows)
87-
if: runner.os == 'Windows'
88-
run: |
89-
pyinstaller --onefile --icon=wb.ico --name=${{ matrix.asset_name }} --add-data="BZONE.ttf;." world_builder.py
90-
91-
- name: Upload Release Assets
92-
uses: softprops/action-gh-release@v1
93-
if: startsWith(github.ref, 'refs/tags/')
94-
with:
95-
files: ${{ matrix.asset_path }}
97+
- name: Checkout code
98+
uses: actions/checkout@v4
99+
100+
- name: Download packaged assets
101+
uses: actions/download-artifact@v4
102+
with:
103+
pattern: world-builder-*
104+
path: release-assets
105+
merge-multiple: true
106+
107+
- name: Verify release payload
108+
run: |
109+
ls -lh release-assets
110+
test "$(stat -c%s release-assets/world-builder-linux)" -gt 1000000
111+
test "$(stat -c%s release-assets/world-builder-windows.exe)" -gt 1000000
112+
test "$(stat -c%s release-assets/world-builder-macos.zip)" -gt 1000000
113+
114+
- name: Publish GitHub Release
115+
uses: softprops/action-gh-release@v2
116+
with:
117+
tag_name: ${{ env.RELEASE_TAG }}
118+
target_commitish: ${{ github.sha }}
119+
name: Release ${{ env.RELEASE_TAG }}
120+
body_path: docs/RELEASE_NOTES_${{ env.RELEASE_TAG }}.md
121+
files: release-assets/*
122+
draft: false
123+
prerelease: false
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)