use bash shell to execute commands #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- master | |
- TestPyPI | |
pull_request: | |
branches: | |
- master | |
release: | |
types: [created] | |
workflow_dispatch: | |
jobs: | |
build_wheels: | |
name: Build wheel for cp${{ matrix.cibw_python }}-${{ matrix.platform_id }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# macOS on Apple M1 64-bit | |
- os: [self-hosted, macOS, ARM64] | |
python: '3.8' | |
cibw_python: 38 | |
arch: arm64 | |
platform_id: macosx_arm64 | |
- os: [self-hosted, macOS, ARM64] | |
python: '3.9' | |
cibw_python: 39 | |
arch: arm64 | |
platform_id: macosx_arm64 | |
- os: [self-hosted, macOS, ARM64] | |
python: '3.10' | |
cibw_python: 310 | |
arch: arm64 | |
platform_id: macosx_arm64 | |
- os: [self-hosted, macOS, ARM64] | |
python: '3.11' | |
cibw_python: 311 | |
arch: arm64 | |
platform_id: macosx_arm64 | |
- os: [self-hosted, macOS, ARM64] | |
python: '3.12' | |
cibw_python: 312 | |
arch: arm64 | |
platform_id: macosx_arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install Python host for cibuildwheel | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-activate-base: false | |
activate-environment: py${{ matrix.cibw_python }} | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
channels: conda-forge | |
channel-priority: true | |
python-version: ${{ matrix.python }} | |
- name: Install dependencies | |
shell: bash -l {0} | |
run: | | |
# Workaround for https://github.com/conda-incubator/setup-miniconda/issues/186 | |
conda config --remove channels defaults | |
# dependencies | |
python -m ensurepip --upgrade | |
mamba install cmake ninja libpng | |
- name: Install cibuildwheel and other build tools | |
shell: bash -l {0} | |
run: | | |
python -m pip install --upgrade build pip twine | |
python -m pip install cibuildwheel==2.16.2 jq pipx setuptools | |
python -m pipx ensurepath | |
- name: Get package name and version (Linux / Mac) | |
shell: bash -l {0} | |
if: ${{ ! startsWith(matrix.os, 'windows-') }} | |
run: | | |
echo PACKAGE_NAME=$( python setup.py --name ) >> $GITHUB_ENV | |
echo PACKAGE_VERSION=$( python setup.py --version ) >> $GITHUB_ENV | |
- name: Build and test wheels | |
shell: bash -l {0} | |
env: | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_MANYLINUX_I686_IMAGE: manylinux2014 | |
CIBW_BUILD: cp${{ matrix.cibw_python }}-${{ matrix.platform_id }} | |
# Include latest Python beta | |
CIBW_PRERELEASE_PYTHONS: True | |
CIBW_ARCHS_MACOS: ${{ matrix.arch }} | |
CIBW_ENVIRONMENT_MACOS: | | |
CMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} | |
CIBW_BEFORE_TEST: | | |
python -m pip install --find-links=wheelhouse/ -r requirements.txt | |
CIBW_TEST_COMMAND: bash {project}/tests/run_tests.sh | |
CIBW_TEST_SKIP: cp38-macosx_*:arm64 | |
run: | | |
python -m cibuildwheel --output-dir wheelhouse/cp${{ matrix.cibw_python }}-${{ matrix.platform_id }} | |
- name: Store wheel artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}-cp${{ matrix.cibw_python }}-${{ matrix.platform_id }} | |
path: ./wheelhouse/cp${{ matrix.cibw_python }}-${{ matrix.platform_id }}/*.whl | |
- name: Upload release asset | |
# Previously was using actions/upload-release-asset@v1 , but this had some | |
# errors with large files | |
uses: ncipollo/release-action@v1.11.1 | |
if: ${{ github.event_name == 'release' }} | |
with: | |
allowUpdates: true | |
omitBodyDuringUpdate: true | |
omitNameDuringUpdate: true | |
artifacts: ./wheelhouse/cp${{ matrix.cibw_python }}-${{ matrix.platform_id }}/*.whl | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
if: ${{ (github.event_name == 'push') && (runner.os == 'Linux') }} | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
verify_metadata: false | |
skip_existing: true | |
verbose: true | |
- name: Download artifacts | |
# needs: [build_wheels, build_sdist] | |
uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: ${{ env.PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}* | |
path: dist | |
merge-multiple: true | |
- name: Publish package to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true |