stages: - prepare - build - upload workflow: rules: - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "m_pg" changes: - "**/*" - "!**/*.md" - "!.github/**/*" - ".gitlab-ci.yml" - if: $CI_PIPELINE_SOURCE == "web" default: image: alpine:3.20 tags: - saas-linux-medium-amd64 before_script: - export ANDROID_HOME="${ANDROID_SDK_ROOT:-$ANDROID_HOME}" - echo "sdk.dir=${ANDROID_HOME}" > local.properties - echo "ndk.dir=${ANDROID_HOME}/ndk/27.2.12479018" >> local.properties - git config --global --add safe.directory $CI_PROJECT_DIR .fetch-status: &fetch-status | sed -i -E 's#https://github\.com/[^/]+/#https://gitlab.com/xtao-labs/mirrors/#g' .gitmodules sed -i 's|https://chromium\.googlesource\.com/libyuv/libyuv|https://gitlab.com/xtao-labs/mirrors/libyuv.git|g' .gitmodules git submodule sync git submodule update --init --force fingerprint: stage: prepare tags: - saas-linux-small-amd64 before_script: - apk add --no-cache git bash coreutils script: - *fetch-status - find TMessagesProj/jni/ -maxdepth 2 -type f -exec cat {} + > native_status 2>/dev/null - cat gradle/wrapper/gradle-wrapper.properties > gradle_status - export NATIVE_KEY=$(sha256sum native_status | cut -d' ' -f1) - export GRADLE_KEY=$(sha256sum gradle_status | cut -d' ' -f1) - echo "NATIVE_KEY=${NATIVE_KEY}" >> fingerprint.env - echo "GRADLE_KEY=${GRADLE_KEY}" >> fingerprint.env - cat fingerprint.env artifacts: reports: dotenv: fingerprint.env expire_in: 1 day build: stage: build image: registry.gitlab.com/xtao-labs/android-ndk:35-jdk17.0.19_10-ndk27.2.12479018-cmake3.22.1-ci needs: - job: fingerprint artifacts: true cache: - key: "gradle-${GRADLE_KEY}" paths: - .gradle-cache/ - key: "native-arm64-v8a-${NATIVE_KEY}" paths: - TMessagesProj/src/main/libs/arm64-v8a/ script: - *fetch-status - | if [[ ! -d TMessagesProj/src/main/libs/arm64-v8a ]]; then export NATIVE_TARGET="arm64-v8a" ./run init libs ./run libs native fi - sed -i "s/2000000000000/$(date +%s%N | cut -c1-13)/g" gradle.properties - export GRADLE_USER_HOME="$CI_PROJECT_DIR/.gradle-cache" - export LOCAL_PROPERTIES="${LOCAL_PROPERTIES}" - export SENTRY_AUTH_TOKEN="${SENTRY_AUTH_TOKEN}" - ./gradlew TMessagesProj:assembleRelease --build-cache --no-configuration-cache - APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') - APK_DIR=$(dirname "$APK") - mkdir -p artifacts/Release - cp -r "$APK_DIR"/* artifacts/Release/ - cp gradle.properties artifacts/gradle.properties artifacts: name: "Release-${CI_COMMIT_SHORT_SHA}" paths: - artifacts/Release/ - artifacts/gradle.properties expire_in: 1 week upload: stage: upload image: python:3.12-slim tags: - saas-linux-small-amd64 before_script: - apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* needs: - job: build artifacts: true script: - cp artifacts/gradle.properties gradle.properties - pip install --no-cache-dir -r bin/scripts/requirements.txt - git log -1 --pretty=format:"%s%n%n%b" > artifacts/caption.txt - python bin/scripts/upload.py "${HELPER_BOT_TOKEN}" "${HELPER_BOT_TARGET}"