Skip to content

Build

Build #6

Workflow file for this run

name: Build
on:
workflow_dispatch:
inputs:
onnxruntime-version:
description: "ONNX Runtime version"
type: string
push:
tags:
- v*.*.*
env:
GCC_VERSION: 9
CMAKE_VERSION: 3.27
PYTHON_VERSION: 3.9
NODE_VERSION: 16
XCODE_VERSION: 14.2
MACOSX_DEPLOYMENT_TARGET: 10.13
defaults:
run:
shell: bash
jobs:
build:
name: Build
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-unknown-linux-gnu
runs-on: ubuntu-latest
build: |
sudo apt-get update && sudo apt install -y gcc make gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
CMAKE_OPTIONS="-DCMAKE_TOOLCHAIN_FILE=../../toolchains/default-aarch64-linux-gnu.cmake" ./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: x86_64-unknown-linux-gnu
runs-on: ubuntu-latest
build: ./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: aarch64-apple-darwin
runs-on: macos-latest
build: >
CMAKE_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64 -D onnxruntime_USE_COREML=ON"
./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: x86_64-apple-darwin
runs-on: macos-latest
build: >
CMAKE_OPTIONS="-D onnxruntime_USE_COREML=ON"
./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: x86_64-pc-windows-msvc
runs-on: windows-2022
build: >
CMAKE_OPTIONS="--compile-no-warning-as-error -D onnxruntime_USE_DML=ON -D CMAKE_CXX_FLAGS=-D_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS"
./build-static_lib.sh
post-build: 7z a $ARCHIVE_DIR/$ARCHIVE_NAME.zip $OUTPUT_DIR/*
- target: aarch64-pc-windows-msvc
runs-on: windows-2022
build: >
CMAKE_OPTIONS="-A ARM64 --compile-no-warning-as-error -D onnxruntime_USE_DML=ON -D onnxruntime_CROSS_COMPILING=ON -D CMAKE_CXX_FLAGS=-D_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS"
./build-static_lib.sh
post-build: 7z a $ARCHIVE_DIR/$ARCHIVE_NAME.zip $OUTPUT_DIR/*
- target: wasm32-unknown-emscripten
runs-on: ubuntu-latest
build: ./build-wasm-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup GCC
if: runner.os == 'Linux'
uses: egor-tensin/setup-gcc@v1
with:
version: ${{ env.GCC_VERSION }}
- name: Setup CMake
uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ env.CMAKE_VERSION }}
- name: Setup Python
id: setup-python
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python (Linux)
if: runner.os == 'Linux' && steps.setup-python.outcome == 'failure'
run: |
sudo apt-get update -q -y
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get install -q -y \
python${{ env.PYTHON_VERSION }} \
python${{ env.PYTHON_VERSION }}-distutils \
python${{ env.PYTHON_VERSION }}-venv
sudo update-alternatives --install /usr/bin/python python /usr/bin/python${{ env.PYTHON_VERSION }} 1
- name: Install Python (macOS)
if: runner.os == 'macOS' && steps.setup-python.outcome == 'failure'
run: brew install python@${{ env.PYTHON_VERSION }}
- name: Setup Node
if: startsWith(matrix.target, 'wasm')
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Xcode
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Set ONNX Runtime version
run: |
if ${{ startsWith(github.ref, 'refs/tags/v') }}; then
echo ONNXRUNTIME_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_ENV
elif [ -n "${{ inputs.onnxruntime-version }}" ]; then
echo ONNXRUNTIME_VERSION=${{ inputs.onnxruntime-version }} >> $GITHUB_ENV
else
echo ONNXRUNTIME_VERSION=$(cat ONNXRUNTIME_VERSION) >> $GITHUB_ENV
fi
- name: Set environment variables
run: |
echo OUTPUT_DIR=./output >> $GITHUB_ENV
echo ARCHIVE_DIR="${{ runner.temp }}" >> $GITHUB_ENV
echo ARCHIVE_NAME=msort_static-v${{ env.ONNXRUNTIME_VERSION }}-${{ matrix.target }} >> $GITHUB_ENV
- name: Build
run: ${{ matrix.build }}
- name: Post build
run: ${{ matrix.post-build }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_DIR }}/${{ env.ARCHIVE_NAME }}.*
release:
name: Release
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Release
uses: ncipollo/release-action@v1
with:
omitName: true
body: "Official Release: [ONNX Runtime ${{ github.ref_name }}](https://github.com/microsoft/onnxruntime/releases/tag/${{ github.ref_name }})"
artifacts: "*/*.*"
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true
omitDraftDuringUpdate: false