Skip to content

Build and Publish

Build and Publish #51

Workflow file for this run

name: Build and Publish
on:
- workflow_dispatch
- workflow_call
jobs:
test_source:
uses: ./.github/workflows/unittest.yml
build_wheels:
needs: test_source
name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: True
matrix:
include:
- os: ubuntu-latest # linux x86_64
cibw_archs: x86_64
cibw_skip: "pp*"
- os: ubuntu-latest # linux arm64 gnu
cibw_archs: aarch64
cibw_skip: "pp* *musllinux*"
- os: windows-latest
cibw_archs: AMD64
cibw_skip: "pp*"
- os: windows-latest
cibw_archs: ARM64
cibw_skip: "pp*"
- os: macos-13
cibw_archs: x86_64
cibw_skip: "pp*"
- os: macos-14
cibw_archs: arm64
cibw_skip: "pp*"
steps:
- uses: actions/checkout@v4
- name: Setup QEMU
if: runner.os == 'Linux' && matrix.cibw_archs == 'aarch64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Setup Linux
if: runner.os == 'Linux'
run: |
sudo apt update --fix-missing
sudo apt install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev
- name: Setup macOS
if: ${{ runner.os == 'macOS' }}
run: |
brew install gcc libomp
- name: Build wheels for ${{ matrix.os }}
uses: pypa/[email protected]
env:
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7"
CIBW_PRERELEASE_PYTHONS: False
CIBW_BUILD_FRONTEND: build
CIBW_SKIP: ${{ matrix.cibw_skip }}
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_TEST_REQUIRES: "pytest parameterized"
CIBW_TEST_COMMAND: "pytest {project}/tests"
CIBW_TEST_SKIP: "*-win_arm64"
with:
package-dir: ./
- uses: actions/upload-artifact@v4
with:
name: faster-coco-eval-${{ matrix.os }}-${{ matrix.cibw_archs }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
needs: test_source
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
run: make sdist
- uses: actions/upload-artifact@v4
with:
name: faster-coco-eval-sdist
path: ./dist/*.tar.gz
publish_test:
needs: [build_wheels, build_sdist]
name: Publish package to TestPyPI
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:
name: sdist
path: dist
- uses: actions/download-artifact@v4
with:
name: wheels
path: dist
- name: Display structure of downloaded files
run: ls -R dist
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
publish_prod:
needs: [publish_test]
name: Publish package to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- uses: actions/download-artifact@v4
with:
name: wheels
path: dist
- name: Display structure of downloaded files
run: ls -R dist
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}