[infra] Update python packaging workflow #44
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
| name: Publish onert to pypi | |
| on: | |
| pull_request: | |
| branches: [ master ] | |
| paths: | |
| - '.github/workflows/pub-onert-pypi.yml' | |
| - 'runtime/infra/python/**' | |
| - '!**/*.md' | |
| workflow_dispatch: | |
| inputs: | |
| official: | |
| description: 'Official release' | |
| required: true | |
| type: boolean | |
| default: false | |
| jobs: | |
| build: | |
| if: github.repository_owner == 'Samsung' | |
| strategy: | |
| matrix: | |
| python-version: [ '3.10', '3.11', '3.12' ] | |
| arch: [ 'x86_64', 'aarch64' ] | |
| include: | |
| - arch: x86_64 | |
| runner: one-x64-linux | |
| image: samsungonedev.azurecr.io/pypa/manylinux_2_28_x86_64 | |
| - arch: aarch64 | |
| runner: one-arm-linux | |
| image: samsungonedev.azurecr.io/pypa/manylinux_2_28_aarch64 | |
| fail-fast: false | |
| runs-on: ${{ matrix.runner }} | |
| container: | |
| image: ${{ matrix.image }} | |
| env: | |
| BUILD_TYPE: release | |
| OPTIONS: "-DENABLE_TEST=OFF -DBUILD_ARMCOMPUTE=OFF" | |
| # Set env to decide package name: refer runtime/infra/python/wheel_target_hook.py | |
| PLATFORM: ${{ matrix.arch }} | |
| GLIBC_VERSION: "2.28" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Caching externals | |
| uses: actions/cache@v4 | |
| with: | |
| path: runtime/externals | |
| key: external-onert-jammy-${{ hashFiles('runtime/infra/cmake/packages/**/*.cmake') }} | |
| restore-keys: | | |
| external-onert-jammy- | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "0.9.10" | |
| python-version: "${{ matrix.python-version }}" | |
| # For flatc build | |
| - name: Install glibc-static | |
| run: | | |
| yum install -y glibc-static | |
| - name: Build | |
| run: | | |
| uv run --python "${{ matrix.python-version }}" make -f Makefile.template configure build install | |
| # Pre-release build | |
| # 1) Release branch test build | |
| # 2) PR build | |
| # 3) Main branch (develop branch) build | |
| - name: Pre-release packaging | |
| if: github.event.inputs.official == 'false' || github.event_name == 'pull_request' || github.ref_name == 'master' | |
| run: | | |
| uv version "$(uv version --short --project runtime)-dev$(date -u "+%y%m%d")" --project runtime --python "${{ matrix.python-version }}" | |
| - name: Build package | |
| run: | | |
| uv build --wheel --project runtime --python "${{ matrix.python-version }}" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: onert-wheel-python${{ matrix.python-version }}-${{ matrix.arch }} | |
| path: runtime/dist/*.whl | |
| publish-to-pypi: | |
| needs: [ build ] | |
| if: github.repository_owner == 'Samsung' && github.event_name != 'pull_request' | |
| runs-on: ubuntu-22.04 | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/onert | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: "Download all the dists" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: onert-wheel-* | |
| path: "./dist/" | |
| merge-multiple: true # download to 'dist/' directory, not individual directories | |
| - name: "Publish distribution to PyPI" | |
| uses: pypa/gh-action-pypi-publish@release/v1 |