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 bash bin/scripts/submodule.sh .setup-ccache: &setup-ccache | export CCACHE_DIR="$CI_PROJECT_DIR/.ccache" export CCACHE_COMPILERCHECK="%compiler% -dumpmachine; %compiler% -dumpversion" export CCACHE_NOHASHDIR="true" export CCACHE_MAXSIZE="5G" export CCACHE_HARDLINK="true" fingerprint: stage: prepare tags: - saas-linux-small-amd64 before_script: - apk add --no-cache git bash coreutils script: - git ls-tree -r HEAD | grep '^160000' > native_status - cat native_status - 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:36-jdk17.0.20_8-ndk27.2.12479018-cmake3.22.1-ci needs: - job: fingerprint artifacts: true cache: - key: "gradle-${GRADLE_KEY}" paths: - .gradle-cache/ - key: "ccache-arm64-v8a" paths: - .ccache/ - key: "native-submodules-${NATIVE_KEY}" paths: - submodules.tar.gz script: - *fetch-status - *setup-ccache # Only the arm64-v8a APK is published, so build native code for that ABI alone. - export NATIVE_TARGET="arm64-v8a" - 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}"