Skip to content

ubuntu

ubuntu #2

Workflow file for this run

name: ubuntu
on:
workflow_dispatch:
jobs:
ubuntu:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os_name: [ ubuntu ]
ver:
- { onnx: v1.18.1, cmake: 3.28.6, python: 3.8.18, gradle: 8.6, jdk: openjdk-11-jdk }
list:
- { os_ver: 20.04, os_id: focal }
- { os_ver: 22.04, os_id: jammy }
arch:
[
amd64,
arm,
arm64,
ppc64le,
]
exclude:
- list: { os_ver: 20.04, os_id: focal }
arch: arm64
name: ${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }}
env:
BUILD_SCRIPT: build-onnxruntime-linux.sh
SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}-shared
STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}-static
JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}-java
CMAKE_NAME: cmake-${{ matrix.ver.cmake }}-${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }}
PYTHON_NAME: python-${{ matrix.ver.python }}-${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }}
GRADLE_NAME: gradle-${{ matrix.ver.gradle }}-bin
steps:
# 检出代码
- uses: actions/checkout@v4
# 检出onnxruntime
- name: checkout onnxruntime
uses: actions/checkout@v4
with:
repository: microsoft/onnxruntime
path: onnxruntime-${{ matrix.ver.onnx }}
ref: ${{ matrix.ver.onnx }}
submodules: recursive
# 复制
- name: copy
run: |
cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }}
chmod a+x ${{ env.BUILD_SCRIPT }}
- name: Host - update
run: sudo apt-get update
- name: Host - Install host qemu-static
run: sudo apt-get install -y qemu binfmt-support qemu-user-static
- name: Host - Docker multiarch bootstrap
run: sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: deploy cmake
run: |
wget https://github.com/benjaminwan/CmakeBuilder/releases/download/${{ matrix.ver.cmake }}/${{ env.CMAKE_NAME }}.7z -O ${{ env.CMAKE_NAME }}.7z
7z x ${{ env.CMAKE_NAME }}.7z -aoa
rm ${{ env.CMAKE_NAME }}.7z
- name: deploy python
run: |
wget https://github.com/benjaminwan/PythonBuilder/releases/download/${{ matrix.ver.python }}/${{ env.PYTHON_NAME }}.7z -O ${{ env.PYTHON_NAME }}.7z
7z x ${{ env.PYTHON_NAME }}.7z -aoa
rm ${{ env.PYTHON_NAME }}.7z
- name: deploy gradle
run: |
wget https://services.gradle.org/distributions/${{ env.GRADLE_NAME }}.zip -O ${{ env.GRADLE_NAME }}.zip
7z x ${{ env.GRADLE_NAME }}.zip -aoa
rm ${{ env.GRADLE_NAME }}.zip
- name: Host - Create Docker template env file
run: |
echo "PATH=/root/cmake-${{ matrix.ver.cmake }}/bin:/root/python-${{ matrix.ver.python }}/bin:/root/gradle-${{ matrix.ver.gradle }}/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" > env.custom
echo "DEBIAN_FRONTEND=noninteractive" >> env.custom
echo "TZ=Etc/UTC" >> env.custom
- name: Host - Create docker container
run: docker run --name ${{ matrix.os_name }} --env-file env.custom --platform linux/${{ matrix.arch }} -it -d -w /root -v ${{ github.workspace }}:/root ${{ matrix.os_name }}:${{ matrix.list.os_id }}
- name: Docker - apt-get update
run: docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get update
- name: Docker - install build deps
run: docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get install -y build-essential git software-properties-common
- name: Docker - install jdk
run: |
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} add-apt-repository -y ppa:openjdk-r/ppa
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get update
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get -y install ${{ matrix.ver.jdk }}
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} java -version
JAVA_DIR=$(docker exec ${{ matrix.os_name }} readlink -f /usr/bin/javac | sed "s:/bin/javac::")
echo "$JAVA_DIR"
echo "JAVA_HOME=$JAVA_DIR" >> env.custom
echo "JAVA_INCLUDE_PATH=$JAVA_DIR/include" >> env.custom
- name: Docker - build lib
run: |
docker exec --env-file env.custom -w /root ${{ matrix.os_name }} git config --global --add safe.directory "*"
docker exec --env-file env.custom -w /root/onnxruntime-${{ matrix.ver.onnx }} ${{ matrix.os_name }} chmod a+x ${{ env.BUILD_SCRIPT }}
docker exec --env-file env.custom -w /root/onnxruntime-${{ matrix.ver.onnx }} ${{ matrix.os_name }} ./${{ env.BUILD_SCRIPT }}
# install文件夹改名linux,并使用7z压缩
- name: 7zip shared lib
run: |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install ${{ env.SHARED_PKG_NAME }}
7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ env.SHARED_PKG_NAME }}
rm -r -f ${{ env.SHARED_PKG_NAME }}
- name: 7zip static lib
run: |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install-static ${{ env.STATIC_PKG_NAME }}
7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ env.STATIC_PKG_NAME }}
rm -r -f ${{ env.STATIC_PKG_NAME }}
- name: Docker - build java
run: |
docker exec --env-file env.custom -w /root/onnxruntime-${{ matrix.ver.onnx }} ${{ matrix.os_name }} ./${{ env.BUILD_SCRIPT }} -j
- name: 7zip java lib
run: |
if [ -d "onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/java/build/libs" ]; then
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/java/build/libs ${{ env.JAVA_PKG_NAME }}
7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }}
rm -r -f ${{ env.JAVA_PKG_NAME }}
fi
# 上传artifact
# - name: upload shared lib
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.SHARED_PKG_NAME }}
# path: ${{ env.SHARED_PKG_NAME }}.7z
# - name: upload static lib
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.STATIC_PKG_NAME }}
# path: ${{ env.STATIC_PKG_NAME }}.7z
# - name: Check file existence
# id: check_java_7z
# uses: andstor/file-existence-action@v3
# with:
# files: "${{ env.JAVA_PKG_NAME }}.7z"
# - name: upload java lib
# if: steps.check_java_7z.outputs.files_exists == 'true'
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.JAVA_PKG_NAME }}
# path: ${{ env.JAVA_PKG_NAME }}.7z
# 获取所有的git log和tag
# - name: Unshallow
# run: git fetch --prune --unshallow
# 获取git log 从 previousTag 到 lastTag
# - name: Get git log
# id: git-log
# run: |
# previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
# lastTag=$(git describe --abbrev=0 --tags)
# echo "previousTag:$previousTag ~ lastTag:$lastTag"
# log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S')
# echo "$log"
# echo "log_state="$log"" >> $GITHUB_ENV
# 创建Changelog文件 triggered by git tag push
# - name: Generate Changelog
# if: startsWith(github.ref, 'refs/tags/')
# run: |
# echo -e '${{ env.log_state }}' > release.md
# 创建release 上传release
# https://github.com/marketplace/actions/create-release
- name: Create release and upload-archive
uses: ncipollo/release-action@v1
with:
prerelease: false
bodyFile: release.md
artifacts: 'onnxruntime-*.7z'
allowUpdates: true
artifactContentType: application/x-7z-compressed
token: ${{ secrets.GITHUB_TOKEN }}