|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Builds standalone binaries for Linux / macOS / Windows and publishes them |
| 4 | +# as assets on the GitHub Release corresponding to the pushed tag. |
| 5 | +# |
| 6 | +# Trigger: |
| 7 | +# - Push a git tag matching v* (e.g. v0.1.0) → builds all targets and |
| 8 | +# creates/updates a Release named after the tag. |
| 9 | +# - workflow_dispatch → manual run for debugging; requires a tag input |
| 10 | +# that already exists on the repository. |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + tags: |
| 15 | + - 'v*' |
| 16 | + workflow_dispatch: |
| 17 | + inputs: |
| 18 | + tag: |
| 19 | + description: 'Existing tag to build and release (e.g. v0.1.0)' |
| 20 | + required: true |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: write |
| 24 | + |
| 25 | +env: |
| 26 | + PYTHON_VERSION: '3.11' |
| 27 | + DISABLE_BREAKING_CHANGES_WARNING: '1' |
| 28 | + |
| 29 | +jobs: |
| 30 | + # --------------------------------------------------------------------- |
| 31 | + # Version sanity check: setuptools-scm must resolve the tag to the |
| 32 | + # same PEP 440 version we expect from the tag name (v1.2.3 → 1.2.3). |
| 33 | + # --------------------------------------------------------------------- |
| 34 | + verify-version: |
| 35 | + name: Verify version |
| 36 | + runs-on: ubuntu-latest |
| 37 | + outputs: |
| 38 | + tag: ${{ steps.resolve.outputs.tag }} |
| 39 | + version: ${{ steps.resolve.outputs.version }} |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + ref: ${{ github.event.inputs.tag || github.ref }} |
| 44 | + fetch-depth: 0 # setuptools-scm needs full history + tags |
| 45 | + |
| 46 | + - uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: ${{ env.PYTHON_VERSION }} |
| 49 | + |
| 50 | + - name: Resolve tag and version |
| 51 | + id: resolve |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + TAG="${{ github.event.inputs.tag || github.ref_name }}" |
| 55 | + VERSION="${TAG#v}" |
| 56 | + python -m pip install --upgrade pip |
| 57 | + python -m pip install "setuptools-scm>=8" |
| 58 | + SCM_VERSION=$(python -m setuptools_scm) |
| 59 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 60 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 61 | + if [ "$VERSION" != "$SCM_VERSION" ]; then |
| 62 | + echo "::error::Tag version ($VERSION) does not match setuptools-scm resolution ($SCM_VERSION). Make sure the tag points at the commit you want to release." |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | + echo "Building version $VERSION from tag $TAG" |
| 66 | +
|
| 67 | + # --------------------------------------------------------------------- |
| 68 | + # Matrix build: 5 targets |
| 69 | + # --------------------------------------------------------------------- |
| 70 | + build: |
| 71 | + name: Build ${{ matrix.target }} |
| 72 | + needs: verify-version |
| 73 | + runs-on: ${{ matrix.runner }} |
| 74 | + container: ${{ matrix.container }} |
| 75 | + strategy: |
| 76 | + fail-fast: false |
| 77 | + matrix: |
| 78 | + include: |
| 79 | + - target: linux-amd64 |
| 80 | + runner: ubuntu-latest |
| 81 | + container: quay.io/pypa/manylinux_2_28_x86_64 |
| 82 | + ext: '' |
| 83 | + archive: tar.gz |
| 84 | + - target: linux-arm64 |
| 85 | + runner: ubuntu-24.04-arm |
| 86 | + container: quay.io/pypa/manylinux_2_28_aarch64 |
| 87 | + ext: '' |
| 88 | + archive: tar.gz |
| 89 | + - target: darwin-amd64 |
| 90 | + runner: macos-13 |
| 91 | + container: '' |
| 92 | + ext: '' |
| 93 | + archive: tar.gz |
| 94 | + - target: darwin-arm64 |
| 95 | + runner: macos-latest |
| 96 | + container: '' |
| 97 | + ext: '' |
| 98 | + archive: tar.gz |
| 99 | + - target: windows-amd64 |
| 100 | + runner: windows-latest |
| 101 | + container: '' |
| 102 | + ext: '.exe' |
| 103 | + archive: zip |
| 104 | + |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v4 |
| 107 | + with: |
| 108 | + ref: ${{ needs.verify-version.outputs.tag }} |
| 109 | + fetch-depth: 0 # setuptools-scm needs full history + tags |
| 110 | + |
| 111 | + # manylinux images ship multiple Pythons under /opt/python; expose one. |
| 112 | + - name: Configure Python (manylinux container) |
| 113 | + if: matrix.container != '' |
| 114 | + shell: bash |
| 115 | + run: | |
| 116 | + PY=/opt/python/cp311-cp311/bin |
| 117 | + echo "$PY" >> "$GITHUB_PATH" |
| 118 | + "$PY/python" -m pip install --upgrade pip |
| 119 | +
|
| 120 | + - name: Setup Python (host runner) |
| 121 | + if: matrix.container == '' |
| 122 | + uses: actions/setup-python@v5 |
| 123 | + with: |
| 124 | + python-version: ${{ env.PYTHON_VERSION }} |
| 125 | + |
| 126 | + - name: Install project + PyInstaller |
| 127 | + shell: bash |
| 128 | + run: | |
| 129 | + python -m pip install --upgrade pip |
| 130 | + python -m pip install -e . |
| 131 | + python -m pip install pyinstaller |
| 132 | +
|
| 133 | + - name: Build binary |
| 134 | + shell: bash |
| 135 | + run: | |
| 136 | + pyinstaller --clean --noconfirm agentrun.spec |
| 137 | + ls -lh dist/ |
| 138 | +
|
| 139 | + - name: Smoke test binary |
| 140 | + shell: bash |
| 141 | + run: | |
| 142 | + ./dist/agentrun${{ matrix.ext }} --version |
| 143 | +
|
| 144 | + # --- Package (Unix) ----------------------------------------------- |
| 145 | + - name: Package tar.gz (Unix) |
| 146 | + if: matrix.archive == 'tar.gz' |
| 147 | + shell: bash |
| 148 | + run: | |
| 149 | + VERSION="${{ needs.verify-version.outputs.version }}" |
| 150 | + ASSET="agentrun-${VERSION}-${{ matrix.target }}.tar.gz" |
| 151 | + cd dist |
| 152 | + tar czf "../${ASSET}" "agentrun${{ matrix.ext }}" |
| 153 | + cd .. |
| 154 | + shasum -a 256 "${ASSET}" > "${ASSET}.sha256" |
| 155 | + echo "ASSET=${ASSET}" >> "$GITHUB_ENV" |
| 156 | +
|
| 157 | + # --- Package (Windows) -------------------------------------------- |
| 158 | + - name: Package zip (Windows) |
| 159 | + if: matrix.archive == 'zip' |
| 160 | + shell: pwsh |
| 161 | + run: | |
| 162 | + $version = "${{ needs.verify-version.outputs.version }}" |
| 163 | + $asset = "agentrun-$version-${{ matrix.target }}.zip" |
| 164 | + Compress-Archive -Path "dist/agentrun${{ matrix.ext }}" -DestinationPath $asset -Force |
| 165 | + $hash = (Get-FileHash $asset -Algorithm SHA256).Hash.ToLower() |
| 166 | + "$hash $asset" | Out-File -Encoding ascii "$asset.sha256" |
| 167 | + echo "ASSET=$asset" >> $env:GITHUB_ENV |
| 168 | +
|
| 169 | + - uses: actions/upload-artifact@v4 |
| 170 | + with: |
| 171 | + name: agentrun-${{ matrix.target }} |
| 172 | + path: | |
| 173 | + ${{ env.ASSET }} |
| 174 | + ${{ env.ASSET }}.sha256 |
| 175 | + retention-days: 7 |
| 176 | + if-no-files-found: error |
| 177 | + |
| 178 | + # --------------------------------------------------------------------- |
| 179 | + # Collect all artifacts and publish the Release |
| 180 | + # --------------------------------------------------------------------- |
| 181 | + release: |
| 182 | + name: Publish Release |
| 183 | + needs: [verify-version, build] |
| 184 | + runs-on: ubuntu-latest |
| 185 | + steps: |
| 186 | + - uses: actions/download-artifact@v4 |
| 187 | + with: |
| 188 | + path: dist |
| 189 | + merge-multiple: true |
| 190 | + |
| 191 | + - name: List artifacts |
| 192 | + run: ls -lh dist/ |
| 193 | + |
| 194 | + - name: Create combined checksums file |
| 195 | + working-directory: dist |
| 196 | + run: | |
| 197 | + cat *.sha256 > SHA256SUMS |
| 198 | + echo "---" |
| 199 | + cat SHA256SUMS |
| 200 | +
|
| 201 | + - name: Publish to GitHub Releases |
| 202 | + uses: softprops/action-gh-release@v2 |
| 203 | + with: |
| 204 | + tag_name: ${{ needs.verify-version.outputs.tag }} |
| 205 | + name: ${{ needs.verify-version.outputs.tag }} |
| 206 | + draft: false |
| 207 | + prerelease: ${{ contains(needs.verify-version.outputs.version, '-') }} |
| 208 | + generate_release_notes: true |
| 209 | + files: | |
| 210 | + dist/agentrun-*.tar.gz |
| 211 | + dist/agentrun-*.zip |
| 212 | + dist/agentrun-*.sha256 |
| 213 | + dist/SHA256SUMS |
0 commit comments