| # Builds packages for native (non cross-compiled) targets on supported | |
| # platforms. | |
| # | |
| # For these mainline distributions, we use cibuildwheel and drive the | |
| # packaging through python, extracting native assets. While this may seem | |
| # hopelessly round-about, it lets us leverage a lot of what cibuildwheel | |
| # does for free and get python packages to boot. | |
| name: Build Native Release Packages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| package_suffix: | |
| description: 'Suffix to append to package names' | |
| required: false | |
| default: '' | |
| package_version: | |
| description: 'Version of the package' | |
| required: true | |
| default: '0.1a1' | |
| release_id: | |
| description: 'Release id to upload artifacts to' | |
| default: '' | |
| jobs: | |
| build_core: | |
| name: "${{ matrix.os }} :: Build ${{ matrix.build_package }} Package" | |
| runs-on: ${{ matrix.os }} | |
| continue-on-error: ${{ matrix.experimental }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Ubuntu packages. | |
| - os: ubuntu-20.04 | |
| build_family: linux | |
| build_package: main-dist-linux | |
| experimental: false | |
| - os: ubuntu-20.04 | |
| build_family: linux | |
| build_package: py-compiler-pkg | |
| experimental: false | |
| - os: ubuntu-20.04 | |
| build_family: linux | |
| build_package: py-runtime-pkg | |
| experimental: false | |
| - os: ubuntu-20.04 | |
| build_family: linux | |
| build_package: py-tf-compiler-tools-pkg | |
| experimental: false | |
| # Macos packages. | |
| - os: macos-latest | |
| build_family: macos | |
| build_package: py-compiler-pkg | |
| experimental: true | |
| - os: macos-latest | |
| build_family: macos | |
| build_package: py-runtime-pkg | |
| experimental: true | |
| env: | |
| MANYLINUX_X86_64_IMAGE: gcr.io/iree-oss/manylinux2014_x86_64-release@sha256:2c6a9120a5f96bcf3b1dda4086d807682705b51fb9c6ee5b48a8756c436220bc | |
| steps: | |
| - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2 | |
| with: | |
| path: 'main_checkout' | |
| submodules: true | |
| ########################################################################## | |
| # OS specific setup | |
| ########################################################################## | |
| - name: Install MacOS Deps | |
| if: "matrix.build_family == 'macos'" | |
| shell: bash | |
| run: | | |
| sudo ./main_checkout/build_tools/python_deploy/install_macos_deps.sh | |
| ########################################################################## | |
| # Write version_info.json | |
| # Various tools will read this in order to embed release information. | |
| ########################################################################## | |
| - name: Write version info (release) | |
| shell: bash | |
| run: | | |
| cat << EOF > ./main_checkout/version_info.json | |
| { | |
| "package-suffix": "${{ github.event.inputs.package_suffix }}", | |
| "package-version": "${{ github.event.inputs.package_version }}", | |
| "iree-revision": "$(cd ./main_checkout && git rev-parse HEAD)" | |
| } | |
| EOF | |
| cat ./main_checkout/version_info.json | |
| ########################################################################## | |
| # Build the main distribution tarball. | |
| # The main distribution consists of the project being built, installed | |
| # and archived. We have to split it per operating system, and Linux | |
| # is special because we build under a manylinux container which gives | |
| # broad compatibility. We use the Python based manylinux containers | |
| # since they come packaged with all dev tools we need. Note that the | |
| # manylinux containers have a default python 2.x with all supported | |
| # python versions under /opt/python (need to add one to the path). It | |
| # is not enough to just invoke it directly because then pip managed | |
| # console scripts (like cmake, ninja) will not be on the path. | |
| ########################################################################## | |
| - name: Main distribution (Linux) | |
| if: "matrix.build_package == 'main-dist-linux'" | |
| shell: bash | |
| run: | | |
| docker run --rm -w=/work \ | |
| -v $PWD:/work \ | |
| "${MANYLINUX_X86_64_IMAGE}" \ | |
| bash -c 'export PATH=/opt/python/cp39-cp39/bin:$PATH; python ./main_checkout/build_tools/github_actions/build_dist.py main-dist' | |
| ########################################################################## | |
| # py-runtime-pkg | |
| # Builds the iree-runtime and iree-runtime-instrumented wheels. | |
| # One step per OS. | |
| ########################################################################## | |
| - name: Build runtime wheels (Linux) | |
| if: "matrix.build_package == 'py-runtime-pkg' && matrix.build_family == 'linux'" | |
| shell: bash | |
| run: | | |
| packages="iree-runtime iree-runtime-instrumented" \ | |
| output_dir="$PWD/bindist" \ | |
| ./main_checkout/build_tools/python_deploy/build_linux_packages.sh | |
| - name: Build runtime wheels (MacOS) | |
| if: "matrix.build_package == 'py-runtime-pkg' && matrix.build_family == 'macos'" | |
| shell: bash | |
| run: | | |
| packages="iree-runtime iree-runtime-instrumented" \ | |
| output_dir="$PWD/bindist" \ | |
| ./main_checkout/build_tools/python_deploy/build_macos_packages.sh | |
| ########################################################################## | |
| # py-compiler-pkg | |
| # Builds the iree-compielr wheel. | |
| # One step per OS. | |
| ########################################################################## | |
| - name: Build compiler wheels (Linux) | |
| if: "matrix.build_package == 'py-compiler-pkg' && matrix.build_family == 'linux'" | |
| shell: bash | |
| run: | | |
| packages="iree-compiler" \ | |
| output_dir="$PWD/bindist" \ | |
| ./main_checkout/build_tools/python_deploy/build_linux_packages.sh | |
| - name: Build compiler wheels (MacOS) | |
| if: "matrix.build_package == 'py-compiler-pkg' && matrix.build_family == 'macos'" | |
| shell: bash | |
| run: | | |
| packages="iree-compiler" \ | |
| output_dir="$PWD/bindist" \ | |
| ./main_checkout/build_tools/python_deploy/build_macos_packages.sh | |
| ########################################################################## | |
| # TF Compiler Tools | |
| # Compiler tools wheels are not python version specific, so just build | |
| # for one examplar python version. | |
| # TODO: This currently only builds on Linux and is hardcoded to do so. | |
| ########################################################################## | |
| - name: Build TF Compiler Tools wheels | |
| if: "matrix.build_package == 'py-tf-compiler-tools-pkg'" | |
| shell: bash | |
| run: | | |
| docker run --rm -w=/work \ | |
| -v $PWD:/work \ | |
| "${MANYLINUX_X86_64_IMAGE}" \ | |
| bash -c 'export PATH=/opt/python/cp39-cp39/bin:$PATH; python ./main_checkout/build_tools/github_actions/build_dist.py py-tf-compiler-tools-pkg' | |
| - uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2 | |
| with: | |
| # We upload all wheels (which includes deps so that subsequent | |
| # steps can run without further fetching). | |
| path: ./bindist/* | |
| retention-days: 5 | |
| # TODO: Upload the tar.bz2 files too when ready | |
| - name: Upload Release Assets | |
| if: github.event.inputs.release_id != '' | |
| id: upload-release-assets | |
| uses: dwenegar/upload-release-assets@5bc3024cf83521df8ebfadf00ad0c4614fd59148 # v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }} | |
| with: | |
| release_id: ${{ github.event.inputs.release_id }} | |
| # Only upload iree wheels. | |
| assets_path: ./bindist/iree*.whl | |
| validate_and_publish: | |
| name: "Invoke workflow to validate and publish release" | |
| needs: build_core | |
| runs-on: ubuntu-20.04 | |
| steps: | |
| - name: "Invoke workflow :: Validate and Publish Release" | |
| uses: benc-uk/workflow-dispatch@4c044c1613fabbe5250deadc65452d54c4ad4fc7 # v1 | |
| with: | |
| workflow: Validate and Publish Release | |
| token: ${{ secrets.WRITE_ACCESS_TOKEN }} | |
| ref: "${{ env.tag_name }}" | |
| inputs: '{"release_id": "${{ github.event.inputs.release_id }}", "package_version": "${{ github.event.inputs.package_version }}", "build_run_id": "${{ github.run_id }}"}' |