Build PackyCode macOS app #6
This file contains hidden or 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 PackyCode macOS app | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| tags: | |
| - 'v*' | |
| paths: | |
| - '**' | |
| jobs: | |
| build-macos: | |
| runs-on: macos-14 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Determine working directory (repo root vs subfolder) | |
| id: wd | |
| shell: bash | |
| run: | | |
| if [[ -f requirements.txt && -f setup.py && -f main.py ]]; then | |
| echo "wd=." >> "$GITHUB_ENV" | |
| echo "dir=." >> "$GITHUB_OUTPUT" | |
| echo "Workspace looks like packycode root"; | |
| elif [[ -f packycode/requirements.txt && -f packycode/setup.py ]]; then | |
| echo "wd=packycode" >> "$GITHUB_ENV" | |
| echo "dir=packycode" >> "$GITHUB_OUTPUT" | |
| echo "Workspace looks like monorepo; using packycode/ as WD"; | |
| else | |
| echo "Unable to locate requirements.txt/setup.py" >&2 | |
| ls -la | |
| exit 1 | |
| fi | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/Library/Caches/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| - name: Install dependencies | |
| run: | | |
| cd "$wd" | |
| python -m pip install --upgrade pip | |
| pip uninstall -y wheel || true | |
| pip install -r requirements.txt | |
| pip install py2app | |
| - name: Ensure icon exists (fallback if missing) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| cd "$wd" | |
| ICON=assets/icon.png | |
| if [[ ! -f "$ICON" ]]; then | |
| echo "[warn] $ICON not found. Generating a tiny placeholder icon..." | |
| mkdir -p assets | |
| python - <<'PY' | |
| import base64, os | |
| png_b64 = ( | |
| 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMB/ai4E4QAAAAASUVORK5CYII=' | |
| ) | |
| with open('assets/icon.png', 'wb') as f: | |
| f.write(base64.b64decode(png_b64)) | |
| print('Wrote assets/icon.png (1x1 placeholder)') | |
| PY | |
| else | |
| echo "[ok] Found $ICON" | |
| fi | |
| - name: Build .app | |
| run: | | |
| cd "$wd" | |
| python setup.py py2app -q | |
| - name: Archive app (zip) | |
| run: | | |
| cd "$wd/dist" | |
| ditto -c -k --sequesterRsrc --keepParent PackyCode.app PackyCode-macOS.zip | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: PackyCode-macOS | |
| path: | | |
| ${{ steps.wd.outputs.dir }}/dist/PackyCode-macOS.zip | |
| - name: Create GitHub Release (on tag) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| ${{ steps.wd.outputs.dir }}/dist/PackyCode-macOS.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |