Skip to content

MacRelease

MacRelease #18

Workflow file for this run

name: MacRelease
on:
schedule:
# Run weekly on Monday 00:00
- cron: '00 00 * * MON'
push:
branches: [main, rel-*]
pull_request:
branches: [main, rel-*]
workflow_dispatch:
# Use MACOSX_DEPLOYMENT_TARGET=10.12 to produce compatible wheel
env:
MACOSX_DEPLOYMENT_TARGET: 10.12
permissions:
contents: read
jobs:
build:
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
runs-on: macos-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
host-architecture: ['x64']
target-architecture: ['x86_64', 'universal2']
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.host-architecture }}
- name: Install Python dependencies
run: |
python -m pip install -q --upgrade pip
python -m pip install -q -r requirements-release.txt
- name: Build wheel and install
env:
CC: "clang"
CXX: "clang++"
ONNX_ML: 1
run: |
# Install Protobuf from source
export NUM_CORES=`sysctl -n hw.logicalcpu`
if [ '${{ matrix.target-architecture }}' == 'x86_64' ]; then
export CMAKE_OSX_ARCHITECTURES=x86_64
elif [ '${{ matrix.target-architecture }}' == 'universal2' ]; then
export CMAKE_OSX_ARCHITECTURES='arm64;x86_64'
fi
source workflow_scripts/protobuf/build_protobuf_unix.sh $NUM_CORES $(pwd)/protobuf/protobuf_install
export CMAKE_ARGS="-DONNX_USE_LITE_PROTO=ON"
# Currently GitHub Action agent is using macos-11, use -p to force change the final MACOSX_DEPLOYMENT_TARGET
# Change -p if MACOSX_DEPLOYMENT_TARGET is different
if [ '${{ github.event_name }}' == 'schedule' ]; then
python setup.py bdist_wheel -p macosx_10_12_${{ matrix.target-architecture }} --weekly_build
else
python setup.py bdist_wheel -p macosx_10_12_${{ matrix.target-architecture }}
fi
for file in dist/*.whl; do python -m pip install --upgrade $file; done
- name: Test the installed wheel
run: |
pytest
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: wheels
path: dist
- name: Upload wheel to TestPyPI/PyPI weekly
if: github.event_name == 'schedule' # Only triggered by weekly event
run: |
twine upload --verbose dist/*.whl --repository-url https://upload.pypi.org/legacy/ -u ${{ secrets.ONNXWEEKLY_USERNAME }} -p ${{ secrets.ONNXWEEKLY_TOKEN }}
# TODO: stop uploading to TestPyPI after future ONNX 1.14
twine upload --verbose dist/*.whl --repository-url https://test.pypi.org/legacy/ -u ${{ secrets.TESTPYPI_USERNAME }} -p ${{ secrets.TESTPYPI_PASSWORD }}
- name: Verify ONNX with the latest numpy
if: ${{ always() }}
run: |
python -m pip uninstall -y numpy onnx && python -m pip install numpy
for file in dist/*.whl; do python -m pip install --upgrade $file; done
pytest
- name: Verify ONNX with the latest protobuf
if: ${{ always() }}
run: |
python -m pip uninstall -y protobuf onnx && python -m pip install protobuf
for file in dist/*.whl; do python -m pip install --upgrade $file; done
pytest
- name: Verify ONNX with the minimum supported protobuf (from requirements.txt)
if: ${{ always() }}
run: |
python -m pip uninstall -y protobuf onnx && python -m pip install protobuf==3.20.2
for file in dist/*.whl; do python -m pip install --upgrade $file; done
pytest
# Only triggered by weekly event on certain CI
- name: Build and upload source distribution to PyPI weekly
if: github.event_name == 'schedule' && matrix.python-version == '3.10' && matrix.target-architecture == 'x86_64'
run: |
# Build and upload source distribution to PyPI
git clean -xdf
python setup.py sdist --weekly_build
twine upload dist/* --repository-url https://upload.pypi.org/legacy/ -u ${{ secrets.ONNXWEEKLY_USERNAME }} -p ${{ secrets.ONNXWEEKLY_TOKEN }}
# Test weekly source distribution from PyPI
python -m pip uninstall -y onnx
python -m pip install setuptools
python -m pip install --index-url https://upload.pypi.org/legacy/ --use-deprecated=legacy-resolver --no-use-pep517 --no-binary onnx-weekly onnx-weekly
pytest
- name: Verify ONNX with ONNX Runtime PyPI package
if: matrix.python-version != '3.11'
run: |
python -m pip uninstall -y protobuf numpy && python -m pip install -q -r requirements-release.txt
python -m pip install -q onnxruntime
export ORT_MAX_IR_SUPPORTED_VERSION=8
export ORT_MAX_ML_OPSET_SUPPORTED_VERSION=3
export ORT_MAX_ONNX_OPSET_SUPPORTED_VERSION=18
pytest