forked from csukuangfj/onnxruntime-build
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (157 loc) · 6.18 KB
/
Copy pathandroid-static.yaml
File metadata and controls
193 lines (157 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: android-static
on:
push:
branches:
- v1.23.2-2
workflow_dispatch:
inputs:
version:
description: "Version information (e.g., 1.23.2)"
required: true
permissions:
contents: write
env:
ONNXRUNTIME_VERSION:
|- # Enter release tag name or version name in workflow_dispatch. Appropriate version if not specified
${{ github.event.release.tag_name || github.event.inputs.version || '1.23.2' }}
jobs:
android-static:
name: android static lib ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
arch: [arm64-v8a, armeabi-v7a, x86, x86_64]
steps:
- name: Checkout
uses: actions/checkout@v4
# https://github.com/actions/setup-java
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: android-static-${{ env.ONNXRUNTIME_VERSION }}-${{ matrix.arch }}
# - uses: nttld/setup-ndk@v1
# id: setup-ndk
# with:
# ndk-version: r22
# add-to-path: false
- name: Display NDK HOME
shell: bash
run: |
echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}"
ls -lh ${ANDROID_NDK_LATEST_HOME}
export ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}
echo "ANDROID_NDK_HOME: $ANDROID_NDK_HOME"
echo "ANDROID_NDK: $ANDROID_NDK"
- name: Update ONNX Runtime
if: steps.cache-build-result.outputs.cache-hit != 'true'
run: |
echo $ONNXRUNTIME_VERSION > ONNXRUNTIME_VERSION
git submodule update --init --depth=1 onnxruntime
cd onnxruntime
git fetch origin tag v$ONNXRUNTIME_VERSION
git checkout v$ONNXRUNTIME_VERSION
- name: Download protoc
if: steps.cache-build-result.outputs.cache-hit != 'true'
shell: bash
run: |
# see ./cmake/deps.txt
if [[ ${{ env.ONNXRUNTIME_VERSION }} =~ 1.14.[0-9] ]]; then
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip
elif [[ ${{ env.ONNXRUNTIME_VERSION }} =~ 1.1[56789].[0-9] || ${{ env.ONNXRUNTIME_VERSION }} =~ 1.2[0-9].[0-9] ]]; then
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.12/protoc-21.12-linux-x86_64.zip
unzip protoc-21.12-linux-x86_64.zip
else
echo "Unsupported version ${{ env.ONNXRUNTIME_VERSION }}"
exit 1
fi
rm -fv protoc*.zip
./bin/protoc --version
- name: Set environment variable
if: steps.cache-build-result.outputs.cache-hit != 'true'
shell: bash
run: |
echo "$GITHUB_WORKSPACE/bin" >> "$GITHUB_PATH"
- name: Display protoc info for ${{ env.ONNXRUNTIME_VERSION }}
if: steps.cache-build-result.outputs.cache-hit != 'true'
shell: bash
run: |
protoc --version
- name: Show current directory
shell: bash
run: |
ls -lh
echo $PWD
- name: Install dependencies
if: steps.cache-build-result.outputs.cache-hit != 'true'
shell: bash
run: |
python3 -m pip install cmake
cmake --version
- name: Build onnxruntime for android ${{ matrix.arch}}
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
# For ndk 22
# export ANDROID_NDK_HOME=${{ steps.setup-ndk.outputs.ndk-path }}
# export ANDROID_NDK=${{ steps.setup-ndk.outputs.ndk-path }}
arch=${{ matrix.arch }}
export CMAKE_OPTIONS="--compile-no-warning-as-error -Donnxruntime_BUILD_UNIT_TESTS=OFF -DONNX_CUSTOM_PROTOC_EXECUTABLE=$GITHUB_WORKSPACE/bin/protoc -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=$arch -DANDROID_PLATFORM=android-21 -DANDROID_STL=c++_shared"
./build-static_lib.sh
- name: Collect result ${{ matrix.arch }}
shell: bash
run: |
ls -lh output/static_lib/
ls -lh output/static_lib/include
ls -lh output/static_lib/lib
dst=onnxruntime-android-${{ matrix.arch }}-static_lib-${{ env.ONNXRUNTIME_VERSION }}
mkdir $dst
mv -v output/static_lib/* $dst
zip -r ${dst}.zip $dst/
- uses: actions/upload-artifact@v4
with:
name: sherpa-onnx-android-${{ matrix.arch }}
path: ./onnxruntime*.zip
- name: Upload v${{ env.ONNXRUNTIME_VERSION }} ${{ matrix.arch }}
uses: svenstaro/upload-release-action@v2
with:
file_glob: true
file: "./onnxruntime*.zip"
overwrite: true
repo_name: csukuangfj/onnxruntime-libs
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
tag: v${{ env.ONNXRUNTIME_VERSION }}
- name: Publish to huggingface
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v2
with:
max_attempts: 20
timeout_seconds: 200
shell: bash
command: |
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"
rm -rf huggingface
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
ls -lh
git clone https://huggingface.co/csukuangfj2/onnxruntime-libs huggingface
cd huggingface
git pull
version=${{ env.ONNXRUNTIME_VERSION }}
mkdir -p $version
name=onnxruntime-android-${{ matrix.arch }}-static_lib-${{ env.ONNXRUNTIME_VERSION }}.zip
cp -v ../$name $version/
git status
git add .
git commit -m "add $name"
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/onnxruntime-libs main