| - upload |
| 6 |
| 7 | workflow: |
| 8 | rules: |
| 9 | - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "m_pg" |
| 10 | changes: |
| 11 | - "**/*" |
| 12 | - "!**/*.md" |
| 13 | - "!.github/**/*" |
| 14 | - ".gitlab-ci.yml" |
| 15 | - if: $CI_PIPELINE_SOURCE == "web" |
| 16 |
| 17 | default: |
| 18 | image: alpine:3.20 |
| 19 | tags: |
| 20 | - saas-linux-medium-amd64 |
| 21 | before_script: |
| 22 | - export ANDROID_HOME="${ANDROID_SDK_ROOT:-$ANDROID_HOME}" |
| 23 | - echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 24 | - echo "ndk.dir=${ANDROID_HOME}/ndk/27.2.12479018" >> local.properties |
| 25 | - git config --global --add safe.directory $CI_PROJECT_DIR |
| 26 |
| 27 | .fetch-status: &fetch-status | |
| 28 | sed -i -E 's#https://github\.com/[^/]+/#https://gitlab.com/xtao-labs/mirrors/#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 | native: |
| 53 | stage: native |
| 54 | image: registry.gitlab.com/xtao-labs/android-ndk:35-jdk17.0.19_10-ndk27.2.12479018-cmake3.22.1-ci |
| 55 | cache: |
| 56 | - key: "native-arm64-v8a-${NATIVE_KEY}" |
| 57 | paths: |
| 58 | - TMessagesProj/src/main/libs/arm64-v8a/ |
| 59 | script: |
| 60 | - | |
| 61 | if [[ -d TMessagesProj/src/main/libs/arm64-v8a ]]; then |
| 62 | exit 10 |
| 63 | fi |
| 64 | - *fetch-status |
| 65 | - export NATIVE_TARGET="arm64-v8a" |
| 66 | - ./run libs native |
| 67 | allow_failure: |
| 68 | exit_codes: 10 |
| 69 |
| 70 | build: |
| 71 | stage: build |
| 72 | image: registry.gitlab.com/xtao-labs/android-ndk:35-jdk17.0.19_10-ndk27.2.12479018-cmake3.22.1-ci |
| 73 | needs: |
| 74 | - job: fingerprint |
| 75 | artifacts: true |
| 76 | - job: native |
| 77 | cache: |
| 78 | - key: "gradle-${GRADLE_KEY}" |
| 79 | paths: |
| 80 | - .gradle-cache/ |
| 81 | - key: "native-arm64-v8a-${NATIVE_KEY}" |
| 82 | paths: |
| 83 | - TMessagesProj/src/main/libs/arm64-v8a/ |
| 84 | policy: pull |
| 85 | script: |
| 86 | - *fetch-status |
| 87 | - sed -i "s/2000000000000/$(date +%s%N | cut -c1-13)/g" gradle.properties |
| 88 | - export GRADLE_USER_HOME="$CI_PROJECT_DIR/.gradle-cache" |
| 89 | - export LOCAL_PROPERTIES="${LOCAL_PROPERTIES}" |
| 90 | - export SENTRY_AUTH_TOKEN="${SENTRY_AUTH_TOKEN}" |
| 91 | - ./gradlew TMessagesProj:assembleRelease --build-cache --no-configuration-cache |
| 92 | - APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') |
| 93 | - APK_DIR=$(dirname "$APK") |
| 94 | - mkdir -p artifacts/Release |
| 95 | - cp -r "$APK_DIR"/* artifacts/Release/ |
| 96 | - cp gradle.properties artifacts/gradle.properties |
| 97 | artifacts: |
| 98 | name: "Release-${CI_COMMIT_SHORT_SHA}" |
| 99 | paths: |
| 100 | - artifacts/Release/ |
| 101 | - artifacts/gradle.properties |
| 102 | expire_in: 1 week |
| 103 |
| 104 | upload: |
| 105 | stage: upload |
| 106 | image: python:3.12-slim |
| 107 | tags: |
| 108 | - saas-linux-small-amd64 |
| 109 | before_script: |
| 110 | - apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/* |
| 111 | needs: |
| 112 | - job: build |
| 113 | artifacts: true |
| 114 | script: |
| 115 | - cp artifacts/gradle.properties gradle.properties |
| 116 | - export mini64=$(find artifacts -name "*arm64-v8a.apk") |
| 117 | - export mini32=$(find artifacts -name "*armeabi-v7a.apk") |
| 118 | - echo $mini64 |
| 119 | - echo $mini32 |
| 120 | - pip install --no-cache-dir -r bin/scripts/requirements.txt |
| 121 | - git log -1 --pretty=format:"%s%n%n%b" > artifacts/caption.txt |
| 122 | - python bin/scripts/upload.py "${HELPER_BOT_TOKEN}" "${HELPER_BOT_TARGET}" test |
| 123 |