Skip to content

Instantly share code, notes, and snippets.

@codekeyz
Last active March 21, 2020 20:10
Show Gist options
  • Save codekeyz/75c8b5a1e771ea667d49da26611a8dfb to your computer and use it in GitHub Desktop.
Save codekeyz/75c8b5a1e771ea667d49da26611a8dfb to your computer and use it in GitHub Desktop.
Gitlab CI for Flutter Android (Rev 1)
image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "28"
ANDROID_BUILD_TOOLS: "28.0.2"
ANDROID_SDK_TOOLS: "4333796"
FLUTTER_VERSION: "https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_v1.2.1-stable.tar.xz"
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
- unzip -d android-sdk-linux android-sdk.zip
- echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
# temporarily disable checking for EPIPE error and use yes to accept all licenses
- set +o pipefail
- yes | android-sdk-linux/tools/bin/sdkmanager --licenses
- set -o pipefail
# flutter sdk setup
- wget --output-document=flutter-sdk.tar.xz $FLUTTER_VERSION
- tar -xf flutter-sdk.tar.xz
- export PATH=$PATH:$PWD/flutter/bin
- echo flutter.sdk=$PWD/flutter > android/local.properties
- chmod +x ./android/gradlew
stages:
- test
- build
test:android:
stage: test
script:
- cd android
- ./gradlew -Pci --console=plain :app:testDebug
build:apk:
stage: build
script:
- flutter build apk
artifacts:
paths:
- build/app/outputs/apk
build:bundle:
stage: build
script:
- flutter build appbundle
artifacts:
paths:
- build/app/outputs/bundle
test:flutter:
stage: test
script:
- flutter test
@IhwanID
Copy link

IhwanID commented Nov 25, 2019

Thanks bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment