Skip to content

Commit

Permalink
Merge pull request #3 from AppFlowy-IO/migrate_builder
Browse files Browse the repository at this point in the history
feat: migrate builders
  • Loading branch information
LucasXu0 committed Jan 30, 2024
2 parents 47dcb99 + 8c72dc8 commit 7b194a8
Show file tree
Hide file tree
Showing 7 changed files with 1,044 additions and 35 deletions.
186 changes: 186 additions & 0 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
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
140 changes: 140 additions & 0 deletions .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Build AppFlowy iOS

on:
workflow_dispatch:
inputs:
repo:
description: "Repo"
required: true
default: "AppFlowy-IO/AppFlowy"
branch:
description: "Branch"
required: true
default: "main"
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: "1"
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: [macos-latest]
include:
- target: aarch64-apple-ios
runs-on: ${{ matrix.os }}

steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.branch }}

- name: Install the Apple certificate and provisioning profile
env:
IOS_CERTIFICATE_BASE64: ${{ secrets.IOS_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
IOS_PROVISION_PROFILE_BASE64: ${{ secrets.IOS_PROVISION_PROFILE_BASE64 }}
IOS_KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$IOS_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
echo -n "$IOS_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH
# create temporary keychain
security create-keychain -p "$IOS_KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$IOS_KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- 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: 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-apple-ios
cargo install --force duckscript_cli
cargo install --force cargo-lipo
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: Build AppFlowy
working-directory: frontend
run: |
cargo make --profile production-ios-arm64 appflowy-core-dev-ios
cargo make --profile production-ios-arm64 code_generation
cd appflowy_flutter
flutter build ipa --build-name ${{ github.event.inputs.build_name }} --build-number ${{ github.event.inputs.build_number }} --split-debug-info=./ --obfuscate
- name: Upload ipa
uses: actions/upload-artifact@v2
with:
name: AppFlowy.xcarchive
path: frontend/appflowy_flutter/build/ios/archive/Runner.xcarchive
Loading

0 comments on commit 7b194a8

Please sign in to comment.