Release Script Documentation
This directory contains scripts for building and releasing the MnnLlmChat Android application.
Files
release.sh- Main release script for building and publishing the appbump_version.sh- Version bump helper forversionNameandversionCodeupload-cdn.mjs- Upload APK to CDN (ali-oss)upload-market-config.mjs- Uploadmodel_market.jsonto OSS (data/mnn/apis/model_market.json)release.config.example- Example configuration filesetup_release.sh- Setup script to help configure the release environmenttest_build.sh- Test script to verify build commands work correctlyget_repo_info.py- Utility script for getting repository information
Quick Start
-
Setup the release environment:
./scripts/setup_release.sh -
Bump app version:
./scripts/bump_version.sh 0.7.7 752 -
Edit the configuration:
# Edit the configuration file with your actual values nano scripts/release.config -
Test the build commands:
./scripts/test_build.sh -
Run the release process:
source scripts/release.config ./scripts/release.sh
Release Script Usage
The release.sh script automates building the standard flavor debug APK (for CDN) and the Google Play flavor release AAB (for Google Play Store).
Prerequisites
- Java 11 or higher - Required for building Android projects
- Gradle Wrapper - Should be present in the project root
- Signing Configuration - Required for Google Play upload
- CDN Configuration - Required for CDN uploads
- Google Play Configuration - Required for Google Play uploads
Configuration
-
Copy the example configuration file:
cp scripts/release.config.example scripts/release.config -
Edit
scripts/release.configwith your actual values:- Signing Configuration: Path to keystore file and credentials
- CDN Configuration: Aliyun OSS endpoint and credentials
- Google Play Configuration: Service account JSON file path
-
Source the configuration file before running the script:
source scripts/release.config
Running the Release Script
From the project root directory:
# Run the complete release process
./scripts/release.sh
What the Script Does
- Requirements Check: Verifies Java version, Gradle wrapper, and configuration
- Clean Build: Removes previous builds and creates output directories
- Build Standard Debug: Builds the standard flavor debug APK for CDN distribution
- Build Google Play Release: Builds the Google Play flavor release AAB for Google Play Store
- Upload to CDN: Uploads the standard debug APK to Aliyun OSS CDN
- Upload to Google Play: Uploads the Google Play release AAB to Google Play Store
- Generate Release Notes: Creates release notes with build information
Output Structure
release_outputs/
├── cdn/
│ └── app-standard-debug.apk
├── googleplay/
│ └── app-googleplay-release.aab
└── release_notes.md
Environment Variables
The script uses the following environment variables (can be set in release.config):
Signing Configuration
KEYSTORE_FILE- Path to keystore fileKEYSTORE_PASSWORD- Keystore passwordKEY_ALIAS- Key aliasKEY_PASSWORD- Key password
CDN Configuration (automatic upload via ali-oss SDK)
Set in ~/.zshrc or release.config. No bucket/region defaults in codebase.
CDN_ENDPOINT- Aliyun OSS endpointCDN_ACCESS_KEY- Aliyun OSS access key IDCDN_SECRET_KEY- Aliyun OSS access key secretCDN_BUCKET- OSS bucket nameCDN_OSS_PREFIX- (optional) OSS path prefix, defaultdata/mnn/apks
Upload path: {CDN_OSS_PREFIX}/mnn_chat_{version}.apk
CDN upload uses Node.js + ali-oss SDK (no ossutil required). Run npm install once in the project root to install dependencies.
Google Play Configuration
GOOGLE_PLAY_SERVICE_ACCOUNT- Path to Google Play service account JSON fileGOOGLE_PLAY_PACKAGE_NAME- Google Play package name
Troubleshooting
Common Issues
- Java Version Error: Ensure Java 11 or higher is installed and in PATH
- Gradle Wrapper Missing: Run
gradle wrapperto generate the wrapper - Signing Configuration Missing: Google Play AAB build still works locally; upload is skipped
- CDN Upload Failed: Verify Aliyun OSS credentials and bucket permissions
- Google Play Upload Failed: Verify service account permissions and package name
Manual Steps
If the script fails, you can run individual steps manually:
# Build standard debug
./gradlew assembleStandardDebug
# Build Google Play bundle
./gradlew bundleGoogleplayRelease
# Clean build
./gradlew clean
Security Notes
- Never commit
release.configwith actual credentials - Use environment variables in CI/CD systems
- Keep keystore files secure and backed up
- Rotate access keys regularly
CI/CD Integration
For CI/CD integration, set the environment variables in your CI/CD system and run:
source scripts/release.config
./scripts/release.sh
The script will automatically detect missing configurations and skip those steps while continuing with available builds.