add copyright license #796
Workflow file for this run
This file contains hidden or 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
| # Copyright (c) ONNX Project Contributors | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Build and Test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| build_wheels: | |
| env: | |
| CIBW_ARCHS_MACOS: x86_64 universal2 | |
| MACOSX_DEPLOYMENT_TARGET: "10.15" | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | |
| CIBW_BEFORE_ALL_LINUX: WD=`pwd` && /opt/python/cp39-cp39/bin/python -m pip install --target tmp_cmake cmake && cp tmp_cmake/bin/cmake /usr/local/bin/cmake && rm -rf tmp_cmake && /opt/python/cp39-cp39/bin/python -m pip install cmake && cmake --version && whereis cmake | |
| CIBW_BEFORE_ALL_MACOS: WD=`pwd` && pip install cmake | |
| CIBW_BEFORE_BUILD_LINUX: pip install protobuf | |
| CIBW_BEFORE_BUILD_WINDOWS: python -m pip install protobuf | |
| CIBW_BEFORE_BUILD_MACOS: pip install protobuf | |
| CIBW_TEST_REQUIRES_LINUX: pytest pytest-xdist flake8 mypy onnxruntime | |
| CIBW_TEST_REQUIRES_MACOS: pytest pytest-xdist | |
| CIBW_TEST_REQUIRES_WINDOWS: pytest pytest-xdist | |
| CIBW_BEFORE_TEST_LINUX: pip install torch==2.6.0+cpu torchvision==0.21.0+cpu --index-url https://download.pytorch.org/whl/cpu | |
| CIBW_TEST_COMMAND: pytest {project}/onnxoptimizer/test | |
| CIBW_TEST_COMMAND_LINUX: cd {project} && flake8 && pytest | |
| CIBW_TEST_SKIP: " *_arm64" | |
| CIBW_ENVIRONMENT: CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5" | |
| CIBW_ENVIRONMENT_WINDOWS: USE_MSVC_STATIC_RUNTIME=0 CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DProtobuf_USE_STATIC_LIBS=ON -DONNX_USE_LITE_PROTO=ON" | |
| CIBW_BUILD: "${{ matrix.python }}-*" | |
| CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_*" | |
| name: Build whls ${{ matrix.os }}${{ matrix.python }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-24.04, windows-2022, macos-15] | |
| python: ["cp39", "cp310", "cp311", "cp312", "cp313"] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v3.2.0 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: artifact-${{ matrix.os }}-${{ matrix.python }} | |
| path: ./wheelhouse/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - run: python3 -m pip install protobuf | |
| - name: Build sdist | |
| run: pipx run build --sdist | |
| - name: Install and test sdist | |
| run: | | |
| # It's important to leave the project directory where a 'onnxoptimizer' subdirectory exists | |
| cd dist | |
| python3 -m pip install *.tar.gz | |
| python3 -c "import onnxoptimizer; print(onnxoptimizer.get_fuse_and_elimination_passes())" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| path: dist/*.tar.gz | |
| release: | |
| name: Release | |
| environment: | |
| name: release | |
| url: https://pypi.org/p/onnxoptimizer | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| needs: [build_wheels, build_sdist] | |
| steps: | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: artifact | |
| path: dist | |
| # TODO: get acccess for test.pypi | |
| # - name: Publish distribution 📦 to Test PyPI | |
| # uses: pypa/gh-action-pypi-publish@release/v1 | |
| # with: | |
| # repository-url: https://test.pypi.org/legacy/ | |
| # skip-existing: true | |
| # attestations: true | |
| - name: Publish distribution 📦 to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://upload.pypi.org/legacy/ | |
| attestations: true |