Skip to content

Build

Build #164

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: 11
CMAKE_VERSION: 3.26
PYTHON_VERSION: 3.9
NODE_VERSION: 20
XCODE_VERSION: 14.2
MACOSX_DEPLOYMENT_TARGET: 10.15
defaults:
run:
shell: bash
jobs:
build:
name: Build
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- target: linux-aarch64-static_lib
runs-on: buildjet-4vcpu-ubuntu-2204-arm
build: >
PARALLEL_JOB_COUNT=2
./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: linux-x64-static_lib
runs-on: ubuntu-22.04
build: ./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: osx-arm64-static_lib
runs-on: macos-13-xlarge
build: ./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: osx-universal2-static_lib
runs-on: macos-13-xlarge
build: >
CMAKE_OPTIONS="-D CMAKE_OSX_ARCHITECTURES=arm64;x86_64"
./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: osx-x86_64-static_lib
runs-on: macos-13
build: ./build-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
- target: win-x64-static_lib
runs-on: windows-2022
build: ./build-static_lib.sh
post-build: 7z a $ARCHIVE_DIR/$ARCHIVE_NAME.zip $OUTPUT_DIR/*
- target: wasm-static_lib-simd-threaded
runs-on: ubuntu-22.04
build: ./build-wasm-static_lib.sh
post-build: tar -czvf $ARCHIVE_DIR/$ARCHIVE_NAME.tgz -C $OUTPUT_DIR .
steps:
- name: Checkout
uses: actions/checkout@v4
- 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@v5
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@v4
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=onnxruntime-${{ matrix.target }}-${{ env.ONNXRUNTIME_VERSION }} >> $GITHUB_ENV
- name: Build
run: ${{ matrix.build }}
- name: Post build
run: ${{ matrix.post-build }}
- name: Upload artifact
uses: actions/upload-artifact@v4
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-22.04
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- 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