Skip to content

feat: add req count #11

feat: add req count

feat: add req count #11

Workflow file for this run

name: Build PackyCode macOS app
on:
workflow_dispatch:
inputs:
publish:
description: "Publish a GitHub Release with the built zip"
required: false
default: "false"
tag:
description: "Release tag when publishing from manual run (optional)"
required: false
default: ""
release_name:
description: "Release title (optional)"
required: false
default: ""
prerelease:
description: "Mark as prerelease"
required: false
default: "false"
draft:
description: "Create as draft"
required: false
default: "false"
make_latest:
description: "Latest flag: true | false | legacy"
required: false
default: "true"
push:
tags:
- 'v*'
paths:
- '**'
permissions:
contents: write
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
working-directory: ${{ steps.wd.outputs.dir }}
run: |
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
working-directory: ${{ steps.wd.outputs.dir }}
run: |
set -euo pipefail
ICON=assets/icon.png
if [[ ! -f "$ICON" ]]; then
echo "[warn] $ICON not found. Will probe common locations and fallback to placeholder."
for CAND in icon.png Icon.png ICON.png images/icon.png assets/Icon.png; do
if [[ -f "$CAND" ]]; then
mkdir -p assets
cp "$CAND" "$ICON"
echo "[ok] Copied $CAND -> $ICON"
break
fi
done
fi
if [[ ! -f "$ICON" ]]; then
python -c "import base64, pathlib; pathlib.Path('assets').mkdir(parents=True, exist_ok=True); open('assets/icon.png','wb').write(base64.b64decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMB/ai4E4QAAAAASUVORK5CYII='))";
echo "[ok] Generated placeholder icon at $ICON"
else
echo "[ok] Found $ICON"
fi
- name: Build .app
working-directory: ${{ steps.wd.outputs.dir }}
run: |
python setup.py py2app -q
- name: Archive app (zip)
working-directory: ${{ steps.wd.outputs.dir }}/dist
run: |
ditto -c -k --sequesterRsrc --keepParent PackyCode.app PackyCode-macOS.zip
- name: Prepare release metadata
id: relmeta
run: |
if [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
echo "REL_TAG=${{ github.ref_name }}" >> "$GITHUB_ENV"
else
if [[ -n "${{ inputs.tag }}" ]]; then
echo "REL_TAG=${{ inputs.tag }}" >> "$GITHUB_ENV"
else
echo "REL_TAG=build-${{ github.run_number }}" >> "$GITHUB_ENV"
fi
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: PackyCode-macOS
path: |
${{ steps.wd.outputs.dir }}/dist/PackyCode-macOS.zip
- name: Publish GitHub Release
if: inputs.publish == 'true' || startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.REL_TAG }}
name: ${{ inputs.release_name != '' && inputs.release_name || env.REL_TAG }}
files: |
${{ steps.wd.outputs.dir }}/dist/PackyCode-macOS.zip
target_commitish: ${{ github.sha }}
generate_release_notes: true
make_latest: ${{ inputs.make_latest != '' && inputs.make_latest || 'true' }}
draft: ${{ inputs.draft == 'true' }}
prerelease: ${{ inputs.prerelease == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}