| 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 | bash bin/scripts/submodule.sh |
| 30 |
| 31 | .setup-ccache: &setup-ccache | |
| 32 | export CCACHE_DIR="$CI_PROJECT_DIR/.ccache" |
| 33 | export CCACHE_COMPILERCHECK="%compiler% -dumpmachine; %compiler% -dumpversion" |
| 34 | export CCACHE_NOHASHDIR="true" |
| 35 | export CCACHE_MAXSIZE="5G" |
| 36 | export CCACHE_HARDLINK="true" |
| 37 |
| 38 | fingerprint: |
| 39 | stage: prepare |
| 40 | tags: |
| 41 | - saas-linux-small-amd64 |
| 42 | before_script: |
| 43 | - apk add --no-cache git bash coreutils |
| 44 | script: |
| 45 | - git ls-tree -r HEAD | grep '^160000' > native_status |
| 46 | - cat native_status |
| 47 | - cat gradle/wrapper/gradle-wrapper.properties > gradle_status |
| 48 | - export NATIVE_KEY=$(sha256sum native_status | cut -d' ' -f1) |
| 49 | - export GRADLE_KEY=$(sha256sum gradle_status | cut -d' ' -f1) |
| 50 | - echo "NATIVE_KEY=${NATIVE_KEY}" >> fingerprint.env |
| 51 | - echo "GRADLE_KEY=${GRADLE_KEY}" >> fingerprint.env |
| 52 | - cat fingerprint.env |
| 53 | artifacts: |
| 54 | reports: |
| 55 | dotenv: fingerprint.env |
| 56 | expire_in: 1 day |
| 57 |
| 58 | build: |
| 59 | stage: build |
| 60 | image: registry.gitlab.com/xtao-labs/android-ndk:36-jdk17.0.20_8-ndk27.2.12479018-cmake3.22.1-ci |
| 61 | needs: |
| 62 | - job: fingerprint |
| 63 | artifacts: true |
| 64 | cache: |
| 65 | - key: "gradle-${GRADLE_KEY}" |
| 66 | paths: |
| 67 | - .gradle-cache/ |
| 68 | - key: "ccache-arm64-v8a" |
| 69 | paths: |
| 70 | - .ccache/ |
| 71 | - key: "native-submodules-${NATIVE_KEY}" |
| 72 | paths: |
| 73 | - submodules.tar.gz |
| 74 | script: |
| 75 | - *fetch-status |
| 76 | - *setup-ccache |
| 77 | # Only the arm64-v8a APK is published, so build native code for that ABI alone. |
| 78 | - export NATIVE_TARGET="arm64-v8a" |
| 79 | - sed -i "s/2000000000000/$(date +%s%N | cut -c1-13)/g" gradle.properties |
| 80 | - export GRADLE_USER_HOME="$CI_PROJECT_DIR/.gradle-cache" |
| 81 | - export LOCAL_PROPERTIES="${LOCAL_PROPERTIES}" |
| 82 | - export SENTRY_AUTH_TOKEN="${SENTRY_AUTH_TOKEN}" |
| 83 | - ./gradlew TMessagesProj:assembleRelease --build-cache --no-configuration-cache |
| 84 | - APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') |
| 85 | - APK_DIR=$(dirname "$APK") |
| 86 | - mkdir -p artifacts/Release |
| 87 | - cp -r "$APK_DIR"/* artifacts/Release/ |
| 88 | - cp gradle.properties artifacts/gradle.properties |
| 89 | artifacts: |
| 90 | name: "Release-${CI_COMMIT_SHORT_SHA}" |
| 91 | paths: |
| 92 | - artifacts/Release/ |
| 93 | - artifacts/gradle.properties |
| 94 | expire_in: 1 week |
| 95 |
| 96 | upload: |
| 97 | stage: upload |
| 98 | image: python:3.12-slim |
| 99 | tags: |
| 100 | - saas-linux-small-amd64 |
| 101 | before_script: |
| 102 | - apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* |
| 103 | needs: |
| 104 | - job: build |
| 105 | artifacts: true |
| 106 | script: |
| 107 | - cp artifacts/gradle.properties gradle.properties |
| 108 | - pip install --no-cache-dir -r bin/scripts/requirements.txt |
| 109 | - git log -1 --pretty=format:"%s%n%n%b" > artifacts/caption.txt |
| 110 | - python bin/scripts/upload.py "${HELPER_BOT_TOKEN}" "${HELPER_BOT_TARGET}" |
| 111 |