update 1.17.3 #70
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: android | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
jobs: | |
android: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ver: | |
- { onnx: v1.17.3, ndk: 26.1.10909125, gradle: 8.5 } | |
list: | |
- { arch: armeabi-v7a, min: 19 } | |
- { arch: arm64-v8a, min: 21 } | |
- { arch: x86, min: 19 } | |
- { arch: x86_64 , min: 21 } | |
env: | |
BUILD_SCRIPT: build-onnxruntime-android.sh | |
SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.list.arch }}-shared | |
STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.list.arch }}-static | |
JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.list.arch }}-java | |
steps: | |
# install ndk | |
- name: install ndk | |
run: | | |
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ matrix.ver.ndk }}" | |
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ matrix.ver.ndk }}" >> $GITHUB_ENV | |
# 删除ndk -g参数 | |
- name: ndk del -g | |
run: | | |
echo $ANDROID_NDK_HOME | |
sed -i -e '/^ -g$/d' $ANDROID_NDK_HOME/build/cmake/android-legacy.toolchain.cmake | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8.18' | |
- uses: gradle/actions/setup-gradle@v3 | |
with: | |
gradle-version: ${{ matrix.ver.gradle }} | |
# Setup JDK 11 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: test gradle | |
run: gradle --version | |
# 检出代码 | |
- uses: actions/checkout@v3 | |
# 检出onnxruntime | |
- name: checkout onnxruntime | |
uses: actions/checkout@v3 | |
with: | |
repository: microsoft/onnxruntime | |
path: onnxruntime-${{ matrix.ver.onnx }} | |
ref: ${{ matrix.ver.onnx }} | |
submodules: recursive | |
# 复制编译脚本 | |
- name: copy build script | |
run: | | |
cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }} | |
# 编译 | |
- name: build | |
run: | | |
cd onnxruntime-${{ matrix.ver.onnx }} | |
chmod a+x ${{ env.BUILD_SCRIPT }} | |
./${{ env.BUILD_SCRIPT }} ${{ matrix.list.arch }} ${{ matrix.list.min }} | |
# 7z压缩 | |
- name: 7zip | |
run: | | |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-android-${{ matrix.list.arch }}/Release/install ${{ matrix.list.arch }} | |
7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ matrix.list.arch }} | |
rm -r -f ${{ matrix.list.arch }} | |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-android-${{ matrix.list.arch }}/Release/install-static ${{ matrix.list.arch }} | |
7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ matrix.list.arch }} | |
rm -r -f ${{ matrix.list.arch }} | |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-android-${{ matrix.list.arch }}/Release/java/build/libs ${{ matrix.list.arch }} | |
7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ matrix.list.arch }} | |
# 上传artifact | |
- name: upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.SHARED_PKG_NAME }} | |
path: ${{ env.SHARED_PKG_NAME }}.7z | |
- name: upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.STATIC_PKG_NAME }} | |
path: ${{ env.STATIC_PKG_NAME }}.7z | |
- name: upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.JAVA_PKG_NAME }} | |
path: ${{ env.JAVA_PKG_NAME }}.7z | |
release: | |
needs: [ android ] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
ver: | |
- { onnx: v1.17.3 } | |
env: | |
SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-android-shared | |
STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-android-static | |
JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-android-java | |
steps: | |
# 检出代码 | |
- uses: actions/checkout@v3 | |
# 获取所有的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 | |
# 下载artifact | |
- name: download | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
# 查看artifact | |
- name: list artifact | |
run: | | |
tree artifacts | |
# 合并 | |
- name: merge shared | |
run: | | |
mkdir onnxruntime-android-shared | |
mv artifacts/*/*-shared.7z artifacts/ | |
find artifacts/*-shared.7z -exec 7z x {} -aoa -oonnxruntime-android-shared \; | |
find artifacts/*-shared.7z -exec rm {} \; | |
pushd onnxruntime-android-shared | |
echo "message(\"OnnxRuntime Path: \${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" > OnnxRuntimeWrapper.cmake | |
echo "set(OnnxRuntime_DIR \"\${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" >> OnnxRuntimeWrapper.cmake | |
popd | |
7z a ${{ env.SHARED_PKG_NAME }}.7z onnxruntime-android-shared | |
rm -r -f onnxruntime-android-shared | |
- name: merge static | |
run: | | |
mkdir onnxruntime-android-static | |
mv artifacts/*/*-static.7z artifacts/ | |
find artifacts/*-static.7z -exec 7z x {} -aoa -oonnxruntime-android-static \; | |
find artifacts/*-static.7z -exec rm {} \; | |
pushd onnxruntime-android-static | |
echo "message(\"OnnxRuntime Path: \${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" > OnnxRuntimeWrapper.cmake | |
echo "set(OnnxRuntime_DIR \"\${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" >> OnnxRuntimeWrapper.cmake | |
popd | |
7z a ${{ env.STATIC_PKG_NAME }}.7z onnxruntime-android-static | |
rm -r -f onnxruntime-android-static | |
- name: merge java | |
run: | | |
mkdir onnxruntime-android-java | |
mv artifacts/*/*-java.7z artifacts/ | |
find artifacts/*-java.7z -exec 7z x {} -aoa -oonnxruntime-android-java \; | |
find artifacts/*-java.7z -exec rm {} \; | |
7z a ${{ env.JAVA_PKG_NAME }}.7z onnxruntime-android-java | |
rm -r -f onnxruntime-android-java | |
# 创建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: ${{ env.SHARED_PKG_NAME }}.7z,${{ env.STATIC_PKG_NAME }}.7z,${{ env.JAVA_PKG_NAME }}.7z | |
allowUpdates: true | |
artifactContentType: application/x-7z-compressed | |
token: ${{ secrets.GITHUB_TOKEN }} |