|
| 1 | +# This file is a template, and might need editing before it works on your project. |
| 2 | +# Read more about this script on this blog post https://about.gitlab.com/2018/10/24/setting-up-gitlab-ci-for-android-projects/, by Jason Lenny |
| 3 | +# If you are interested in using Android with FastLane for publishing take a look at the Android-Fastlane template. |
| 4 | + |
| 5 | +image: openjdk:8-jdk |
| 6 | + |
| 7 | +variables: |
| 8 | + |
| 9 | + # ANDROID_COMPILE_SDK is the version of Android you're compiling with. |
| 10 | + # It should match compileSdkVersion. |
| 11 | + ANDROID_COMPILE_SDK: "30" |
| 12 | + |
| 13 | + # ANDROID_BUILD_TOOLS is the version of the Android build tools you are using. |
| 14 | + # It should match buildToolsVersion. |
| 15 | + ANDROID_BUILD_TOOLS: "30.0.3" |
| 16 | + |
| 17 | + # It's what version of the command line tools we're going to download from the official site. |
| 18 | + # Official Site-> https://developer.android.com/studio/index.html |
| 19 | + # There, look down below at the cli tools only, sdk tools package is of format: |
| 20 | + # commandlinetools-os_type-ANDROID_SDK_TOOLS_latest.zip |
| 21 | + # when the script was last modified for latest compileSdkVersion, it was which is written down below |
| 22 | + ANDROID_SDK_TOOLS: "6514223" |
| 23 | + |
| 24 | +# Packages installation before running script |
| 25 | +before_script: |
| 26 | + - apt-get --quiet update --yes |
| 27 | + - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 |
| 28 | + |
| 29 | + # Setup path as android_home for moving/exporting the downloaded sdk into it |
| 30 | + - export ANDROID_HOME="${PWD}/android-home" |
| 31 | + # Create a new directory at specified location |
| 32 | + - install -d $ANDROID_HOME |
| 33 | + # Here we are installing androidSDK tools from official source, |
| 34 | + # (the key thing here is the url from where you are downloading these sdk tool for command line, so please do note this url pattern there and here as well) |
| 35 | + # after that unzipping those tools and |
| 36 | + # then running a series of SDK manager commands to install necessary android SDK packages that'll allow the app to build |
| 37 | + - wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip |
| 38 | + # move to the archive at ANDROID_HOME |
| 39 | + - pushd $ANDROID_HOME |
| 40 | + - unzip -d cmdline-tools cmdline-tools.zip |
| 41 | + - popd |
| 42 | + - export PATH=$PATH:${ANDROID_HOME}/cmdline-tools/tools/bin/ |
| 43 | + |
| 44 | + # Nothing fancy here, just checking sdkManager version |
| 45 | + - sdkmanager --version |
| 46 | + |
| 47 | + # use yes to accept all licenses |
| 48 | + - yes | sdkmanager --sdk_root=${ANDROID_HOME} --licenses || true |
| 49 | + - sdkmanager --sdk_root=${ANDROID_HOME} "platforms;android-${ANDROID_COMPILE_SDK}" |
| 50 | + - sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools" |
| 51 | + - sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;${ANDROID_BUILD_TOOLS}" |
| 52 | + |
| 53 | + # Not necessary, but just for surity |
| 54 | + - chmod +x ./gradlew |
| 55 | + |
| 56 | +# Basic android and gradle stuff |
| 57 | +# Check linting |
| 58 | +lintDebug: |
| 59 | + interruptible: true |
| 60 | + stage: build |
| 61 | + script: |
| 62 | + - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint |
| 63 | + |
| 64 | +# Make Project |
| 65 | +assembleOnlineRelease: |
| 66 | + interruptible: true |
| 67 | + stage: build |
| 68 | + script: |
| 69 | + - ./gradlew --parallel app:assembleOnlineRelease |
| 70 | + artifacts: |
| 71 | + paths: |
| 72 | + - app/build/outputs/ |
0 commit comments