blob: a4b0221cac42019053f8805f21a92033cdb42b71 [file] [log] [blame]
# 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-18.04
build_package: main-dist-linux
experimental: false
- os: ubuntu-18.04
build_package: py-compiler-pkg
experimental: false
- os: ubuntu-18.04
build_package: py-runtime-pkg
experimental: false
- os: ubuntu-18.04
build_package: instrumented-py-runtime-pkg
experimental: true
- os: ubuntu-18.04
build_package: py-tf-compiler-tools-pkg
experimental: false
# Windows packages.
- os: windows-2019
build_package: py-compiler-pkg
experimental: true
- os: windows-2019
build_package: py-runtime-pkg
experimental: true
# Macos packages.
- os: macos-latest
build_package: py-compiler-pkg
experimental: true
- os: macos-latest
build_package: py-runtime-pkg
experimental: true
env:
CIBW_BUILD_VERBOSITY: 1
# Note that on Linux, we run under docker with an altered path.
# Note that on Windows, we need to configure the compiler api project to
# but its CMake build directory on a short path to avoid path overflow.
CIBW_ENVIRONMENT_LINUX: "REPO_DIR=/project/main_checkout BINDIST_DIR=/output CMAKE_GENERATOR=Ninja IREE_TARGET_BACKEND_CUDA=ON"
CIBW_ENVIRONMENT_MACOS: "REPO_DIR=${{ github.workspace }}/main_checkout CMAKE_GENERATOR=Ninja"
CIBW_ENVIRONMENT_WINDOWS: "REPO_DIR='${{ github.workspace }}\\main_checkout' CMAKE_GENERATOR=Ninja IREE_COMPILER_API_CMAKE_BUILD_DIR=D:/b"
# Needs the bazel manylinux image.
# TODO: Move this to our repo and pin.
CIBW_MANYLINUX_X86_64_IMAGE: stellaraccident/manylinux2014_x86_64-bazel-5.0.0:latest
# CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BUILD: "cp37-* cp38-* cp39-*"
CIBW_SKIP: "*-win32 *-manylinux_i686"
steps:
- uses: actions/checkout@v2
with:
path: 'main_checkout'
submodules: true
# Make sure we have a system python before setting up the dev path.
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'
# It is 2021. And the Windows Path is still a mess.
- name: Set up visual studio environment
if: "contains(matrix.os, 'windows')"
shell: powershell
run: |
${{ github.workspace }}\main_checkout\build_tools\github_actions\configure_dev_environment.ps1 -bashExePath C:\msys64\usr\bin\bash.exe
- name: Report windows environment
if: "contains(matrix.os, 'windows')"
shell: bash
run: |
# Should display either an msys mount table or an "install from the windows store" banner
echo "--- System path:"
echo "$PATH"
echo "--- Result of asking bash to run 'mount' (should show msys mounts):"
mount
- name: Install cibuildwheel
shell: bash
run: |
python -m pip install cibuildwheel==1.7.2
- name: Write version info (release)
if: "!startsWith(matrix.build_package, 'instrumented-')"
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
- name: Write version info (instrumented)
if: "startsWith(matrix.build_package, 'instrumented-')"
shell: bash
run: |
cat << EOF > ./main_checkout/version_info.json
{
"package-suffix": "-instrumented${{ 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
# 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 \
"${CIBW_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'
# Runtime wheels are version specific, so we build one for each python
# version. We do this serially by deleting the CMakeCache and install
# directory between runs. Most of the build will be incremental.
# We save a lot of time by disabling the compiler build.
- name: Build runtime wheels
if: "matrix.build_package == 'py-runtime-pkg'"
shell: bash
run: |
package_dir="./iree-install/python_packages/iree_runtime"
export CIBW_BEFORE_BUILD="python ./main_checkout/build_tools/github_actions/build_dist.py py-runtime-pkg"
# TODO: cibuildwheel sanity checks this, but our setup.py is the
# *output* of the build :( Make source packages.
mkdir -p $package_dir && touch $package_dir/setup.py
python -m cibuildwheel --output-dir bindist $package_dir
- name: Build runtime wheels (instrumented)
if: "matrix.build_package == 'instrumented-py-runtime-pkg'"
shell: bash
run: |
package_dir="./iree-install/python_packages/iree_runtime"
export CIBW_BEFORE_ALL_LINUX="./main_checkout/build_tools/github_actions/install_tracy_cli_deps_manylinux2014.sh"
export CIBW_BEFORE_BUILD="python ./main_checkout/build_tools/github_actions/build_dist.py instrumented-py-runtime-pkg"
# TODO: cibuildwheel sanity checks this, but our setup.py is the
# *output* of the build :( Make source packages.
mkdir -p $package_dir && touch $package_dir/setup.py
python -m cibuildwheel --output-dir bindist $package_dir
# Experimental iree.compiler package.
- name: Build compiler wheels
if: "matrix.build_package == 'py-compiler-pkg'"
shell: bash
run: |
# In pip 21.3, in-tree builds became the default and only way to
# build. We require that and make sure to be past that threshold.
export CIBW_BEFORE_BUILD="python -m pip install --upgrade pip>=21.3"
python -m cibuildwheel --output-dir bindist ./main_checkout/llvm-external-projects/iree-compiler-api
# Compiler tools wheels are not python version specific, so just build
# for one examplar python version.
- 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 \
"${CIBW_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@v2
with:
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@v1
env:
GITHUB_TOKEN: ${{ secrets.WRITE_ACCESS_TOKEN }}
with:
release_id: ${{ github.event.inputs.release_id }}
assets_path: ./bindist/*
validate_and_publish:
name: "Invoke workflow to validate and publish release"
needs: build_core
runs-on: ubuntu-18.04
steps:
- name: "Invoke workflow :: Validate and Publish Release"
uses: benc-uk/workflow-dispatch@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 }}"}'