diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d1fedc6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,139 @@ +name: Release wheels + +# Builds wheels for Linux / macOS / Windows × Python 3.10–3.13 and +# publishes them to PyPI on a tag push. Trigger: +# git tag v0.1.1 && git push --tags +# Or manually via the Actions tab → "Run workflow". + +on: + push: + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: read + +jobs: + linux: + name: build linux ${{ matrix.target }} py${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [x86_64, aarch64] + python-version: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: build wheel + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist -i python${{ matrix.python-version }} + manylinux: auto + + - uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.target }}-py${{ matrix.python-version }} + path: dist + + macos: + name: build macos ${{ matrix.target }} py${{ matrix.python-version }} + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + target: [x86_64, aarch64] + python-version: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: build wheel + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist -i python${{ matrix.python-version }} + + - uses: actions/upload-artifact@v4 + with: + name: wheels-macos-${{ matrix.target }}-py${{ matrix.python-version }} + path: dist + + windows: + name: build windows x86_64 py${{ matrix.python-version }} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: build wheel + uses: PyO3/maturin-action@v1 + with: + target: x86_64 + args: --release --out dist -i python${{ matrix.python-version }} + + - uses: actions/upload-artifact@v4 + with: + name: wheels-windows-x86_64-py${{ matrix.python-version }} + path: dist + + sdist: + name: build sdist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + + - uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist + + publish: + name: publish to PyPI + needs: [linux, macos, windows, sdist] + runs-on: ubuntu-latest + # Only run on tag push, not on manual dispatch (use dispatch for build-only dry runs). + if: startsWith(github.ref, 'refs/tags/v') + # Trusted Publishing (OIDC). Configure at: + # https://pypi.org/manage/account/publishing/ + # with: project=hebb-py, owner=hebb-project, repo=hebb, + # workflow=release.yml, environment=pypi + environment: + name: pypi + url: https://pypi.org/p/hebb-py + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + pattern: wheels-* + merge-multiple: true + path: dist + + - name: publish to PyPI + uses: PyO3/maturin-action@v1 + with: + command: upload + args: --non-interactive --skip-existing dist/*