1
# Copyright (c) ONNX Project Contributors
3
# SPDX-License-Identifier: Apache-2.0
7
on: # Specifies the event triggering the workflow
8
workflow_call: # Indicates that this is a reusable workflow
14
# Use MACOSX_DEPLOYMENT_TARGET=12.0 to produce compatible wheel
16
MACOSX_DEPLOYMENT_TARGET: "12.0"
23
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
27
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
30
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
31
- name: Checkout submodules
34
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
35
git submodule sync --recursive
36
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
37
- name: Set up Python ${{ matrix.python-version }}
38
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
40
python-version: ${{ matrix.python-version }}
42
- name: Install Python dependencies
44
python -m pip install -q --upgrade pip
45
python -m pip install -q -r requirements-release.txt
47
- name: Build wheel and install
52
CMAKE_OSX_ARCHITECTURES: "arm64;x86_64"
53
CMAKE_ARGS: "-DONNX_USE_LITE_PROTO=ON"
55
# Install Protobuf from source
56
export NUM_CORES=`sysctl -n hw.logicalcpu`
57
source workflow_scripts/protobuf/build_protobuf_unix.sh $NUM_CORES $(pwd)/protobuf/protobuf_install
58
if [ '${{ github.event_name }}' == 'schedule' ]; then
59
sed -i '' 's/name = "onnx"/name = "onnx-weekly"/' 'pyproject.toml'
60
export ONNX_PREVIEW_BUILD=1
62
python -m build --wheel
64
- uses: actions/upload-artifact@v4
66
name: wheels-${{ inputs.os }}-${{ matrix.python-version }}
71
runs-on: ${{ (matrix.target-architecture == 'x86_64') && 'macos-12' || 'macos-14' }}
74
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
75
target-architecture: ['x86_64', 'arm64']
78
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
79
- name: Set up Python ${{ matrix.python-version }}
80
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
82
python-version: ${{ matrix.python-version }}
84
- name: Install Python dependencies
86
arch -${{ matrix.target-architecture }} python -m pip install -q --upgrade pip
87
arch -${{ matrix.target-architecture }} python -m pip install -q -r requirements-release.txt
89
- uses: actions/download-artifact@v4
91
name: wheels-${{ inputs.os }}-${{ matrix.python-version }}
94
- name: Test the wheel
96
arch -${{ matrix.target-architecture }} python -m pip install --upgrade dist/*.whl
97
arch -${{ matrix.target-architecture }} pytest
99
- name: Upload wheel to PyPI weekly
100
if: github.event_name == 'schedule' && matrix.target-architecture == 'arm64' # Only triggered by weekly event
102
twine upload --verbose dist/*.whl --repository-url https://upload.pypi.org/legacy/ -u ${{ secrets.ONNXWEEKLY_USERNAME }} -p ${{ secrets.ONNXWEEKLY_TOKEN }}
104
- name: Verify ONNX with the latest numpy
107
arch -${{ matrix.target-architecture }} python -m pip uninstall -y numpy onnx
108
arch -${{ matrix.target-architecture }} python -m pip install numpy
109
arch -${{ matrix.target-architecture }} python -m pip install --upgrade dist/*.whl
110
arch -${{ matrix.target-architecture }} pytest
112
- name: Verify ONNX with the latest protobuf
115
arch -${{ matrix.target-architecture }} python -m pip uninstall -y protobuf onnx
116
arch -${{ matrix.target-architecture }} python -m pip install protobuf
117
arch -${{ matrix.target-architecture }} python -m pip install --upgrade dist/*.whl
118
arch -${{ matrix.target-architecture }} pytest
120
- name: Verify ONNX with the minimumly supported packages
121
if: always() && (matrix.target-architecture == 'x86_64' || (matrix.python-version != '3.8' && matrix.python-version != '3.9'))
123
arch -${{ matrix.target-architecture }} python -m pip uninstall -y numpy protobuf onnx
124
arch -${{ matrix.target-architecture }} python -m pip install -r requirements-min.txt
125
arch -${{ matrix.target-architecture }} python -m pip install --upgrade dist/*.whl
126
arch -${{ matrix.target-architecture }} pytest
128
# Only triggered by weekly event on certain CI
129
- name: Build and upload source distribution to PyPI weekly
130
if: github.event_name == 'schedule' && matrix.python-version == '3.10' && matrix.target-architecture == 'arm64'
132
# Build and upload source distribution to PyPI
134
sed -i '' 's/name = "onnx"/name = "onnx-weekly"/' 'pyproject.toml'
135
ONNX_PREVIEW_BUILD=1 python -m build --sdist
136
twine upload dist/* --repository-url https://upload.pypi.org/legacy/ -u ${{ secrets.ONNXWEEKLY_USERNAME }} -p ${{ secrets.ONNXWEEKLY_TOKEN }}
138
# Test weekly source distribution from PyPI
139
python -m pip uninstall -y onnx-weekly
140
python -m pip install setuptools
141
python -m pip install --use-deprecated=legacy-resolver --no-binary onnx-weekly onnx-weekly
144
- name: Verify ONNX with ONNX Runtime PyPI package
145
if: matrix.python-version != '3.12'
147
arch -${{ matrix.target-architecture }} python -m pip uninstall -y protobuf numpy
148
arch -${{ matrix.target-architecture }} python -m pip install -q -r requirements-release.txt
149
arch -${{ matrix.target-architecture }} python -m pip install -q onnxruntime==1.17.3
150
export ORT_MAX_IR_SUPPORTED_VERSION=9
151
export ORT_MAX_ML_OPSET_SUPPORTED_VERSION=3
152
export ORT_MAX_ONNX_OPSET_SUPPORTED_VERSION=20
153
arch -${{ matrix.target-architecture }} pytest