image: openjdk:8-jdk

variables:
  ANDROID_COMPILE_SDK: "29"
  ANDROID_BUILD_TOOLS: "29.0.2"
  ANDROID_SDK_TOOLS:   "4333796"

before_script:
  # - export vercode=$(cat ./app/build.gradle | grep versionName)
  # - export vercode=$(echo $vercode | awk -F[=\'] '{print $2}')
  # - echo $vercode > vercode.txt
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - if [ -f "android-sdk.zip" ]; then echo "exists!!" ; else wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip ; fi
  - 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 ./gradlew
  - set +o pipefail
  - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
  - set -o pipefail

stages:
  - release


# lintDebug:
#   stage: build
#   script:
#     - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint

assembleDebug:
  stage: release
  script:
    - ./gradlew assembleDebug
  artifacts:
    expire_in: 4 days
    paths:
    - app/build/outputs/

# assembleRelease:
#   stage: release
#   script:
#     - ./gradlew assembleRelease
#       -Pandroid.injected.signing.store.file=$(pwd)/.RELEASE.jks
#       -Pandroid.injected.signing.store.password=$PSWD
#       -Pandroid.injected.signing.key.alias=$AIZA
#       -Pandroid.injected.signing.key.password=$PSWD
#   artifacts:
#     paths:
#     - app/build/outputs/
