| 6 | rules: |
| 7 | - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "m_pg" |
| 8 | changes: |
| 9 | - "**/*" |
| 10 | - "!**/*.md" |
| 11 | - "!.github/**/*" |
| 12 | - ".gitlab-ci.yml" |
| 13 | - if: $CI_PIPELINE_SOURCE == "web" |
| 14 |
| 15 | default: |
| 16 | image: alpine:3.20 |
| 17 | tags: |
| 18 | - saas-linux-medium-amd64 |
| 19 | before_script: |
| 20 | - export ANDROID_HOME="${ANDROID_SDK_ROOT:-$ANDROID_HOME}" |
| 21 | - echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 22 | - echo "ndk.dir=${ANDROID_HOME}/ndk/27.2.12479018" >> local.properties |
| 23 | - git config --global --add safe.directory $CI_PROJECT_DIR |
| 24 |
| 25 | .fetch-status: &fetch-status | |
| 26 | sed -i -E 's#https://github\.com/[^/]+/#https://gitlab.com/xtao-labs/mirrors/#g' .gitmodules |
| 27 | sed -i 's|https://chromium\.googlesource\.com/libyuv/libyuv|https://gitlab.com/xtao-labs/mirrors/libyuv.git|g' .gitmodules |
| 28 | git submodule sync |
| 29 | git submodule update --init --force |
| 30 |
| 31 | fingerprint: |
| 32 | stage: prepare |
| 33 | tags: |
| 34 | - saas-linux-small-amd64 |
| 35 | before_script: |
| 36 | - apk add --no-cache git bash coreutils |
| 37 | script: |
| 38 | - *fetch-status |
| 39 | - find TMessagesProj/jni/ -maxdepth 2 -type f -exec cat {} + > native_status 2>/dev/null |
| 40 | - cat gradle/wrapper/gradle-wrapper.properties > gradle_status |
| 41 | - export NATIVE_KEY=$(sha256sum native_status | cut -d' ' -f1) |
| 42 | - export GRADLE_KEY=$(sha256sum gradle_status | cut -d' ' -f1) |
| 43 | - echo "NATIVE_KEY=${NATIVE_KEY}" >> fingerprint.env |
| 44 | - echo "GRADLE_KEY=${GRADLE_KEY}" >> fingerprint.env |
| 45 | - cat fingerprint.env |
| 46 | artifacts: |
| 47 | reports: |
| 48 | dotenv: fingerprint.env |
| 49 | expire_in: 1 day |
| 50 |
| 51 | build: |
| 52 | stage: build |
| 53 | image: registry.gitlab.com/xtao-labs/android-ndk:35-jdk17.0.19_10-ndk27.2.12479018-cmake3.22.1-ci |
| 54 | needs: |
| 55 | - job: fingerprint |
| 56 | artifacts: true |
| 57 | cache: |
| 58 | - key: "gradle-${GRADLE_KEY}" |
| 59 | paths: |
| 60 | - .gradle-cache/ |
| 61 | - key: "native-arm64-v8a-${NATIVE_KEY}" |
| 62 | paths: |
| 63 | - TMessagesProj/src/main/libs/arm64-v8a/ |
| 64 | script: |
| 65 | - *fetch-status |
| 66 | - | |
| 67 | if [[ ! -d TMessagesProj/src/main/libs/arm64-v8a ]]; then |
| 68 | export NATIVE_TARGET="arm64-v8a" |
| 69 | ./run libs native |
| 70 | fi |
| 71 | - sed -i "s/2000000000000/$(date +%s%N | cut -c1-13)/g" gradle.properties |
| 72 | - export GRADLE_USER_HOME="$CI_PROJECT_DIR/.gradle-cache" |
| 73 | - export LOCAL_PROPERTIES="${LOCAL_PROPERTIES}" |
| 74 | - export SENTRY_AUTH_TOKEN="${SENTRY_AUTH_TOKEN}" |
| 75 | - ./gradlew TMessagesProj:assembleRelease --build-cache --no-configuration-cache |
| 76 | - APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') |
| 77 | - APK_DIR=$(dirname "$APK") |
| 78 | - mkdir -p artifacts/Release |
| 79 | - cp -r "$APK_DIR"/* artifacts/Release/ |
| 80 | - cp gradle.properties artifacts/gradle.properties |
| 81 | artifacts: |
| 82 | name: "Release-${CI_COMMIT_SHORT_SHA}" |
| 83 | paths: |
| 84 | - artifacts/Release/ |
| 85 | - artifacts/gradle.properties |
| 86 | expire_in: 1 week |
| 87 |