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