88 lines
2.9 KiB
YAML
88 lines
2.9 KiB
YAML
image: eclipse-temurin:17-jdk-jammy
|
|
|
|
variables:
|
|
ANDROID_COMPILE_SDK: "34"
|
|
ANDROID_BUILD_TOOLS: "33.0.2"
|
|
ANDROID_SDK_TOOLS: "9477386"
|
|
|
|
# Keystore credentials stored as GitLab CI/CD variables
|
|
KEYSTORE_FILE: "${CI_PROJECT_DIR}/keystore.jks" # Path to your keystore file
|
|
KEYSTORE_PASSWORD: $KS_PASSWORD # GitLab CI/CD variable for the keystore password
|
|
KEY_ALIAS: $KS_ALIAS # GitLab CI/CD variable for the key alias
|
|
KEY_PASSWORD: $KS_KEY_PASSWORD # GitLab CI/CD variable for the key password
|
|
|
|
before_script:
|
|
- apt-get --quiet update --yes
|
|
- apt-get --quiet install --yes wget unzip
|
|
- export ANDROID_HOME="${PWD}/android-sdk-root"
|
|
- install -d $ANDROID_HOME
|
|
- wget --no-verbose --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
|
|
- unzip -q -d "$ANDROID_HOME/cmdline-tools" "$ANDROID_HOME/cmdline-tools.zip"
|
|
- mv -T "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/tools"
|
|
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin
|
|
- sdkmanager --version
|
|
- yes | sdkmanager --licenses > /dev/null || true
|
|
- sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
|
|
- sdkmanager "platform-tools"
|
|
- sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
|
|
- chmod +x ./gradlew
|
|
|
|
lintDebug:
|
|
interruptible: true
|
|
stage: build
|
|
script:
|
|
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint
|
|
artifacts:
|
|
paths:
|
|
- app/lint/reports/lint-results-debug.html
|
|
expose_as: "lint-report"
|
|
when: always
|
|
|
|
assembleDebug:
|
|
interruptible: true
|
|
stage: build
|
|
script:
|
|
- ./gradlew assembleDebug
|
|
artifacts:
|
|
paths:
|
|
- app/build/outputs/
|
|
|
|
debugTests:
|
|
needs: [lintDebug, assembleDebug]
|
|
interruptible: true
|
|
stage: test
|
|
script:
|
|
- ./gradlew -Pci --console=plain :app:testDebug
|
|
artifacts:
|
|
paths:
|
|
- app/build/test-results/
|
|
|
|
publishTestResults:
|
|
stage: test
|
|
script:
|
|
- echo "Publishing JUnit test results"
|
|
needs: [debugTests]
|
|
artifacts:
|
|
when: always
|
|
reports:
|
|
junit: app/build/test-results/testDebugUnitTest/*.xml
|
|
|
|
# Job for building signed release APK when tag 'released' is created
|
|
assembleRelease:
|
|
stage: build
|
|
script:
|
|
- echo "Copying keystore file"
|
|
- cp $KEYSTORE_FILE $CI_PROJECT_DIR/app/keystore.jks
|
|
- echo "Building signed release APK"
|
|
- ./gradlew assembleRelease -Pandroid.injected.signing.store.file=$CI_PROJECT_DIR/app/keystore.jks \
|
|
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
|
|
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
|
|
-Pandroid.injected.signing.key.password=$KEY_PASSWORD
|
|
only:
|
|
- tags
|
|
except:
|
|
- "/^((?!released).)*$/"
|
|
artifacts:
|
|
paths:
|
|
- app/build/outputs/
|
|
expire_in: never |