Skip to content

Commit 7921bb0

Browse files
authored
Fix publishing dart packages for Android (k2-fsa#3522)
1 parent 6357508 commit 7921bb0

35 files changed

Lines changed: 697 additions & 31 deletions

File tree

.github/workflows/release-dart-package.yaml

Lines changed: 273 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ concurrency:
1515

1616
jobs:
1717
build_linux_libs_x64:
18+
# if: false
1819
name: ${{ matrix.os }}
1920
runs-on: ${{ matrix.os }}
2021
strategy:
@@ -439,11 +440,11 @@ jobs:
439440
flutter pub publish --dry-run
440441
flutter pub publish --force
441442
442-
sherpa_onnx_android:
443+
sherpa_onnx_android_arm64:
443444
# if: false
444445
permissions:
445446
id-token: write # Required for authentication using OIDC
446-
name: sherpa_onnx_android
447+
name: sherpa_onnx_android_arm64
447448
runs-on: ubuntu-latest
448449

449450
steps:
@@ -458,14 +459,14 @@ jobs:
458459
- name: ccache
459460
uses: hendrikmuhs/ccache-action@v1.2
460461
with:
461-
key: ${{ matrix.os }}-flutter-release-package-android
462+
key: flutter-release-package-android-arm64
462463

463464
- name: Fix version
464465
shell: bash
465466
run: |
466467
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
467468
468-
src_dir=$PWD/flutter/sherpa_onnx_android
469+
src_dir=$PWD/flutter/sherpa_onnx_android_arm64
469470
pushd $src_dir
470471
v="version: $SHERPA_ONNX_VERSION"
471472
echo "v: $v"
@@ -477,7 +478,7 @@ jobs:
477478
- name: Copy extra files
478479
shell: bash
479480
run: |
480-
dst=flutter/sherpa_onnx_android
481+
dst=flutter/sherpa_onnx_android_arm64
481482
482483
mkdir $dst/example
483484
@@ -500,6 +501,91 @@ jobs:
500501
501502
./build-android-arm64-v8a.sh
502503
504+
- name: Copy pre-built libs
505+
shell: bash
506+
run: |
507+
echo "----arm64-v8a----"
508+
cp -v build-android-arm64-v8a/install/lib/lib*.so flutter/sherpa_onnx_android_arm64/android/src/main/jniLibs/arm64-v8a/
509+
510+
mv -v flutter/sherpa_onnx_android_arm64 /tmp/to_be_published
511+
512+
ls -lh /tmp/to_be_published
513+
514+
cd /tmp
515+
tar cjfv android_arm64.tar.bz2 ./to_be_published
516+
ls -lh android_arm64.tar.bz2
517+
518+
- uses: actions/upload-artifact@v4
519+
with:
520+
name: android-arm64
521+
path: /tmp/android_arm64.tar.bz2
522+
523+
- name: Setup Flutter SDK
524+
uses: flutter-actions/setup-flutter@v3
525+
with:
526+
channel: stable
527+
version: latest
528+
529+
- uses: dart-lang/setup-dart@v1
530+
531+
- name: Release
532+
shell: bash
533+
run: |
534+
cd /tmp/to_be_published
535+
du -h -d1 .
536+
537+
flutter pub get
538+
flutter pub publish --dry-run
539+
flutter pub publish --force
540+
541+
sherpa_onnx_android_armeabi:
542+
# if: false
543+
permissions:
544+
id-token: write # Required for authentication using OIDC
545+
name: sherpa_onnx_android_armeabi
546+
runs-on: ubuntu-latest
547+
548+
steps:
549+
- uses: actions/checkout@v4
550+
551+
- name: Update version
552+
shell: bash
553+
run: |
554+
./new-release.sh
555+
git diff .
556+
557+
- name: ccache
558+
uses: hendrikmuhs/ccache-action@v1.2
559+
with:
560+
key: flutter-release-package-android-armeabi
561+
562+
- name: Fix version
563+
shell: bash
564+
run: |
565+
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
566+
567+
src_dir=$PWD/flutter/sherpa_onnx_android_armeabi
568+
pushd $src_dir
569+
v="version: $SHERPA_ONNX_VERSION"
570+
echo "v: $v"
571+
sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml
572+
rm *.bak
573+
git status
574+
git diff
575+
576+
- name: Copy extra files
577+
shell: bash
578+
run: |
579+
dst=flutter/sherpa_onnx_android_armeabi
580+
581+
mkdir $dst/example
582+
583+
cp -v flutter/sherpa_onnx/example/* $dst/example
584+
cp -v LICENSE $dst/
585+
cp -v CHANGELOG.md $dst/
586+
587+
git status
588+
503589
- name: Build android-armv7-eabi
504590
shell: bash
505591
run: |
@@ -513,6 +599,91 @@ jobs:
513599
514600
./build-android-armv7-eabi.sh
515601
602+
- name: Copy pre-built libs
603+
shell: bash
604+
run: |
605+
echo "----armv7-eabi----"
606+
cp -v build-android-armv7-eabi/install/lib/lib*.so flutter/sherpa_onnx_android_armeabi/android/src/main/jniLibs/armeabi-v7a/
607+
608+
mv -v flutter/sherpa_onnx_android_armeabi /tmp/to_be_published
609+
610+
ls -lh /tmp/to_be_published
611+
612+
cd /tmp
613+
tar cjfv android_armeabi.tar.bz2 ./to_be_published
614+
ls -lh android_armeabi.tar.bz2
615+
616+
- uses: actions/upload-artifact@v4
617+
with:
618+
name: android-armeabi
619+
path: /tmp/android_armeabi.tar.bz2
620+
621+
- name: Setup Flutter SDK
622+
uses: flutter-actions/setup-flutter@v3
623+
with:
624+
channel: stable
625+
version: latest
626+
627+
- uses: dart-lang/setup-dart@v1
628+
629+
- name: Release
630+
shell: bash
631+
run: |
632+
cd /tmp/to_be_published
633+
du -h -d1 .
634+
635+
flutter pub get
636+
flutter pub publish --dry-run
637+
flutter pub publish --force
638+
639+
sherpa_onnx_android_x86:
640+
# if: false
641+
permissions:
642+
id-token: write # Required for authentication using OIDC
643+
name: sherpa_onnx_android_x86
644+
runs-on: ubuntu-latest
645+
646+
steps:
647+
- uses: actions/checkout@v4
648+
649+
- name: Update version
650+
shell: bash
651+
run: |
652+
./new-release.sh
653+
git diff .
654+
655+
- name: ccache
656+
uses: hendrikmuhs/ccache-action@v1.2
657+
with:
658+
key: flutter-release-package-android-x86
659+
660+
- name: Fix version
661+
shell: bash
662+
run: |
663+
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
664+
665+
src_dir=$PWD/flutter/sherpa_onnx_android_x86
666+
pushd $src_dir
667+
v="version: $SHERPA_ONNX_VERSION"
668+
echo "v: $v"
669+
sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml
670+
rm *.bak
671+
git status
672+
git diff
673+
674+
- name: Copy extra files
675+
shell: bash
676+
run: |
677+
dst=flutter/sherpa_onnx_android_x86
678+
679+
mkdir $dst/example
680+
681+
cp -v flutter/sherpa_onnx/example/* $dst/example
682+
cp -v LICENSE $dst/
683+
cp -v CHANGELOG.md $dst/
684+
685+
git status
686+
516687
- name: Build android-x86
517688
shell: bash
518689
run: |
@@ -526,6 +697,91 @@ jobs:
526697
527698
./build-android-x86.sh
528699
700+
- name: Copy pre-built libs
701+
shell: bash
702+
run: |
703+
echo "----x86----"
704+
cp -v build-android-x86/install/lib/lib*.so flutter/sherpa_onnx_android_x86/android/src/main/jniLibs/x86/
705+
706+
mv -v flutter/sherpa_onnx_android_x86 /tmp/to_be_published
707+
708+
ls -lh /tmp/to_be_published
709+
710+
cd /tmp
711+
tar cjfv android_x86.tar.bz2 ./to_be_published
712+
ls -lh *.tar.bz2
713+
714+
- uses: actions/upload-artifact@v4
715+
with:
716+
name: android-x86
717+
path: /tmp/android_x86.tar.bz2
718+
719+
- name: Setup Flutter SDK
720+
uses: flutter-actions/setup-flutter@v3
721+
with:
722+
channel: stable
723+
version: latest
724+
725+
- uses: dart-lang/setup-dart@v1
726+
727+
- name: Release
728+
shell: bash
729+
run: |
730+
cd /tmp/to_be_published
731+
du -h -d1 .
732+
733+
flutter pub get
734+
flutter pub publish --dry-run
735+
flutter pub publish --force
736+
737+
sherpa_onnx_android_x86_64:
738+
# if: false
739+
permissions:
740+
id-token: write # Required for authentication using OIDC
741+
name: sherpa_onnx_android_x86_64
742+
runs-on: ubuntu-latest
743+
744+
steps:
745+
- uses: actions/checkout@v4
746+
747+
- name: Update version
748+
shell: bash
749+
run: |
750+
./new-release.sh
751+
git diff .
752+
753+
- name: ccache
754+
uses: hendrikmuhs/ccache-action@v1.2
755+
with:
756+
key: flutter-release-package-android-x86_64
757+
758+
- name: Fix version
759+
shell: bash
760+
run: |
761+
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
762+
763+
src_dir=$PWD/flutter/sherpa_onnx_android_x86_64
764+
pushd $src_dir
765+
v="version: $SHERPA_ONNX_VERSION"
766+
echo "v: $v"
767+
sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml
768+
rm *.bak
769+
git status
770+
git diff
771+
772+
- name: Copy extra files
773+
shell: bash
774+
run: |
775+
dst=flutter/sherpa_onnx_android_x86_64
776+
777+
mkdir $dst/example
778+
779+
cp -v flutter/sherpa_onnx/example/* $dst/example
780+
cp -v LICENSE $dst/
781+
cp -v CHANGELOG.md $dst/
782+
783+
git status
784+
529785
- name: Build android-x86-64
530786
shell: bash
531787
run: |
@@ -542,22 +798,22 @@ jobs:
542798
- name: Copy pre-built libs
543799
shell: bash
544800
run: |
545-
echo "----arm64-v8a----"
546-
cp -v build-android-arm64-v8a/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/arm64-v8a/
547-
548-
echo "----armv7-eabi----"
549-
cp -v build-android-armv7-eabi/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/armeabi-v7a
550-
551-
echo "----x86----"
552-
cp -v build-android-x86/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/x86
553-
554801
echo "----x86_64----"
555-
cp -v build-android-x86-64/install/lib/lib*.so flutter/sherpa_onnx_android/android/src/main/jniLibs/x86_64
802+
cp -v build-android-x86-64/install/lib/lib*.so flutter/sherpa_onnx_android_x86_64/android/src/main/jniLibs/x86_64/
556803
557-
mv -v flutter/sherpa_onnx_android /tmp/to_be_published
804+
mv -v flutter/sherpa_onnx_android_x86_64 /tmp/to_be_published
558805
559806
ls -lh /tmp/to_be_published
560807
808+
cd /tmp
809+
tar cjfv android_x64.tar.bz2 ./to_be_published
810+
ls -lh *.tar.bz2
811+
812+
- uses: actions/upload-artifact@v4
813+
with:
814+
name: android-x64
815+
path: /tmp/android_x64.tar.bz2
816+
561817
- name: Setup Flutter SDK
562818
uses: flutter-actions/setup-flutter@v3
563819
with:
@@ -661,7 +917,7 @@ jobs:
661917
flutter pub publish --force
662918
663919
sherpa_onnx:
664-
needs: [sherpa_onnx_linux, sherpa_onnx_macos, sherpa_onnx_windows, sherpa_onnx_android, sherpa_onnx_ios]
920+
needs: [sherpa_onnx_linux, sherpa_onnx_macos, sherpa_onnx_windows, sherpa_onnx_android_arm64, sherpa_onnx_android_armeabi, sherpa_onnx_android_x86, sherpa_onnx_android_x86_64, sherpa_onnx_ios]
665921
# if: false
666922
permissions:
667923
id-token: write # Required for authentication using OIDC

.github/workflows/tauri-vad-asr.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ jobs:
4040
4141
- uses: dtolnay/rust-toolchain@stable
4242

43+
- name: Install Python dependencies
44+
shell: bash
45+
run: |
46+
if [[ "${{ runner.os }}" == "macOS" ]]; then
47+
python3 -m pip install --upgrade --break-system-packages pip jinja2 pillow
48+
else
49+
python3 -m pip install --upgrade pip jinja2 pillow
50+
fi
51+
4352
- name: Install Tauri CLI
4453
shell: bash
4554
run: |

flutter/notes.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ flutter create --template plugin_ffi --platforms linux sherpa_onnx_linux
2727
flutter create --template plugin_ffi --platforms linux sherpa_onnx_windows
2828
```
2929

30-
5. Create `sherpa_onnx_android`
30+
5. Create `sherpa_onnx_android_arm64`, `sherpa_onnx_android_armeabi`, `sherpa_onnx_android_x86`, `sherpa_onnx_android_x86_64`
3131

3232
```bash
33-
flutter create --template plugin_ffi --platforms android --org com.k2fsa.sherpa.onnx sherpa_onnx_android
33+
flutter create --template plugin_ffi --platforms android --org com.k2fsa.sherpa.onnx sherpa_onnx_android_arm64
34+
flutter create --template plugin_ffi --platforms android --org com.k2fsa.sherpa.onnx sherpa_onnx_android_armeabi
35+
flutter create --template plugin_ffi --platforms android --org com.k2fsa.sherpa.onnx sherpa_onnx_android_x86
36+
flutter create --template plugin_ffi --platforms android --org com.k2fsa.sherpa.onnx sherpa_onnx_android_x86_64
3437
```
3538

3639
6. Create `sherpa_onnx_ios`

0 commit comments

Comments
 (0)