-
Notifications
You must be signed in to change notification settings - Fork 536
184 lines (148 loc) · 4.75 KB
/
dot-net.yaml
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
name: release-nuget-package
on:
workflow_dispatch:
concurrency:
group: release-nuget-package
cancel-in-progress: true
permissions:
contents: read
jobs:
build-libs:
name: ${{ matrix.os }} ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
arch: [x64, x86, arm64]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build sherpa-onnx
shell: bash
run: |
arch=${{ matrix.arch }}
opts=""
if [ $arch == x86 ]; then
opts="-A Win32"
elif [ $arch == arm64 ]; then
opts="-A ARM64"
fi
mkdir build
cd build
cmake \
$opts \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_BUILD_C_API_EXAMPLES=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=ON \
..
cmake --build . --target install --config Release
rm -rf install/pkgconfig
- name: Create tar file
shell: bash
run: |
arch=${{ matrix.arch }}
cd build
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ../CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
dst=sherpa-onnx-$SHERPA_ONNX_VERSION-win-$arch
mv install/lib $dst
tar cjvf $dst.tar.bz2 $dst
ls -lh *.tar.bz2
mv *.tar.bz2 ../
- uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}
path: ./*.tar.bz2
# https://huggingface.co/docs/hub/spaces-github-actions
- name: Publish to huggingface
if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
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_CLONE_PROTECTION_ACTIVE=false
export GIT_LFS_SKIP_SMUDGE=1
git clone https://huggingface.co/csukuangfj/sherpa-onnx-libs huggingface
cd huggingface
mkdir -p windows-for-dotnet
cp -v ../sherpa-onnx-*.tar.bz2 ./windows-for-dotnet
git status
git lfs track "*.bz2"
git add .
git commit -m "add more files"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
rm -rf huggingface
release-nuget-package:
runs-on: ${{ matrix.os }}
needs: [build-libs]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip Jinja2
- name: Retrieve artifact from windows x64
uses: actions/download-artifact@v4
with:
name: windows-x64
path: /tmp/windows-x64
- name: Retrieve artifact from windows x86
uses: actions/download-artifact@v4
with:
name: windows-x86
path: /tmp/windows-x86
- name: Retrieve artifact from windows arm64
uses: actions/download-artifact@v4
with:
name: windows-arm64
path: /tmp/windows-arm64
- name: Check dotnet
run: dotnet --info
- name: Build
shell: bash
run: |
sudo apt-get install -y tree
ls -lh /tmp/
tree /tmp/windows*
echo "----"
rm -fv /tmp/windows*/*.lib
tree /tmp/windows*
- name: Build
shell: bash
run: |
cd scripts/dotnet
./run.sh
ls -lh /tmp/packages
- name: publish .Net packages to nuget.org
if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa'
shell: bash
env:
API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
# API_KEY is valid until 2025.04.26
cd /tmp/packages
dotnet nuget push ./org.k2fsa.sherpa.onnx.*.nupkg --skip-duplicate --api-key $API_KEY --source https://api.nuget.org/v3/index.json