onnx

Форк
0
/
release_mac.yml 
153 строки · 6.4 Кб
1
# Copyright (c) ONNX Project Contributors
2
#
3
# SPDX-License-Identifier: Apache-2.0
4

5
name: MacRelease
6

7
on:  # Specifies the event triggering the workflow
8
  workflow_call:  # Indicates that this is a reusable workflow
9
    inputs:      
10
      os:
11
        required: true
12
        type: string
13

14
# Use MACOSX_DEPLOYMENT_TARGET=12.0 to produce compatible wheel
15
env:
16
  MACOSX_DEPLOYMENT_TARGET: "12.0"
17

18
permissions:
19
  contents: read
20

21
jobs:
22
  build:
23
    if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
24
    runs-on: macos-latest
25
    strategy:
26
      matrix:
27
        python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
28

29
    steps:
30
    - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
31
    - name: Checkout submodules
32
      shell: bash
33
      run: |
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
39
      with:
40
        python-version: ${{ matrix.python-version }}
41

42
    - name: Install Python dependencies
43
      run: |
44
        python -m pip install -q --upgrade pip
45
        python -m pip install -q -r requirements-release.txt
46

47
    - name: Build wheel and install
48
      env:
49
        CC: "clang"
50
        CXX: "clang++"
51
        ONNX_ML: 1
52
        CMAKE_OSX_ARCHITECTURES: "arm64;x86_64"
53
        CMAKE_ARGS: "-DONNX_USE_LITE_PROTO=ON"
54
      run: |
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
61
        fi
62
        python -m build --wheel
63

64
    - uses: actions/upload-artifact@v4
65
      with:
66
        name: wheels-${{ inputs.os }}-${{ matrix.python-version }}
67
        path: dist/*.whl
68

69
  test:
70
    needs: build
71
    runs-on: ${{ (matrix.target-architecture == 'x86_64') && 'macos-12' || 'macos-14' }}
72
    strategy:
73
      matrix:
74
        python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
75
        target-architecture: ['x86_64', 'arm64']
76

77
    steps:
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
81
      with:
82
        python-version: ${{ matrix.python-version }}
83

84
    - name: Install Python dependencies
85
      run: |
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
88

89
    - uses: actions/download-artifact@v4
90
      with:
91
        name:  wheels-${{ inputs.os }}-${{ matrix.python-version }}
92
        path: dist
93

94
    - name: Test the wheel
95
      run: |
96
        arch -${{ matrix.target-architecture }} python -m pip install --upgrade dist/*.whl
97
        arch -${{ matrix.target-architecture }} pytest
98

99
    - name: Upload wheel to PyPI weekly
100
      if: github.event_name == 'schedule' && matrix.target-architecture == 'arm64'  # Only triggered by weekly event
101
      run: |
102
        twine upload --verbose dist/*.whl --repository-url https://upload.pypi.org/legacy/ -u ${{ secrets.ONNXWEEKLY_USERNAME }} -p ${{ secrets.ONNXWEEKLY_TOKEN }}
103

104
    - name: Verify ONNX with the latest numpy
105
      if: ${{ always() }}
106
      run: |
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
111

112
    - name: Verify ONNX with the latest protobuf
113
      if: ${{ always() }}
114
      run: |
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
119

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'))
122
      run: |
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
127

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'
131
      run: |
132
        # Build and upload source distribution to PyPI
133
        git clean -xdf
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 }}
137

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
142
        pytest
143

144
    - name: Verify ONNX with ONNX Runtime PyPI package
145
      if: matrix.python-version != '3.12'
146
      run: |
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
154

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.