Publish onert to pypi #30
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: [ 'python3.10', 'python3.11', 'python3.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" | |
| DEV_TAG: "" | |
| 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 venv for python version | |
| run: | | |
| ${{ matrix.python-version }} -m venv ./venv | |
| source ./venv/bin/activate | |
| pip3 install -U setuptools wheel | |
| - name: Build | |
| run: | | |
| source ./venv/bin/activate | |
| 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: | | |
| source ./venv/bin/activate | |
| cd runtime/infra/python | |
| python3 setup.py bdist_wheel --plat-name manylinux_2_28_${{ matrix.arch }} egg_info --tag-build "dev$(date -u "+%y%m%d")" | |
| # Allow official release on release branch only | |
| - name: Release packaging | |
| if: github.event.inputs.official == 'true' && startsWith(github.ref_name, 'release/') | |
| run: | | |
| source ./venv/bin/activate | |
| cd runtime/infra/python | |
| python3 setup.py bdist_wheel --plat-name manylinux_2_28_${{ matrix.arch }} egg_info | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: onert-wheel-${{ matrix.python-version }}-${{ matrix.arch }} | |
| path: runtime/infra/python/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 |