2023-07-15 06:45:41 -05:00
|
|
|
# Workflow to build and test wheels.
|
|
|
|
name: Wheel builder
|
|
|
|
|
2023-07-23 10:15:42 -05:00
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2023-08-11 09:25:11 -05:00
|
|
|
tags:
|
|
|
|
- v**
|
2023-07-23 10:15:42 -05:00
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
|
|
|
|
2023-07-15 06:45:41 -05:00
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
2023-07-16 11:52:55 -05:00
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}-manylinux2014
|
|
|
|
|
2023-07-15 06:45:41 -05:00
|
|
|
jobs:
|
2023-07-16 11:52:55 -05:00
|
|
|
build-custom-manylinux:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Get changed Dockerfile
|
|
|
|
id: changed-files-specific
|
2023-07-23 10:32:59 -05:00
|
|
|
uses: tj-actions/changed-files@de0eba32790fb9bf87471b32855a30fc8f9d5fc6 #v37.4.0
|
2023-07-16 11:52:55 -05:00
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
Dockerfile-manylinux
|
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
2023-07-23 10:32:59 -05:00
|
|
|
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc #v2.2.0
|
2023-07-16 11:52:55 -05:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
|
|
|
id: meta
|
2023-07-23 10:32:59 -05:00
|
|
|
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 #v4.6.0
|
2023-07-16 11:52:55 -05:00
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
|
|
|
|
- name: Build and push Docker image
|
|
|
|
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
2023-07-23 10:32:59 -05:00
|
|
|
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 #v4.1.1
|
2023-07-16 11:52:55 -05:00
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile-manylinux
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
|
2023-07-15 06:45:41 -05:00
|
|
|
build_wheels:
|
|
|
|
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
|
2023-07-16 11:52:55 -05:00
|
|
|
needs: build-custom-manylinux
|
2023-07-15 06:45:41 -05:00
|
|
|
runs-on: ${{ matrix.buildplat[0] }}
|
|
|
|
strategy:
|
|
|
|
# Ensure that a wheel builder finishes even if another fails
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
# Github Actions doesn't support pairing matrix values together, let's improvise
|
|
|
|
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
|
|
|
|
buildplat:
|
|
|
|
- [ubuntu-20.04, manylinux_x86_64]
|
|
|
|
#- [ubuntu-20.04, musllinux_x86_64]
|
|
|
|
#- [macos-12, macosx_x86_64]
|
|
|
|
#- [windows-2019, win_amd64]
|
|
|
|
python: ["cp39", "cp310", "cp311", "cp312"] # "pp39"
|
|
|
|
exclude:
|
|
|
|
# Don't build PyPy 32-bit windows
|
|
|
|
- buildplat: [windows-2019, win32]
|
|
|
|
python: "pp39"
|
|
|
|
- buildplat: [ ubuntu-20.04, musllinux_x86_64 ]
|
|
|
|
python: "pp39"
|
|
|
|
steps:
|
|
|
|
- name: Checkout Coriolis
|
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
|
|
|
with:
|
|
|
|
submodules: true
|
|
|
|
# https://github.com/actions/checkout/issues/338
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: pkg-config-for-win
|
|
|
|
run: |
|
|
|
|
choco install -y --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite
|
|
|
|
if: runner.os == 'windows'
|
|
|
|
|
|
|
|
# Used to push the built wheels
|
|
|
|
- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
|
|
|
|
with:
|
|
|
|
python-version: "3.x"
|
|
|
|
|
|
|
|
- name: ccache
|
2023-07-23 10:32:59 -05:00
|
|
|
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e #v1.2.9
|
2023-07-16 00:56:44 -05:00
|
|
|
with:
|
|
|
|
key: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
|
2023-07-15 06:45:41 -05:00
|
|
|
|
2023-07-16 13:29:11 -05:00
|
|
|
- name: Log in to the Container registry
|
2023-07-23 10:32:59 -05:00
|
|
|
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc #v2.2.0
|
2023-07-16 13:29:11 -05:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2023-07-15 06:45:41 -05:00
|
|
|
- name: Build wheels
|
|
|
|
uses: pypa/cibuildwheel@66b46d086804a9e9782354100d96a3a445431bca # v2.14.0
|
|
|
|
env:
|
|
|
|
CIBW_PRERELEASE_PYTHONS: True
|
|
|
|
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
|
2023-07-15 07:28:43 -05:00
|
|
|
CIBW_ENVIRONMENT: USE_CCACHE=1 CCACHE_DIR=/.ccache
|
|
|
|
CIBW_CONTAINER_ENGINE: "docker; create_args: '--volume=${{ github.workspace }}/.ccache:/.ccache'"
|
2023-07-16 13:06:16 -05:00
|
|
|
# overriede before-all in pyproject.toml
|
|
|
|
CIBW_BEFORE_ALL: ""
|
|
|
|
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/chipflow/coriolis-manylinux2014:${{ github.ref_name }}
|
2023-07-15 06:45:41 -05:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
|
|
|
|
path: ./wheelhouse/*.whl
|
2023-07-23 10:15:42 -05:00
|
|
|
|
2023-07-23 10:38:07 -05:00
|
|
|
test_upload_pypi:
|
|
|
|
# TODO: create an sdist that can build without a custom environment
|
|
|
|
needs: [build_wheels]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
buildplat:
|
|
|
|
- [ubuntu-20.04, manylinux_x86_64]
|
|
|
|
#- [ubuntu-20.04, musllinux_x86_64]
|
|
|
|
#- [macos-12, macosx_x86_64]
|
|
|
|
#- [windows-2019, win_amd64]
|
|
|
|
python: ["cp39", "cp310", "cp311", "cp312"] # "pp39"
|
|
|
|
exclude:
|
|
|
|
# Don't build PyPy 32-bit windows
|
|
|
|
- buildplat: [windows-2019, win32]
|
|
|
|
python: "pp39"
|
|
|
|
- buildplat: [ ubuntu-20.04, musllinux_x86_64 ]
|
|
|
|
python: "pp39"
|
|
|
|
|
|
|
|
environment: pypi
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
steps:
|
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
|
|
|
|
path: dist
|
|
|
|
|
|
|
|
- uses: pypa/gh-action-pypi-publish@f8c70e705ffc13c3b4d1221169b84f12a75d6ca8 #v1.8.8
|
|
|
|
with:
|
2023-08-09 09:24:08 -05:00
|
|
|
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
2023-07-23 10:38:07 -05:00
|
|
|
repository_url: https://test.pypi.org/legacy/
|
|
|
|
|
2023-07-23 10:15:42 -05:00
|
|
|
upload_pypi:
|
|
|
|
# TODO: create an sdist that can build without a custom environment
|
2023-08-11 16:12:19 -05:00
|
|
|
if: github.event_name == 'release'
|
2023-07-23 10:15:42 -05:00
|
|
|
needs: [build_wheels]
|
|
|
|
runs-on: ubuntu-latest
|
2023-07-23 10:38:07 -05:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
buildplat:
|
|
|
|
- [ubuntu-20.04, manylinux_x86_64]
|
|
|
|
#- [ubuntu-20.04, musllinux_x86_64]
|
|
|
|
#- [macos-12, macosx_x86_64]
|
|
|
|
#- [windows-2019, win_amd64]
|
|
|
|
python: ["cp39", "cp310", "cp311", "cp312"] # "pp39"
|
|
|
|
exclude:
|
|
|
|
# Don't build PyPy 32-bit windows
|
|
|
|
- buildplat: [windows-2019, win32]
|
|
|
|
python: "pp39"
|
|
|
|
- buildplat: [ ubuntu-20.04, musllinux_x86_64 ]
|
|
|
|
python: "pp39"
|
|
|
|
|
2023-07-23 10:15:42 -05:00
|
|
|
environment: pypi
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
steps:
|
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
2023-07-23 10:38:07 -05:00
|
|
|
name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
|
2023-07-23 10:15:42 -05:00
|
|
|
path: dist
|
|
|
|
|
|
|
|
- uses: pypa/gh-action-pypi-publish@release/v1
|
2023-08-09 12:00:14 -05:00
|
|
|
with:
|
|
|
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
2023-08-09 09:24:08 -05:00
|
|
|
|
2023-07-15 06:45:41 -05:00
|
|
|
# build_sdist:
|
|
|
|
# name: Build sdist
|
|
|
|
# runs-on: ubuntu-latest
|
|
|
|
# steps:
|
|
|
|
# - name: Checkout Coriolis
|
|
|
|
# uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
|
|
|
# with:
|
|
|
|
# submodules: true
|
|
|
|
# fetch-depth: 0
|
|
|
|
# # Used to push the built wheels
|
|
|
|
# - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
|
|
|
|
# with:
|
|
|
|
# # Build sdist on lowest supported Python
|
|
|
|
# python-version: "3.9"
|
|
|
|
# - name: Build sdist
|
|
|
|
# run: |
|
|
|
|
# python -m pip install build
|
|
|
|
# python -m build -s
|
|
|
|
# - name: Test the sdist
|
|
|
|
# run: |
|
|
|
|
# # TODO: Don't run test suite, and instead build wheels from sdist
|
|
|
|
# # Depends on pypa/cibuildwheel#1020
|
|
|
|
# python -m pip install dist/*.gz
|
|
|
|
# #cd .. # Can't import numpy within numpy src directory
|
|
|
|
# #python -c "import numpy, sys; print(numpy.__version__); sys.exit(numpy.test() is False)"
|
|
|
|
#
|
|
|
|
# - name: Check README rendering for PyPI
|
|
|
|
# run: |
|
|
|
|
# python -mpip install twine
|
|
|
|
# twine check dist/*
|
|
|
|
#
|
|
|
|
# - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
|
|
|
# with:
|
|
|
|
# name: sdist
|
|
|
|
# path: ./dist/*
|
|
|
|
#
|