| branches: |
| 6 | - dev |
| 7 | paths-ignore: |
| 8 | - '**.md' |
| 9 | - '.github/**' |
| 10 | - '!.github/workflows/debug.yml' |
| 11 |
| 12 | jobs: |
| 13 | build: |
| 14 | name: Gradle Build |
| 15 | runs-on: ubuntu-latest |
| 16 | env: |
| 17 | CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" |
| 18 | CCACHE_NOHASHDIR: "true" |
| 19 | CCACHE_MAXSIZE: "5G" |
| 20 | CCACHE_HARDLINK: "true" |
| 21 | steps: |
| 22 | - name: Checkout |
| 23 | uses: actions/checkout@v7 |
| 24 | with: |
| 25 | submodules: 'true' |
| 26 | - name: Set up JDK 17 |
| 27 | uses: actions/setup-java@v6 |
| 28 | with: |
| 29 | java-version: '17' |
| 30 | distribution: 'temurin' |
| 31 | - name: Setup Android SDK Tools |
| 32 | uses: android-actions/setup-android@v4 |
| 33 | with: |
| 34 | packages: 'platform-tools' |
| 35 | - name: Set up ccache |
| 36 | uses: hendrikmuhs/ccache-action@v1 |
| 37 | with: |
| 38 | append-timestamp: false |
| 39 | key: native-${{ github.job }} |
| 40 | max-size: 5G |
| 41 | - name: Install NDK |
| 42 | run: | |
| 43 | echo "y" | sdkmanager --install "ndk;27.2.12479018" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 44 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 45 | echo "ndk.dir=${ANDROID_HOME}/ndk/27.2.12479018" >> local.properties |
| 46 | - name: Configure Gradle |
| 47 | run: | |
| 48 | sed -i "s/2000000000000/$(date +%s%N | cut -c1-13)/g" gradle.properties |
| 49 | echo "sdk.dir=${ANDROID_HOME}" >> local.properties |
| 50 | - name: Setup Gradle |
| 51 | uses: gradle/actions/setup-gradle@v6 |
| 52 | with: |
| 53 | cache-read-only: false |
| 54 | - name: Debug Build |
| 55 | run: | |
| 56 | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" |
| 57 | export SENTRY_AUTH_TOKEN="${{ secrets.SENTRY_AUTH_TOKEN }}" |
| 58 | ./gradlew TMessagesProj:assembleRelease --build-cache --no-configuration-cache |
| 59 |
| 60 | APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') |
| 61 | APK=$(dirname $APK) |
| 62 | echo "APK=$APK" >> $GITHUB_ENV |
| 63 | - name: Upload gradle.properties |
| 64 | uses: actions/upload-artifact@v7 |
| 65 | with: |
| 66 | name: gradle-properties |
| 67 | path: gradle.properties |
| 68 | - uses: actions/upload-artifact@v7 |
| 69 | with: |
| 70 | name: Release |
| 71 | path: ${{ env.APK }} |
| 72 | upload: |
| 73 | name: Upload debug |
| 74 | if: github.event.inputs.upload != 'y' |
| 75 | # The channel-publish action runs a Bot API server built on this system. |
| 76 | runs-on: ubuntu-24.04 |
| 77 | needs: |
| 78 | - build |
| 79 | steps: |
| 80 | - name: Checkout |
| 81 | uses: actions/checkout@v7 |
| 82 | - name: Remove gradle.properties |
| 83 | run: | |
| 84 | rm -f gradle.properties |
| 85 | - name: Download gradle.properties |
| 86 | uses: actions/download-artifact@v8 |
| 87 | with: |
| 88 | name: gradle-properties |
| 89 | path: . |
| 90 | - name: Donwload Artifacts |
| 91 | uses: actions/download-artifact@v8 |
| 92 | with: |
| 93 | path: artifacts |
| 94 | - name: Set up Python |
| 95 | uses: actions/setup-python@v7 |
| 96 | with: |
| 97 | python-version: 3.12 |
| 98 | - name: Prepare channel post |
| 99 | id: post |
| 100 | env: |
| 101 | BOT_TOKEN: ${{ secrets.NAGRAM_CHANNEL_BOT_TOKEN }} |
| 102 | CHAT_ID: ${{ vars.NAGRAM_CHANNEL_ASSETS_CHAT_ID }} |
| 103 | COMMITS: ${{ toJSON(github.event.commits) }} |
| 104 | run: | |
| 105 | if [ -z "$BOT_TOKEN" ] || [ -z "$CHAT_ID" ]; then |
| 106 | echo "::notice::NAGRAM_CHANNEL_BOT_TOKEN or NAGRAM_CHANNEL_ASSETS_CHAT_ID is not set, nothing is posted to the channel." |
| 107 | exit 0 |
| 108 | fi |
| 109 | mkdir "$RUNNER_TEMP/channel" |
| 110 | find artifacts \( -name '*arm64-v8a.apk' -o -name '*armeabi-v7a.apk' \) \ |
| 111 | -exec cp {} "$RUNNER_TEMP/channel/" \; |
| 112 | ls -l "$RUNNER_TEMP/channel" |
| 113 | python bin/scripts/apk_version.py "$RUNNER_TEMP"/channel/*arm64-v8a.apk > "$RUNNER_TEMP/apk-version" |
| 114 | cat "$RUNNER_TEMP/apk-version" >> "$GITHUB_OUTPUT" |
| 115 | # The commits of the push, shown grouped by their kind. |
| 116 | printf '%s\n' "$COMMITS" > "$RUNNER_TEMP/channel-commits.json" |
| 117 | echo "chat=$CHAT_ID" >> "$GITHUB_OUTPUT" |
| 118 | # The in-app updater reads the APKs and their JSON from the metadata |
| 119 | # channel, whatever is posted to the channels below. |
| 120 | - name: Update metadata |
| 121 | env: |
| 122 | HELPER_BOT_TOKEN: ${{ secrets.HELPER_BOT_TOKEN }} |
| 123 | run: | |
| 124 | python -m pip install -r bin/scripts/requirements.txt |
| 125 | python bin/scripts/upload.py "$HELPER_BOT_TOKEN" |
| 126 | - name: Post to channel |
| 127 | if: steps.post.outputs.chat != '' |
| 128 | uses: NextAlone/NagramActionRelated/channel-publish@2b74e4cd4e3c89fcc9d50095c039e467c674661f |
| 129 | with: |
| 130 | bot-token: ${{ secrets.NAGRAM_CHANNEL_BOT_TOKEN }} |
| 131 | api-id: ${{ secrets.NAGRAM_API_ID }} |
| 132 | api-hash: ${{ secrets.NAGRAM_API_HASH }} |
| 133 | chat-id: ${{ steps.post.outputs.chat }} |
| 134 | directory: ${{ runner.temp }}/channel |
| 135 | kind: test |
| 136 | title: Nagram |
| 137 | version: ${{ steps.post.outputs.version }} |
| 138 | build: ${{ steps.post.outputs.build }} |
| 139 | hashtags: android test |
| 140 | commits-file: ${{ runner.temp }}/channel-commits.json |
| 141 | files: | |
| 142 | *arm64-v8a.apk | arm64-v8a · 大多数设备 |
| 143 | *armeabi-v7a.apk | armeabi-v7a · 旧设备 |
| 144 | buttons: Commit=${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }} |
| 145 |