Skip to content

Instantly share code, notes, and snippets.

@passos
Last active October 14, 2020 23:53

Revisions

  1. passos revised this gist Oct 14, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Notice:
    # GOOGLE_SERVICE_JSON, KEY_STORE_PROP, and STORE_FILE are the variants you can config in
    # GOOGLE_SERVICE_JSON, KEY_STORE_PROP, and STORE_FILE are the variants you can configure in
    # project settings so that you can avoid to expose it in project codebase.
    # The content of these variants are in Base64 format.

  2. passos revised this gist Oct 14, 2020. No changes.
  3. passos created this gist Oct 14, 2020.
    56 changes: 56 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    # Notice:
    # GOOGLE_SERVICE_JSON, KEY_STORE_PROP, and STORE_FILE are the variants you can config in
    # project settings so that you can avoid to expose it in project codebase.
    # The content of these variants are in Base64 format.

    image: openjdk:8-jdk

    variables:
    ANDROID_COMPILE_SDK: "28"
    ANDROID_BUILD_TOOLS: "28.0.3"
    ANDROID_SDK_TOOLS: "6609375_latest"

    before_script:
    - echo ANDROID_COMPILE_SDK ${ANDROID_COMPILE_SDK}
    - echo ANDROID_BUILD_TOOLS ${ANDROID_BUILD_TOOLS}
    - echo ANDROID_SDK_TOOLS ${ANDROID_SDK_TOOLS}
    - 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/commandlinetools-linux-${ANDROID_SDK_TOOLS}.zip
    - unzip -d android-sdk-linux android-sdk.zip
    - export ANDROID_SDK_ROOT=$PWD/android-sdk-linux
    - export SDK_MANAGER="${ANDROID_SDK_ROOT}/tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT}"
    - echo y | ${SDK_MANAGER} "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
    - echo y | ${SDK_MANAGER} "platform-tools" >/dev/null
    - echo y | ${SDK_MANAGER} "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
    - export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools/
    - chmod +x ./gradlew
    # temporarily disable checking for EPIPE error and use yes to accept all licenses
    - set +o pipefail
    - echo y | ${SDK_MANAGER} --licenses
    - set -o pipefail

    stages:
    - build

    assembleDebug:
    stage: build
    script:
    - echo ${GOOGLE_SERVICE_JSON} | base64 -d > app/google-services.json
    - echo ${KEY_STORE_PROP} | base64 -d > app/keystore.properties
    - echo ${STORE_FILE} | base64 -d > app/keystore.jks
    - ./gradlew assembleDebug
    artifacts:
    paths:
    - app/build/outputs/

    assembleRelease:
    stage: build
    script:
    - echo ${GOOGLE_SERVICE_JSON} | base64 -d > app/google-services.json
    - echo ${KEY_STORE_PROP} | base64 -d > app/keystore.properties
    - echo ${STORE_FILE} | base64 -d > app/keystore.jks
    - ./gradlew assembleRelease
    artifacts:
    paths:
    - app/build/outputs/