|
| 1 | +name: Build wheels & binaries |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ az-build-action ] |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +env: |
| 10 | + # Update this list if you add/remove supported CPython versions |
| 11 | + PY_VERSIONS: "3.12" |
| 12 | + |
| 13 | +jobs: |
| 14 | + # --------------------------- |
| 15 | + # 1) Wheels for multiple Pythons |
| 16 | + # --------------------------- |
| 17 | + wheels: |
| 18 | + name: Wheels (pyc) · CPython ${{ matrix.python-version }} |
| 19 | + runs-on: ubuntu-latest |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + python-version: ['3.12'] |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Set up Python ${{ matrix.python-version }} |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: ${{ matrix.python-version }} |
| 33 | + |
| 34 | + - name: Resolve version from pyjamaz.settings.APP_VERSION |
| 35 | + id: version |
| 36 | + run: | |
| 37 | + PYTHONPATH=. python - <<'PY' |
| 38 | + import os |
| 39 | + import importlib |
| 40 | + mod = importlib.import_module("pyjamaz.settings") |
| 41 | + print(f"version={mod.APP_VERSION}") |
| 42 | + PY |
| 43 | + shell: bash >> $GITHUB_OUTPUT |
| 44 | + |
| 45 | + - name: Install build tooling |
| 46 | + run: | |
| 47 | + python -m pip install --upgrade pip |
| 48 | + pip install build pyc_wheel |
| 49 | +
|
| 50 | + - name: Build universal wheel |
| 51 | + run: python -m build --wheel |
| 52 | + |
| 53 | + - name: Rename wheel to cp tag |
| 54 | + run: | |
| 55 | + # Find the built wheel (assumed to be py3-none-any) |
| 56 | + WHEEL=$(ls dist/*.whl | head -n1) |
| 57 | + echo "Found wheel: $WHEEL" |
| 58 | + # Compute CPython ABI tag for this interpreter (e.g., cp312) |
| 59 | + ABI="cp$(python - <<'PY' |
| 60 | + import sys |
| 61 | + print(f"{sys.version_info.major}{sys.version_info.minor}") |
| 62 | + PY |
| 63 | + )" |
| 64 | + # Build new name: pyjamaz-${{ steps.version.outputs.version }}-${ABI}-none-any.whl |
| 65 | + BASE="pyjamaz-${{ steps.version.outputs.version }}-${ABI}-none-any.whl" |
| 66 | + mv "$WHEEL" "dist/$BASE" |
| 67 | + echo "RENAMED_WHEEL=dist/$BASE" >> $GITHUB_ENV |
| 68 | +
|
| 69 | + - name: Compile .py to .pyc inside the wheel |
| 70 | + run: python -m pyc_wheel "$RENAMED_WHEEL" |
| 71 | + |
| 72 | + - name: Upload wheel artifact |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: wheel-${{ matrix.python-version }}-v${{ steps.version.outputs.version }} |
| 76 | + path: dist/*.whl |
| 77 | + if-no-files-found: error |
| 78 | + |
| 79 | + # --------------------------- |
| 80 | + # 2) PyInstaller binaries per OS/arch |
| 81 | + # --------------------------- |
| 82 | + binaries: |
| 83 | + name: Binary · ${{ matrix.label }} |
| 84 | + # macos-13 = Intel (x86_64), macos-14 = Apple Silicon (arm64) |
| 85 | + # ubuntu-22.04 = x64, ubuntu-22.04-arm64 = ARM64 |
| 86 | + runs-on: ${{ matrix.runner }} |
| 87 | + strategy: |
| 88 | + fail-fast: false |
| 89 | + matrix: |
| 90 | + include: |
| 91 | + - runner: ubuntu-22.04 |
| 92 | + os_tag: linux |
| 93 | + arch: x86_64 |
| 94 | + label: Linux x86_64 |
| 95 | + - runner: ubuntu-22.04-arm64 |
| 96 | + os_tag: linux |
| 97 | + arch: aarch64 |
| 98 | + label: Linux aarch64 |
| 99 | + - runner: macos-13 |
| 100 | + os_tag: macos |
| 101 | + arch: x86_64 |
| 102 | + label: macOS x86_64 |
| 103 | + - runner: macos-14 |
| 104 | + os_tag: macos |
| 105 | + arch: arm64 |
| 106 | + label: macOS arm64 |
| 107 | + |
| 108 | + steps: |
| 109 | + - name: Checkout |
| 110 | + uses: actions/checkout@v4 |
| 111 | + |
| 112 | + - name: Set up Python 3.12 |
| 113 | + uses: actions/setup-python@v5 |
| 114 | + with: |
| 115 | + python-version: '3.12' |
| 116 | + |
| 117 | + - name: Resolve version from pyjamaz.settings.APP_VERSION |
| 118 | + id: version |
| 119 | + run: | |
| 120 | + PYTHONPATH=. python - <<'PY' |
| 121 | + import importlib |
| 122 | + mod = importlib.import_module("pyjamaz.settings") |
| 123 | + print(f"version={mod.APP_VERSION}") |
| 124 | + PY |
| 125 | + shell: bash >> $GITHUB_OUTPUT |
| 126 | + |
| 127 | + - name: Install package & PyInstaller |
| 128 | + run: | |
| 129 | + python -m pip install --upgrade pip |
| 130 | + pip install -e . |
| 131 | + pip install pyinstaller |
| 132 | +
|
| 133 | + - name: Build one-file binary |
| 134 | + run: | |
| 135 | + set -eux |
| 136 | + # Ensure CLI entrypoint is discoverable |
| 137 | + BIN_PATH="$(which pyjamaz)" |
| 138 | + echo "pyjamaz entrypoint: $BIN_PATH" |
| 139 | + pyinstaller --onefile --name pyjamaz --collect-data pyjamaz "$BIN_PATH" |
| 140 | + # Zip with version + platform in filename |
| 141 | + VERSION="${{ steps.version.outputs.version }}" |
| 142 | + OUT_ZIP="dist/pyjamaz-${VERSION}-${{ matrix.os_tag }}-${{ matrix.arch }}.zip" |
| 143 | + (cd dist && zip -r "$(basename "$OUT_ZIP")" pyjamaz*) |
| 144 | + echo "OUT_ZIP=$OUT_ZIP" >> $GITHUB_ENV |
| 145 | +
|
| 146 | + - name: Upload binary artifact |
| 147 | + uses: actions/upload-artifact@v4 |
| 148 | + with: |
| 149 | + name: binary-${{ matrix.os_tag }}-${{ matrix.arch }}-v${{ steps.version.outputs.version }} |
| 150 | + path: ${{ env.OUT_ZIP }} |
| 151 | + if-no-files-found: error |
| 152 | + |
| 153 | + # --------------------------- |
| 154 | + # 3) (Optional) Collect & publish on tag |
| 155 | + # --------------------------- |
| 156 | + release: |
| 157 | + if: startsWith(github.ref, 'refs/tags/v') |
| 158 | + needs: [wheels, binaries] |
| 159 | + runs-on: ubuntu-latest |
| 160 | + permissions: |
| 161 | + contents: write |
| 162 | + steps: |
| 163 | + - name: Download all artifacts |
| 164 | + uses: actions/download-artifact@v4 |
| 165 | + with: |
| 166 | + path: artifacts |
| 167 | + |
| 168 | + - name: Create GitHub Release (attach all files) |
| 169 | + uses: softprops/action-gh-release@v2 |
| 170 | + with: |
| 171 | + generate_release_notes: true |
| 172 | + files: | |
| 173 | + artifacts/**/* |
0 commit comments