Skip to content

v1.3.1

v1.3.1 #39

Workflow file for this run

name: xmos-ai-tools-release
on:
release:
types: [published]
tags:
- v*
workflow_dispatch:
inputs:
version:
description: "Provide a valid release tag version in the format vX.Y.Z"
required: true
# Either we triggered a workflow providing a version or published a new release
# Save the tag version in an environment variable
env:
TAG_VERSION: ${{ github.event.inputs.version == 0 && github.ref_name || github.event.inputs.version }}
BAZEL_CACHE_URL: https://storage.googleapis.com/bazel_remote_cache_0/gh_actions
TOOLS_VERSION: 15.2.1
TOOLS_LINK: https://www.xmos.ai/download/Tools-15---Linux-64(15_2_1).tgz
jobs:
build-release-archive:
name: Build release archive
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ env.TAG_VERSION }}
- name: Build setup
shell: bash
run: |
sudo apt-get -y -qq install libncurses5
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
make patch
wget -nv "${{ env.TOOLS_LINK }}?key=${{ secrets.TOOLS_KEY }}" -O tools.tgz
tar xf tools.tgz
cd XMOS/XTC/${{ env.TOOLS_VERSION }}
source ./SetEnv
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
mkdir -p build
cd build
cmake .. --toolchain=../lib_tflite_micro/submodules/xmos_cmake_toolchain/xs3a.cmake
make create_zip -j4
- uses: actions/upload-artifact@v4
with:
name: xcore-archive
path: third_party/lib_tflite_micro/build/*.zip
macos-release-wheel:
name: Build release wheels for macOS
needs: [build-release-archive]
runs-on: macos-13
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ env.TAG_VERSION }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.BAZEL_REMOTE_CACHE_JSON_KEY }}
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: bash
run: |
cd $GITHUB_WORKSPACE/python/xmos_ai_tools/runtime
unzip release_archive.zip
rm release_archive.zip
- name: Build macOS wheels
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.TAG_VERSION }}
shell: bash
run: |
python --version
python -m pip install wheel setuptools setuptools-scm numpy six --no-cache-dir
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
make patch
cd $GITHUB_WORKSPACE
./build.sh -T xinterpreter-nozip -b
cd $GITHUB_WORKSPACE/xformer
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo "using Google Cloud Storage cache"
echo -e 'build --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-${{ runner.arch }}-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
bazelisk build //:xcore-opt --copt=-fvisibility=hidden --copt=-mavx --copt=-mmacosx-version-min=10.13 --linkopt=-mmacosx-version-min=10.13 --linkopt=-dead_strip --distinct_host_configuration=false --//:disable_version_check
cd $GITHUB_WORKSPACE/python
python setup.py bdist_wheel --plat macosx_10_14_x86_64
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
path: python/dist
macos-arm-release-wheel:
name: Build release wheels for macOS arm64
needs: [build-release-archive]
runs-on: macos-14
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ env.TAG_VERSION }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.BAZEL_REMOTE_CACHE_JSON_KEY }}
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: bash
run: |
cd $GITHUB_WORKSPACE/python/xmos_ai_tools/runtime
unzip release_archive.zip
rm release_archive.zip
- name: Build macOS arm wheels
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.TAG_VERSION }}
CMAKE_ENABLE_DARWIN_TARGET_ARM64: 1
shell: bash
run: |
python --version
python -m pip install wheel setuptools setuptools-scm numpy six --no-cache-dir
cd $GITHUB_WORKSPACE/third_party/lib_tflite_micro
make patch
cd $GITHUB_WORKSPACE
./build.sh -T xinterpreter-nozip -b
cd $GITHUB_WORKSPACE/xformer
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo "using Google Cloud Storage cache"
echo -e 'build --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-arm64-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
bazelisk build //:xcore-opt --cpu=darwin_arm64 --copt=-fvisibility=hidden --copt=-mmacosx-version-min=11.0 --linkopt=-mmacosx-version-min=11.0 --linkopt=-dead_strip --//:disable_version_check
cd $GITHUB_WORKSPACE/python
python setup.py bdist_wheel --plat-name macosx_11_0_arm64
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-arm-wheels
path: python/dist
manylinux-release-wheel:
name: Build release wheels for manylinux2014
needs: [build-release-archive]
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ env.TAG_VERSION }}
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.BAZEL_REMOTE_CACHE_JSON_KEY }}
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: bash
run: |
cd $GITHUB_WORKSPACE/python/xmos_ai_tools/runtime
unzip release_archive.zip
rm release_archive.zip
- name: Build manylinux2014 wheels
# The SETUPTOOLS_SCM_PRETEND_VERSION var is passed via docker to the
# python setup.py script to add the version info for the wheel file.
#
# auditwheel requires patchelf and repairs the created wheel file to
# be compatible for manylinux.
run: |
pushd $GITHUB_WORKSPACE/xformer
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
echo "using Google Cloud Storage cache"
echo -e 'build --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-${{ runner.arch }}-python${{ matrix.python-version }}' >> .bazelrc.user
echo -e 'build --google_default_credentials' >> .bazelrc.user
fi
popd
if [[ -n $GOOGLE_APPLICATION_CREDENTIALS ]]; then
docker run -e SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.TAG_VERSION }} \
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcloud-credentials.json \
-v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/gcloud-credentials.json:ro \
-v ${PWD}:/ai_tools -w /ai_tools \
tensorflow/build:2.15-python${{ matrix.python-version }} \
.github/scripts/build_linux_wheel.sh
else
docker run -e SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.TAG_VERSION }} \
-v ${PWD}:/ai_tools -w /ai_tools \
tensorflow/build:2.15-python${{ matrix.python-version }} \
.github/scripts/build_linux_wheel.sh
fi
sudo apt-get -y -qq install patchelf --no-install-recommends
python -m pip install auditwheel==5.2.0 --no-cache-dir
cd python
for f in dist/*.whl; do
auditwheel repair --plat manylinux2014_x86_64 $f
done
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
# auditwheel creates the output wheel in the wheelhouse folder
path: python/wheelhouse
windows-release-wheel:
name: Build release wheels for windows
needs: [build-release-archive]
runs-on: windows-2019
strategy:
matrix:
python-version: [3.9]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
ref: ${{ env.TAG_VERSION }}
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: google-github-actions/auth@v2
continue-on-error: true
with:
credentials_json: ${{ secrets.BAZEL_REMOTE_CACHE_JSON_KEY }}
- name: Configure pagefile
uses: al-cheb/[email protected]
with:
minimum-size: 10GB
maximum-size: 20GB
- name: Set up pagefile
shell: pwsh
run: |
(Get-CimInstance Win32_PageFileUsage).AllocatedBaseSize
- uses: actions/download-artifact@v4
with:
name: xcore-archive
path: python/xmos_ai_tools/runtime
- name: Prepare release archive
shell: cmd
run: |
cd %GITHUB_WORKSPACE%/python/xmos_ai_tools/runtime
7z x release_archive.zip
del release_archive.zip
- name: Build xcore-opt and xtflm-interpreter
shell: cmd
run: |
python --version
python -m pip install wheel setuptools setuptools-scm numpy six --no-cache-dir
python -c "import sys; print(sys.executable)"
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cd %GITHUB_WORKSPACE%/third_party/lib_tflite_micro
make patch
cd %GITHUB_WORKSPACE%/python/xmos_ai_tools/xinterpreters
mkdir -p build
cd build
cmake ..
cmake --build . -t install --parallel --config Release
cd %GITHUB_WORKSPACE%/xformer
set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC
bazelisk --output_user_root c:\_bzl build //:xcore-opt --local_ram_resources=5120 --action_env PYTHON_BIN_PATH="C:/hostedtoolcache/windows/Python/3.9.13/x64/python.exe" --remote_cache=${{ env.BAZEL_CACHE_URL }}/${{ runner.os }}-${{ runner.arch }}-python${{ matrix.python-version }} --google_default_credentials --//:disable_version_check
- name: Build windows wheels
shell: cmd
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ env.TAG_VERSION }}
run: |
cd python
python setup.py bdist_wheel
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-wheels
path: python/dist
publish-wheels:
name: Publish wheels to PyPi
if: ${{ always() }}
needs: [macos-release-wheel, macos-arm-release-wheel, manylinux-release-wheel, windows-release-wheel]
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v4
with:
name: macOS-wheels
path: macOS-wheels
if: ${{ needs.macos-release-wheel.result == 'success' }}
- uses: actions/download-artifact@v4
with:
name: macOS-arm-wheels
path: macOS-arm-wheels
if: ${{ needs.macos-arm-release-wheel.result == 'success' }}
- uses: actions/download-artifact@v4
with:
name: Linux-wheels
path: Linux-wheels
if: ${{ needs.manylinux-release-wheel.result == 'success' }}
- uses: actions/download-artifact@v4
with:
name: Windows-wheels
path: Windows-wheels
if: ${{ needs.windows-release-wheel.result == 'success' }}
- run: |
set -x
mkdir -p dist
cp macOS-wheels/*.whl dist/ || true
cp macOS-arm-wheels/*.whl dist/ || true
cp Linux-wheels/*.whl dist/ || true
cp Windows-wheels/*.whl dist/ || true
ls -la dist/
sha256sum dist/*.whl
- name: Publish packages to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}