Skip to content

Build and Release App #13

Build and Release App

Build and Release App #13

Workflow file for this run

name: Build and Release App
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Create local.properties
run: |
echo "GITHUB_CLIENT_ID=${{ secrets.GITHUB_CLIENT_ID }}" >> local.properties
echo "GITHUB_CLIENT_SECRET=${{ secrets.GITHUB_CLIENT_SECRET }}" >> local.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Download and Extract Sherpa NCNN Library
run: |
# Create target directory
mkdir -p app/src/main/jniLibs/arm64-v8a
# Download the APK containing the library
curl -L -o sherpa.apk https://github.com/k2-fsa/sherpa-ncnn/releases/download/v2.1.15/sherpa-ncnn-2.1.15-cpu-arm64-v8a-bilingual-en-zh.apk
# Extract all library files from the APK
unzip -j sherpa.apk "lib/arm64-v8a/*.so" -d app/src/main/jniLibs/arm64-v8a/
# Create assets directory
mkdir -p app/src/main/assets/models
# Extract model assets
# The assets in APK are under 'assets/', we need to extract them and move to app/src/main/assets/models/
unzip -q sherpa.apk "assets/sherpa-ncnn-streaming-zipformer-bilingual-zh-en-2023-02-13/*" -d temp_assets
mv temp_assets/assets/sherpa-ncnn-streaming-zipformer-bilingual-zh-en-2023-02-13 app/src/main/assets/models/
rm -rf temp_assets
# Verify files exist
ls -l app/src/main/jniLibs/arm64-v8a/
ls -R app/src/main/assets/models/
- name: Configure Modules to Skip Stripping libsudo.so
run: |
# Configure terminal module
if [ -f terminal/build.gradle.kts ]; then
echo "" >> terminal/build.gradle.kts
echo 'android { packaging { jniLibs { keepDebugSymbols.add("**/libsudo.so") } } }' >> terminal/build.gradle.kts
echo "Added keepDebugSymbols for libsudo.so to terminal/build.gradle.kts"
elif [ -f terminal/build.gradle ]; then
echo "" >> terminal/build.gradle
echo 'android { packagingOptions { doNotStrip "**/libsudo.so" } }' >> terminal/build.gradle
echo "Added doNotStrip for libsudo.so to terminal/build.gradle"
else
echo "Terminal build file not found!"
ls -R terminal
exit 1
fi
# Configure app module to skip stripping when merging native libs
if [ -f app/build.gradle.kts ]; then
# Find the packaging block and inject keepDebugSymbols
# Since app/build.gradle.kts already has a packaging block, we need to be more careful
# We'll inject it within the existing jniLibs block if it exists, or create one
sed -i '/packaging {/a\ jniLibs {\n keepDebugSymbols.add("**/libsudo.so")\n }' app/build.gradle.kts
echo "Added keepDebugSymbols for libsudo.so to app/build.gradle.kts"
else
echo "App build file not found!"
exit 1
fi
- name: Fix Build Warnings
run: |
# Fix 1: Remove deprecated 'package' attribute from terminal AndroidManifest.xml
if [ -f terminal/src/main/AndroidManifest.xml ]; then
sed -i 's/package="com.ai.assistance.operit.terminal"//' terminal/src/main/AndroidManifest.xml
echo "Removed deprecated package attribute from terminal/src/main/AndroidManifest.xml"
else
echo "Warning: terminal/src/main/AndroidManifest.xml not found, skipping fix."
fi
# Fix 2: Suppress C++ warnings in MNN build
if [ -f mnn/build.gradle.kts ]; then
# Inject -w flag to suppress all warnings
# We look for the line 'cppFlags += listOf("-std=c++17", "-fno-emulated-tls")' and append "-w" to it
sed -i 's/"-std=c++17", "-fno-emulated-tls"/"-std=c++17", "-fno-emulated-tls", "-w"/' mnn/build.gradle.kts
echo "Injected -w flag into mnn/build.gradle.kts"
else
echo "Warning: mnn/build.gradle.kts not found, skipping fix."
fi
- name: Build Release APK
run: ./gradlew assembleRelease
- name: Sign Release APK
# If you want to sign with a real key in CI, you would typically decode a base64 keystore here.
# However, the project has a 'release.keystore' committed in the repo (which is unusual but simplifies things here).
# We just need to make sure the passwords match what's in build.gradle.kts or are passed as env vars if they were variables.
# In build.gradle.kts: storePassword = "android", keyPassword = "android".
# So it should just work.
run: echo "Build complete. APK should be signed with the committed keystore."
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
app/build/outputs/apk/release/*.apk
generate_release_notes: true