Fix gh-actions (#2) #23
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
# Adapted from https://github.com/RalfG/python-wheels-manylinux-build/blob/master/full_workflow_example.yml | |
name: libmcphase | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
types: [opened, reopened, synchronize] | |
release: | |
types: [published] | |
workflow_dispatch: | |
concurrency : | |
group: ${{ github.workflow }}-${{ github.ref == 'refs/head/main' && github.run_number || github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -l {0} | |
jobs: | |
build_and_test: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
name: Build and test, ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- uses: mamba-org/setup-micromamba@v1 | |
with: | |
cache-downloads: true | |
- name: Build wheels | |
run: | | |
$MAMBA_EXE create -n cibuildwheel python=3.12 | |
eval "$($MAMBA_EXE shell activate cibuildwheel)" | |
python -m pip install cibuildwheel | |
if [[ $OSTYPE == "darwin23" ]] || [[ $OSTYPE == "darwin22" ]] | |
then | |
# For some reason cibuildwheel on builds 3.9-3.12 arm64 on macos-latest | |
export CIBW_BUILD="cp39* cp310* cp311* cp312*" | |
fi | |
python -m cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_BUILD: "cp38-* cp39* cp310-* cp311-* cp312-*" | |
CIBW_SKIP: "*musllinux* *win32* *i686*" | |
CIBW_ARCHS_MACOS: "native" | |
CIBW_BUILD_VERBOSITY: 1 | |
- name: Install wheels and run test | |
run: | | |
# set -e makes sure the script fails if any command in the loop fails | |
set -e | |
if [[ $OSTYPE == "darwin23" ]] || [[ $OSTYPE == "darwin22" ]] | |
then | |
export PYVERS="3.9 3.10 3.11 3.12" | |
else | |
export PYVERS="3.8 3.9 3.10 3.11 3.12" | |
fi | |
for pyver in $PYVERS | |
do | |
$MAMBA_EXE create -n py$pyver -c conda-forge python=$pyver numpy | |
eval "$($MAMBA_EXE shell activate py$pyver)" | |
python -m pip install wheelhouse/*cp$(echo $pyver | sed s/\\.//)* | |
cd tests | |
python -m unittest | |
cd .. | |
done | |
- name: Upload release wheels | |
if: | | |
contains(github.event.pull_request.title, 'RELEASE') && | |
github.event.pull_request.merged | |
run: | | |
python -m pip install requests numpy | |
python release.py --notest --github --create_tag --token=${{ secrets.GH_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
if: | | |
${{ github.event_name == 'pull_request' }} && | |
contains(github.event.pull_request.labels.*.name, 'save_wheels') | |
with: | |
name: ${{ matrix.os }}_artifacts.zip | |
path: wheelhouse/* | |
#- name: Setup tmate | |
# if: ${{ failure() }} | |
# uses: mxschmitt/action-tmate@v3 |