-
-
Save cn-johndpope/f46e3584d62e80ffa5ac4500b9bec983 to your computer and use it in GitHub Desktop.
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
image: openjdk:8-jdk | |
stages: | |
- build | |
- package | |
#################################################################################################### | |
# BUILD | |
# | |
build_template: | |
stage: build | |
artifacts: | |
expire_in: 4 hours | |
paths: | |
- app/build/outputs/ | |
- .android/ | |
before_script: | |
# Extract the SDK version that we're building against | |
- export ANDROID_COMPILE_SDK=`egrep '^[[:blank:]]+compileSdkVersion' app/build.gradle | awk '{print $2}'` | |
# Explict output for logging purpose only | |
- echo $ANDROID_SDK_TOOLS | |
- echo $ANDROID_COMPILE_SDK | |
# Fetch the specified SDK tools version to build with | |
- wget --quiet --output-document=/tmp/sdk-tools-linux.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip | |
- unzip /tmp/sdk-tools-linux.zip -d .android | |
# Set up environment variables | |
- export ANDROID_HOME=$PWD/.android | |
- export PATH=$PATH:$PWD/.android/platform-tools/ | |
# Install platform tools and Android SDK for the compile target | |
- echo y | .android/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" | |
- chmod +x ./gradlew | |
build_debug: | |
only: | |
- develop | |
script: | |
- ./gradlew build ktling --stacktrace --info --debug | |
build_release: | |
only: | |
- master | |
script: | |
- ./gradlew assembeRelease ktling --stacktrace --info --debug | |
#################################################################################################### | |
# PACKAGE APK FOR DOWNLOADING | |
# | |
package_template: | |
before_script: | |
- export VERSION_NAME=`egrep '^[[:blank:]]+versionName[[:blank:]]' app/build.gradle | awk '{print $2}' | sed s/\"//g` | |
- export VERSION_CODE=`egrep '^[[:blank:]]+versionCode[[:blank:]]' app/build.gradle | awk '{print $2}'` | |
- mkdir -p deliverables | |
# Store some information about the build | |
- touch ./deliverables/info.txt | |
- echo "Build date $(date)" >> ./deliverables/info.txt | |
- echo "App version name ${VERSION_NAME}" >> ./deliverables/info.txt | |
- echo "App version code ${VERSION_CODE}" >> ./deliverables/info.txt | |
- echo "Git branch ${CI_COMMIT_REF_NAME}" >> ./deliverables/info.txt | |
- echo "Git commit ${CI_COMMIT_SHA}" >> ./deliverables/info.txt | |
- echo "Gitlab pipeline ${CI_PIPELINE_ID}" >> ./deliverables/info.txt | |
package_develop: | |
stage: package | |
environment: Development | |
only: | |
- develop | |
script: | |
- mv app/build/outputs/apk/app-debug.apk ./deliverables/motorist-v$VERSION_NAME-$VERSION_CODE-debug.apk | |
artifacts: | |
expire_in: 3 days | |
paths: | |
- deliverables | |
package_release: | |
stage: package | |
environment: Release | |
only: | |
- master | |
script: | |
- mv app/build/outputs/apk/app-release.apk ./deliverables/motorist-v$VERSION_NAME-$VERSION_CODE-release.apk | |
artifacts: | |
expire_in: 4 weeks | |
paths: | |
- deliverables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment