Skip to content

Build and Publish

Build and Publish #9

Workflow file for this run

name: Build and Publish
on:
- workflow_dispatch
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
cibw_archs: x86_64
- os: ubuntu-24.04-arm
cibw_archs: aarch64
- os: windows-latest
cibw_archs: AMD64 ARM64
- os: macos-latest
cibw_archs: universal2
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }}
uses: pypa/cibuildwheel@v3.1.4
env:
CIBW_BUILD_FRONTEND: build[uv]
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
CIBW_SKIP: "pp*"
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_ENABLE: cpython-freethreading
CIBW_TEST_COMMAND: python {project}/tests/test_cases.py
with:
package-dir: ./PythonAPI
- name: Run abi3audit
run: uvx abi3audit --report ./wheelhouse/*-abi3-*.whl
- uses: actions/upload-artifact@v4
with:
name: pycocotools-${{ matrix.os }}-${{ matrix.cibw_archs }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
test_source:
uses: ./.github/workflows/unittest.yml
build_sdist:
needs: test_source
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: pipx run build --sdist ./PythonAPI
- uses: actions/upload-artifact@v4
with:
name: pycocotools-sdist
path: ./PythonAPI/dist/*.tar.gz
publish:
needs: [build_wheels, build_sdist]
name: Publish package to PyPI
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#using-an-environment
environment: release
# https://github.com/pypa/gh-action-pypi-publish#trusted-publishing
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Display structure of downloaded files
run: ls -R dist
- uses: pypa/gh-action-pypi-publish@release/v1