Skip to content

Build binaries test

Build binaries test #5

name: Build wheels & binaries
on:
push:
branches: [ az-build-action ]
permissions:
contents: read
env:
# Update this list if you add/remove supported CPython versions
PY_VERSIONS: "3.12"
jobs:
# ---------------------------
# 1) Wheels for multiple Pythons
# ---------------------------
wheels:
name: Wheels (pyc) · CPython ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Resolve version from pyjamaz.settings.APP_VERSION
id: version
shell: bash
run: |
VERSION=$(PYTHONPATH=. python - <<'PY'
import importlib
mod = importlib.import_module("pyjamaz.settings")
print(mod.APP_VERSION)
PY
)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install build tooling
run: |
python -m pip install --upgrade pip
pip install build pyc_wheel
- name: Build universal wheel
run: python -m build --wheel
- name: Rename wheel to cp tag
run: |
# Find the built wheel (assumed to be py3-none-any)
WHEEL=$(ls dist/*.whl | head -n1)
echo "Found wheel: $WHEEL"
# Compute CPython ABI tag for this interpreter (e.g., cp312)
ABI="cp$(python - <<'PY'
import sys
print(f"{sys.version_info.major}{sys.version_info.minor}")
PY
)"
# Build new name: pyjamaz-${{ steps.version.outputs.version }}-${ABI}-none-any.whl
BASE="pyjamaz-${{ steps.version.outputs.version }}-${ABI}-none-any.whl"
echo "BASE=$BASE"
mv "$WHEEL" "dist/$BASE"
echo "RENAMED_WHEEL=dist/$BASE" >> $GITHUB_ENV
- name: Compile .py to .pyc inside the wheel
run: python -m pyc_wheel "$RENAMED_WHEEL"
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python-version }}-v${{ steps.version.outputs.version }}
path: dist/*.whl
if-no-files-found: error
# ---------------------------
# 2) PyInstaller binaries per OS/arch
# ---------------------------
binaries:
name: Binary · ${{ matrix.label }}
# macos-13 = Intel (x86_64), macos-14 = Apple Silicon (arm64)
# ubuntu-22.04 = x64, ubuntu-22.04-arm64 = ARM64
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-22.04
os_tag: linux
arch: x86_64
label: Linux x86_64
# - runner: ubuntu-22.04-arm64
# os_tag: linux
# arch: aarch64
# label: Linux aarch64
# - runner: macos-13
# os_tag: macos
# arch: x86_64
# label: macOS x86_64
- runner: macos-14
os_tag: macos
arch: arm64
label: macOS arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Resolve version from pyjamaz.settings.APP_VERSION
id: version
shell: bash
run: |
VERSION=$(PYTHONPATH=. python - <<'PY'
import importlib
mod = importlib.import_module("pyjamaz.settings")
print(mod.APP_VERSION)
PY
)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install package & PyInstaller
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pyinstaller
- name: Build one-file binary
run: |
set -eux
# Ensure CLI entrypoint is discoverable
BIN_PATH="$(which pyjamaz)"
echo "pyjamaz entrypoint: $BIN_PATH"
pyinstaller --onefile --name pyjamaz --collect-data pyjamaz "$BIN_PATH"
# Zip with version + platform in filename
VERSION="${{ steps.version.outputs.version }}"
OUT_ZIP="dist/pyjamaz-${VERSION}-${{ matrix.os_tag }}-${{ matrix.arch }}.zip"
(cd dist && zip -r "$(basename "$OUT_ZIP")" pyjamaz*)
echo "OUT_ZIP=$OUT_ZIP" >> $GITHUB_ENV
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.os_tag }}-${{ matrix.arch }}-v${{ steps.version.outputs.version }}
path: ${{ env.OUT_ZIP }}
if-no-files-found: error
# ---------------------------
# 3) (Optional) Collect & publish on tag
# ---------------------------
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [wheels, binaries]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create GitHub Release (attach all files)
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/**/*