Build AppFlowy Android #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build AppFlowy Android | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: "Branch" | |
required: true | |
default: "main" | |
repo: | |
description: "Repo" | |
required: true | |
default: "AppFlowy-IO/AppFlowy" | |
build_name: | |
description: "Build Version (it should match the version in pubspec.yaml)" | |
required: true | |
default: "0.4.3" | |
build_number: | |
description: 'Build Number (it should be unique)' | |
required: true | |
default: "2904300" | |
build_type: | |
type: choice | |
description: 'Build Type' | |
required: true | |
options: | |
- 'apk' | |
- 'appbundle' | |
server_type: | |
type: choice | |
description: 'Server Type (1 for local, 2 for cloud)' | |
required: true | |
default: '2' | |
options: | |
- 1 | |
- 2 | |
server_url: | |
description: 'Server URL' | |
required: true | |
default: 'https://beta.appflowy.cloud' | |
env: | |
FLUTTER_VERSION: "3.18.0-0.2.pre" | |
RUST_TOOLCHAIN: "1.75" | |
jobs: | |
build: | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ubuntu-latest] | |
include: | |
- os: ubuntu-latest | |
target: aarch64-linux-android | |
runs-on: ${{ matrix.os }} | |
steps: | |
# the following step is required to avoid running out of space | |
- name: Maximize build space | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
sudo rm -rf "/usr/local/share/boost" | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
with: | |
repository: ${{ github.event.inputs.repo }} | |
ref: ${{ github.event.inputs.branch }} | |
- name: Install Rust toolchain | |
id: rust_toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
target: ${{ matrix.target }} | |
override: true | |
profile: minimal | |
- name: Install flutter | |
id: flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "beta" | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
cache: true | |
- uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: "r24" | |
add-to-path: true | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
prefix-key: ${{ matrix.os }} | |
workspaces: | | |
frontend/rust-lib | |
- uses: davidB/rust-cargo-make@v1 | |
with: | |
version: '0.37.5' | |
- name: Install prerequisites | |
working-directory: frontend | |
run: | | |
rustup target install aarch64-linux-android | |
cargo install --force duckscript_cli | |
cargo install cargo-ndk | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub | |
sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list | |
sudo apt-get update | |
sudo apt-get install -y dart curl build-essential libssl-dev clang cmake ninja-build pkg-config libgtk-3-dev | |
sudo apt-get install keybinder-3.0 libnotify-dev | |
sudo apt-get install gcc-multilib | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
vcpkg integrate install | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
echo 'do nothing' | |
fi | |
cargo make appflowy-flutter-deps-tools | |
shell: bash | |
- name: Generate env file | |
working-directory: frontend/appflowy_flutter | |
run: | | |
echo "${{ github.env.inputs.server_url }}" > .env | |
echo "${{ github.env.inputs.server_type }}" >> .env | |
shell: bash | |
- name: Configure release sign | |
working-directory: frontend/appflowy_flutter/android/app | |
run: | | |
# replace signingConfig signingConfigs.debug with signingConfig signingConfigs.release | |
sed -i 's/signingConfig signingConfigs.debug/signingConfig signingConfigs.release/g' build.gradle | |
- name: Configure key.properties | |
working-directory: frontend/appflowy_flutter/android | |
run: | | |
echo "${{ secrets.ANDROID_UPLOAD_KEYSTORE_BASE64 }}" | base64 --decode > app/upload-keystore.jks | |
echo -e "storePassword=${{ secrets.ANDROID_UPLOAD_KEYSTORE_STORE_PASSWORD }}\nkeyPassword=${{ secrets.ANDROID_UPLOAD_KEYSTORE_KEY_PASSWORD }}\nkeyAlias=upload\nstoreFile=upload-keystore.jks" > key.properties | |
shell: bash | |
- name: Build AppFlowy | |
working-directory: frontend | |
env: | |
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
run: | | |
cargo make --profile production-android appflowy-core-dev-android | |
sh scripts/code_generation/generate.sh | |
cd appflowy_flutter | |
flutter pub get | |
if [ ${{github.event.inputs.build_type}} = "apk" ]; then | |
flutter build apk --build-name ${{ github.event.inputs.build_name }} --build-number ${{ github.event.inputs.build_number }} --split-per-abi --split-debug-info=./ --obfuscate | |
elif [ ${{github.event.inputs.build_type}} = "appbundle" ]; then | |
flutter build appbundle --build-name ${{ github.event.inputs.build_name }} --build-number ${{ github.event.inputs.build_number }} --split-debug-info=./ --obfuscate | |
fi | |
- name: Rename APK | |
if: github.event.inputs.build_type == 'apk' | |
run: | | |
mv frontend/appflowy_flutter/build/app/outputs/flutter-apk/app-arm64-v8a-release.apk frontend/appflowy_flutter/build/app/outputs/flutter-apk/AppFlowy.apk | |
shell: bash | |
- name: Upload APK | |
if: github.event.inputs.build_type == 'apk' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: AppFlowy-${{ github.event.inputs.build_name }}.apk | |
path: frontend/appflowy_flutter/build/app/outputs/flutter-apk/AppFlowy.apk | |
- name: Rename AAB | |
if: github.event.inputs.build_type == 'appbundle' | |
run: | | |
mv frontend/appflowy_flutter/build/app/outputs/bundle/release/app-release.aab frontend/appflowy_flutter/build/app/outputs/bundle/release/AppFlowy.aab | |
shell: bash | |
- name: Upload AAB | |
if: github.event.inputs.build_type == 'appbundle' | |
uses: actions/upload-artifact@v2 | |
with: | |
name: AppFlowy-${{ github.event.inputs.build_name }}.aab | |
path: frontend/appflowy_flutter/build/app/outputs/bundle/release/AppFlowy.aab |