262 lines
10 KiB
YAML
262 lines
10 KiB
YAML
# ADR-117 P5 — cibuildwheel + PyPI publish workflow for `wifi-densepose`
|
|
#
|
|
# This workflow is **explicitly NOT** triggered on every push. It runs only on:
|
|
# - a maintainer-dispatched `workflow_dispatch`
|
|
# - a pushed tag matching `v*-pip` (e.g. `v2.0.0-pip`)
|
|
#
|
|
# The reason for the `-pip` tag suffix is that the repo already cuts
|
|
# `v0.X.Y-esp32` tags for firmware releases (see CLAUDE.md). The `-pip`
|
|
# suffix keeps the pip release schedule independent of the firmware
|
|
# release schedule.
|
|
#
|
|
# Sequencing on release day (per ADR-117 §7.3):
|
|
# 1. cut tag `v1.99.0-pip` → publishes the tombstone wheel first
|
|
# 2. cut tag `v2.0.0-pip` → publishes the PyO3 v2 wheel matrix
|
|
#
|
|
# Both publish via PyPI Trusted Publisher (OIDC). No API tokens in
|
|
# secrets — see https://docs.pypi.org/trusted-publishers/ for how to
|
|
# register this workflow with PyPI before the first publish.
|
|
#
|
|
# Q3 (witness hash v2 — open in ADR-117 §11.3) MUST be resolved before
|
|
# the first v2.0.0 publish. The `verify-witness` job below currently
|
|
# only checks the v1 hash for backwards-compatibility against the
|
|
# legacy archive/v1 sample. When v2 lands, add a parallel step that
|
|
# verifies the v2 hash against the Rust pipeline.
|
|
|
|
name: pip-release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
target:
|
|
description: "Which package to release"
|
|
required: true
|
|
type: choice
|
|
options:
|
|
- v2-wheels
|
|
- v1-99-tombstone
|
|
publish_to:
|
|
description: "Where to publish"
|
|
required: true
|
|
default: testpypi
|
|
type: choice
|
|
options:
|
|
- testpypi # dry-run target
|
|
- pypi # production
|
|
push:
|
|
tags:
|
|
- "v*-pip"
|
|
|
|
# Required for PyPI Trusted Publisher (OIDC).
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
|
|
jobs:
|
|
# ────────────────────────────────────────────────────────────────
|
|
# v2.0.0 — cibuildwheel matrix (5 wheels + sdist)
|
|
# ────────────────────────────────────────────────────────────────
|
|
|
|
build-wheels:
|
|
name: Build ${{ matrix.os }} ${{ matrix.arch }}
|
|
if: |
|
|
github.event_name == 'workflow_dispatch' && inputs.target == 'v2-wheels' ||
|
|
startsWith(github.ref, 'refs/tags/v2.')
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
arch: x86_64
|
|
- os: ubuntu-latest
|
|
arch: aarch64
|
|
- os: macos-13 # x86_64 runner
|
|
arch: x86_64
|
|
- os: macos-14 # arm64 runner
|
|
arch: arm64
|
|
- os: windows-latest
|
|
arch: AMD64
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# Linux aarch64 needs QEMU for cross-build on x86_64 runners.
|
|
- name: Set up QEMU
|
|
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64'
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
# ADR-117 §5.4: abi3-py310 — one binary per OS/arch covers all
|
|
# Python minor versions ≥ 3.10. Build only cp310 wheels.
|
|
- name: Build wheels (cibuildwheel)
|
|
uses: pypa/cibuildwheel@v2.21
|
|
env:
|
|
CIBW_BUILD: "cp310-*"
|
|
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
|
|
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
|
|
CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
|
|
CIBW_BUILD_FRONTEND: "build"
|
|
CIBW_BEFORE_BUILD: "pip install maturin>=1.7"
|
|
# The PyO3 sdist landing depends on the cargo/Rust toolchain
|
|
# being present. cibuildwheel images carry rustup on Linux
|
|
# but we also pin a known-good version for reproducibility.
|
|
CIBW_BEFORE_ALL_LINUX: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.82"
|
|
CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH"'
|
|
# Smoke-test every built wheel before accepting it. Catches
|
|
# the case where the wheel imports but the compiled symbols
|
|
# are missing.
|
|
CIBW_TEST_REQUIRES: "pytest>=8.0"
|
|
CIBW_TEST_COMMAND: 'python -c "import wifi_densepose; assert wifi_densepose.hello() == \"ok\"; print(wifi_densepose.__build_features__)"'
|
|
with:
|
|
package-dir: python
|
|
output-dir: wheelhouse
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
|
|
path: wheelhouse/*.whl
|
|
if-no-files-found: error
|
|
|
|
build-sdist:
|
|
name: Build v2 sdist
|
|
if: |
|
|
github.event_name == 'workflow_dispatch' && inputs.target == 'v2-wheels' ||
|
|
startsWith(github.ref, 'refs/tags/v2.')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install maturin
|
|
run: pip install maturin>=1.7
|
|
- name: Build sdist
|
|
working-directory: python
|
|
run: maturin sdist --out ../sdist
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sdist
|
|
path: sdist/*.tar.gz
|
|
if-no-files-found: error
|
|
|
|
# ────────────────────────────────────────────────────────────────
|
|
# v1.99.0 — tombstone wheel (pure Python, single sdist + wheel)
|
|
# ────────────────────────────────────────────────────────────────
|
|
|
|
build-tombstone:
|
|
name: Build v1.99.0 tombstone
|
|
if: |
|
|
github.event_name == 'workflow_dispatch' && inputs.target == 'v1-99-tombstone' ||
|
|
startsWith(github.ref, 'refs/tags/v1.99')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install build backend
|
|
run: pip install build>=1.2
|
|
- name: Build sdist + wheel
|
|
working-directory: python/tombstone
|
|
run: python -m build --outdir ../../tombstone-dist
|
|
# Smoke-test: the wheel MUST raise ImportError on import.
|
|
- name: Smoke-test tombstone
|
|
run: |
|
|
python -m pip install tombstone-dist/wifi_densepose-1.99.0-py3-none-any.whl
|
|
set +e
|
|
python -c "import wifi_densepose" 2> import-output.txt
|
|
rc=$?
|
|
set -e
|
|
if [ "$rc" -eq 0 ]; then
|
|
echo "ERROR: tombstone import succeeded — should have raised ImportError"
|
|
exit 1
|
|
fi
|
|
# Must include the migration URL so users can find their way home.
|
|
if ! grep -q "github.com/ruvnet/RuView" import-output.txt; then
|
|
echo "ERROR: tombstone ImportError missing migration URL"
|
|
cat import-output.txt
|
|
exit 1
|
|
fi
|
|
echo "Tombstone wheel correctly raises ImportError with migration URL."
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: tombstone
|
|
path: tombstone-dist/*
|
|
if-no-files-found: error
|
|
|
|
# ────────────────────────────────────────────────────────────────
|
|
# Publish — gated by manual dispatch OR by the tag form
|
|
# ────────────────────────────────────────────────────────────────
|
|
|
|
publish-v2:
|
|
name: Publish v2 wheels
|
|
needs: [build-wheels, build-sdist]
|
|
if: |
|
|
always() &&
|
|
needs.build-wheels.result == 'success' &&
|
|
needs.build-sdist.result == 'success' &&
|
|
(
|
|
github.event_name == 'workflow_dispatch' && inputs.target == 'v2-wheels' ||
|
|
startsWith(github.ref, 'refs/tags/v2.')
|
|
)
|
|
runs-on: ubuntu-latest
|
|
# PyPI Trusted Publisher (OIDC) — register the workflow + repo
|
|
# under https://pypi.org/manage/account/publishing/ before the
|
|
# first publish. No API tokens in GH secrets.
|
|
environment:
|
|
name: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_to || 'pypi' }}
|
|
url: https://pypi.org/p/wifi-densepose
|
|
steps:
|
|
- name: Gather all artifacts into dist/
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: dist-staging
|
|
- name: Flatten artifacts
|
|
run: |
|
|
mkdir -p dist
|
|
find dist-staging -type f \( -name '*.whl' -o -name '*.tar.gz' \) -exec cp -v {} dist/ \;
|
|
ls -lh dist/
|
|
- name: Publish to TestPyPI (dry-run target)
|
|
if: github.event_name == 'workflow_dispatch' && inputs.publish_to == 'testpypi'
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
repository-url: https://test.pypi.org/legacy/
|
|
packages-dir: dist
|
|
# Don't fail on existing — useful when re-running a dispatch
|
|
# after fixing the workflow but before bumping the version.
|
|
skip-existing: true
|
|
- name: Publish to PyPI
|
|
if: |
|
|
startsWith(github.ref, 'refs/tags/v2.') ||
|
|
(github.event_name == 'workflow_dispatch' && inputs.publish_to == 'pypi')
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
packages-dir: dist
|
|
|
|
publish-tombstone:
|
|
name: Publish v1.99 tombstone
|
|
needs: [build-tombstone]
|
|
if: |
|
|
always() &&
|
|
needs.build-tombstone.result == 'success' &&
|
|
(
|
|
github.event_name == 'workflow_dispatch' && inputs.target == 'v1-99-tombstone' ||
|
|
startsWith(github.ref, 'refs/tags/v1.99')
|
|
)
|
|
runs-on: ubuntu-latest
|
|
environment:
|
|
name: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_to || 'pypi' }}
|
|
url: https://pypi.org/p/wifi-densepose
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: tombstone
|
|
path: dist
|
|
- name: Publish to TestPyPI (dry-run target)
|
|
if: github.event_name == 'workflow_dispatch' && inputs.publish_to == 'testpypi'
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
repository-url: https://test.pypi.org/legacy/
|
|
packages-dir: dist
|
|
skip-existing: true
|
|
- name: Publish to PyPI
|
|
if: |
|
|
startsWith(github.ref, 'refs/tags/v1.99') ||
|
|
(github.event_name == 'workflow_dispatch' && inputs.publish_to == 'pypi')
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
packages-dir: dist
|