Last active
October 31, 2019 11:46
-
-
Save hl3hl3/c04c27a48a898befcc6b718ca8d2562a to your computer and use it in GitHub Desktop.
.gitlab-ci.yml flutter project
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
# 官網介紹: https://about.gitlab.com/blog/2018/10/24/setting-up-gitlab-ci-for-android-projects/ | |
# Flutter 部分參考: https://medium.com/@chima_37359/setup-gitlab-ci-in-flutter-android-project-89f6628828e8 | |
# 映像檔 | |
image: openjdk:8-jdk | |
# 定義腳本中要用的變數 | |
variables: | |
ANDROID_COMPILE_SDK: "28" | |
ANDROID_BUILD_TOOLS: "28.0.2" | |
ANDROID_SDK_TOOLS: "4333796" | |
FLUTTER_LINUX_SDK_URL: "https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_v1.9.1+hotfix.6-stable.tar.xz" | |
# 在每個 job 前執行的腳本 | |
before_script: | |
# 這邊安裝工具 | |
- apt-get --quiet update --yes | |
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 | |
# 安裝&設定 android sdk | |
- 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/ | |
- chmod +x ./android/gradlew | |
# 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 | |
- wget --output-document=flutter-sdk.tar.xz $FLUTTER_LINUX_SDK_URL | |
- 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: | |
- build | |
- test | |
# build apk 的 Job | |
a_buildApk: | |
stage: build | |
script: | |
- flutter build apk | |
artifacts: | |
paths: | |
- build/app/outputs/apk | |
# build bundle 的 Job | |
a_buildAppBundle: | |
stage: build | |
script: | |
- flutter build appbundle | |
artifacts: | |
paths: | |
- build/app/outputs/bundle | |
# lint | |
a_lintDebug: | |
stage: build | |
script: | |
- cd android | |
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint | |
# 測試 android 的 job | |
a_testDebug: | |
stage: test | |
script: | |
- cd android | |
- ./gradlew -Pci --console=plain :app:testDebug | |
# 測試 flutter 的 job | |
f_flutterTest: | |
stage: test | |
script: | |
- flutter test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment