- Active AndroidX if it isn’t already.
- Create and checkout to new branch (appcenter currently only listen trigger from commit code on branch)
- Setup android:
- Comment those lines in file android/.gitignore
# gradle-wrapper.jar /.gradle /captures/ # /gradlew # /gradlew.bat /local.properties GeneratedPluginRegistrant.java
- Create KeyStore in android/app
- Add config to android/app/build.gradle
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } // Get VersionCode from AppCenter if auto build def appCenterVersionCode = System.getenv('APPCENTER_BUILD_ID') if (appCenterVersionCode != null) { flutterVersionCode = appCenterVersionCode }
- Modify
android\gradlew
to skip appcenter's gradle because we already call it inandroid/appcenter-post-clone.sh
. Add this code below or custom gradlew by yourself
#!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## if [[ "$@" != *"-Ptarget"* ]]; then echo "Not found target in arguments when call gradlew, force skip gradle." exit 0 fi
- Save file
android-appcenter-post-clone.sh
toandroid/app/appcenter-post-clone.sh
- Setup iOS:
- Get code signing files: Provisioning Profile (*.mobileprovision), Certificate (*.p12)
- Save file
ios-appcenter-post-clone.sh
toios/appcenter-post-clone.sh
- Set architectures in XCode to
arm64
- Commit these config
Last active
May 23, 2023 05:53
-
-
Save Thong-Tran/4ffb79da0955acba05dd2a6c2b71c808 to your computer and use it in GitHub Desktop.
Set up auto build and distribute flutter app on Appcenter
This file contains hidden or 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
#!/usr/bin/env bash | |
# Place this script in project/android/app/appcenter-post-clone.sh | |
# Original file stored at | |
# https://github.com/microsoft/appcenter/blob/master/sample-build-scripts/flutter/android-build/appcenter-post-clone.sh | |
cd .. | |
# fail if any command fails | |
set -e | |
# debug log | |
set -x | |
cd .. | |
git clone -b stable https://github.com/flutter/flutter.git | |
export PATH=`pwd`/flutter/bin:$PATH | |
flutter channel stable | |
flutter doctor | |
echo "Installed flutter to `pwd`/flutter" | |
# build APK | |
flutter -v build apk --release --target-platform android-arm64 --target $APP_TARGET | |
# copy the APK where AppCenter will find it | |
mkdir -p android/app/build/outputs/apk/; mv build/app/outputs/apk/release/app-release.apk $_ | |
# build bundle (AAB) | |
if [ "$BUILD_AAB" = "true" ] ; then | |
flutter -v build appbundle --target $APP_TARGET --target-platform android-arm,android-arm64,android-x64 | |
# copy the AAB where AppCenter will find it | |
mkdir -p android/app/build/outputs/bundle/; mv build/app/outputs/bundle/release/app-release.aab $_ | |
fi |
This file contains hidden or 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
#!/usr/bin/env bash | |
# Place this script in project/ios/appcenter-post-clone.sh | |
# Original file stored at | |
# https://github.com/microsoft/appcenter/blob/master/sample-build-scripts/flutter/ios-build/appcenter-post-clone.sh | |
# fail if any command fails | |
set -e | |
# debug log | |
set -x | |
cd .. | |
git clone -b stable https://github.com/flutter/flutter.git | |
export PATH=`pwd`/flutter/bin:$PATH | |
flutter channel stable | |
flutter doctor | |
echo "Installed flutter to `pwd`/flutter" | |
flutter -v pub get | |
function generate_new_config() { | |
new_str="" | |
while IFS=$'\n' read -r line; do | |
if [[ "$line" == *"FLUTTER_TARGET"* ]]; then | |
IFS='=' read -r key val <<< "$line" | |
new_str="$new_str"$'\n'"$key"="$APP_TARGET""$2" | |
else | |
if [[ "$line" == *"FLUTTER_FRAMEWORK_DIR"* ]]; then | |
IFS='=' read -r key val <<< "$line" | |
new_str="$new_str"$'\n'"$key"="`pwd`/flutter/bin/cache/artifacts/engine/ios-release""$2" | |
else | |
if [ "$new_str" == '' ] ; then | |
new_str="$line" | |
else | |
new_str="$new_str"$'\n'"$line" | |
fi | |
fi | |
fi | |
done < "$1" | |
echo "$new_str" > "$1" | |
} | |
eval generate_new_config ios/Flutter/flutter_export_environment.sh '\"' | |
eval generate_new_config ios/Flutter/Generated.xcconfig | |
# Install ios tools | |
flutter precache --ios --no-android --no-universal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment