| 5 |
| - main |
| 6 | paths-ignore: |
| 7 | - '**.md' |
| 8 | - '.github/**' |
| 9 | - '!.github/workflows/release.yml' |
| 10 | workflow_dispatch: |
| 11 | inputs: |
| 12 | upload: |
| 13 | description: 'Upload: If want ignore' |
| 14 | required: false |
| 15 | jobs: |
| 16 | check: |
| 17 | name: Check Access |
| 18 | runs-on: ubuntu-latest |
| 19 | steps: |
| 20 | - name: "Check access" |
| 21 | uses: "lannonbr/repo-permission-check-action@2.0.0" |
| 22 | with: |
| 23 | permission: "write" |
| 24 | env: |
| 25 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | ffmpeg: |
| 27 | name: Native Build (FFmpeg) |
| 28 | runs-on: ubuntu-latest |
| 29 | needs: check |
| 30 | steps: |
| 31 | - name: Checkout |
| 32 | uses: actions/checkout@v2 |
| 33 | - name: Fetch Status |
| 34 | run: | |
| 35 | sed -i 's/\/\///g' settings.gradle |
| 36 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 37 | git submodule status TMessagesProj/jni/libvpx > libvpx_status |
| 38 | - name: FFmpeg Cache |
| 39 | id: cache |
| 40 | uses: actions/cache@v2 |
| 41 | with: |
| 42 | path: | |
| 43 | TMessagesProj/jni/ffmpeg/build |
| 44 | TMessagesProj/jni/libvpx/build |
| 45 | key: ${{ hashFiles('ffmpeg_status', 'libvpx_status', 'TMessagesProj/jni/*ffmpeg*.sh', 'TMessagesProj/jni/*libvpx*.sh', 'TMessagesProj/jni/patches/ffmpeg/*') }} |
| 46 | - name: Set up JDK 17 |
| 47 | uses: actions/setup-java@v3 |
| 48 | if: steps.cache.outputs.cache-hit != 'true' |
| 49 | with: |
| 50 | java-version: '17' |
| 51 | distribution: 'temurin' |
| 52 | - name: Setup Android SDK Tools |
| 53 | uses: android-actions/setup-android@v3 |
| 54 | if: steps.cache.outputs.cache-hit != 'true' |
| 55 | - name: Install NDK |
| 56 | if: steps.cache.outputs.cache-hit != 'true' |
| 57 | run: | |
| 58 | echo "y" | sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 59 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 60 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 61 | - name: Native Build |
| 62 | if: steps.cache.outputs.cache-hit != 'true' |
| 63 | run: | |
| 64 | sudo apt-get install yasm -y |
| 65 | ./run init libs libvpx |
| 66 | ./run init libs ffmpeg |
| 67 | boringssl: |
| 68 | name: Native Build (BoringSSL) |
| 69 | runs-on: ubuntu-latest |
| 70 | needs: check |
| 71 | steps: |
| 72 | - name: Checkout |
| 73 | uses: actions/checkout@v2 |
| 74 | - name: Fetch Status |
| 75 | run: | |
| 76 | sed -i 's/\/\///g' settings.gradle |
| 77 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 78 | - name: BoringSSL Cache |
| 79 | id: cache |
| 80 | uses: actions/cache@v2 |
| 81 | with: |
| 82 | path: | |
| 83 | TMessagesProj/jni/boringssl/build |
| 84 | key: ${{ hashFiles('boringssl_status') }} |
| 85 | - name: Set up JDK 17 |
| 86 | uses: actions/setup-java@v3 |
| 87 | if: steps.cache.outputs.cache-hit != 'true' |
| 88 | with: |
| 89 | java-version: '17' |
| 90 | distribution: 'temurin' |
| 91 | - name: Setup Android SDK Tools |
| 92 | uses: android-actions/setup-android@v3 |
| 93 | if: steps.cache.outputs.cache-hit != 'true' |
| 94 | - name: Install NDK |
| 95 | if: steps.cache.outputs.cache-hit != 'true' |
| 96 | run: | |
| 97 | echo "y" | sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 98 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 99 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 100 | - name: Native Build |
| 101 | if: steps.cache.outputs.cache-hit != 'true' |
| 102 | run: | |
| 103 | ./run init action boringssl |
| 104 | ./run init libs boringssl |
| 105 | native: |
| 106 | name: Native Build (Telegram) |
| 107 | runs-on: ubuntu-latest |
| 108 | needs: |
| 109 | - ffmpeg |
| 110 | - boringssl |
| 111 | strategy: |
| 112 | matrix: |
| 113 | flavor: |
| 114 | - armeabi-v7a |
| 115 | - arm64-v8a |
| 116 | steps: |
| 117 | - name: Checkout |
| 118 | uses: actions/checkout@v2 |
| 119 | - name: Fetch Status |
| 120 | run: | |
| 121 | sed -i 's/\/\///g' settings.gradle |
| 122 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 123 | git submodule status TMessagesProj/jni/libvpx > libvpx_status |
| 124 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 125 | - name: Native Cache |
| 126 | id: cache |
| 127 | uses: actions/cache@v2 |
| 128 | with: |
| 129 | path: | |
| 130 | TMessagesProj/src/main/libs |
| 131 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-${{ matrix.flavor }} |
| 132 | - name: Checkout Library |
| 133 | if: steps.cache.outputs.cache-hit != 'true' |
| 134 | run: | |
| 135 | git submodule update --init 'TMessagesProj/jni/*' |
| 136 | - name: FFmpeg Cache |
| 137 | uses: actions/cache@v2 |
| 138 | if: steps.cache.outputs.cache-hit != 'true' |
| 139 | with: |
| 140 | path: | |
| 141 | TMessagesProj/jni/ffmpeg/build |
| 142 | TMessagesProj/jni/libvpx/build |
| 143 | key: ${{ hashFiles('ffmpeg_status', 'libvpx_status', 'TMessagesProj/jni/*ffmpeg*.sh', 'TMessagesProj/jni/*libvpx*.sh', 'TMessagesProj/jni/patches/ffmpeg/*') }} |
| 144 | - name: BoringSSL Cache |
| 145 | uses: actions/cache@v2 |
| 146 | if: steps.cache.outputs.cache-hit != 'true' |
| 147 | with: |
| 148 | path: | |
| 149 | TMessagesProj/jni/boringssl/build |
| 150 | key: ${{ hashFiles('boringssl_status') }} |
| 151 | - name: Set up JDK 17 |
| 152 | uses: actions/setup-java@v3 |
| 153 | if: steps.cache.outputs.cache-hit != 'true' |
| 154 | with: |
| 155 | java-version: '17' |
| 156 | distribution: 'temurin' |
| 157 | - name: Setup Android SDK Tools |
| 158 | uses: android-actions/setup-android@v3 |
| 159 | if: steps.cache.outputs.cache-hit != 'true' |
| 160 | - name: Install NDK |
| 161 | if: steps.cache.outputs.cache-hit != 'true' |
| 162 | run: | |
| 163 | echo "y" | sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 164 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 165 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 166 | - name: Fix BoringSSL |
| 167 | if: steps.cache.outputs.cache-hit != 'true' |
| 168 | run: | |
| 169 | cd TMessagesProj/jni |
| 170 | ./patch_boringssl.sh |
| 171 | - name: Native Build |
| 172 | if: steps.cache.outputs.cache-hit != 'true' |
| 173 | run: | |
| 174 | export NATIVE_TARGET="${{ matrix.flavor }}" |
| 175 | ./run libs native |
| 176 | build: |
| 177 | name: Gradle Build |
| 178 | runs-on: ubuntu-latest |
| 179 | needs: |
| 180 | - native |
| 181 | strategy: |
| 182 | matrix: |
| 183 | flavor: |
| 184 | # - FullRelease |
| 185 | - MiniRelease |
| 186 | # - FullReleaseNoGcm |
| 187 | - MiniReleaseNoGcm |
| 188 | steps: |
| 189 | - name: Checkout |
| 190 | uses: actions/checkout@v2 |
| 191 | - name: Set up JDK 17 |
| 192 | uses: actions/setup-java@v3 |
| 193 | with: |
| 194 | java-version: '17' |
| 195 | distribution: 'temurin' |
| 196 | - name: Setup Android SDK Tools |
| 197 | uses: android-actions/setup-android@v3 |
| 198 | - name: Install NDK |
| 199 | run: | |
| 200 | echo "y" | sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 201 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 202 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 203 | - name: Fetch Status |
| 204 | run: | |
| 205 | sed -i 's/\/\///g' settings.gradle |
| 206 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 207 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 208 | - name: Native Cache (armeabi-v7a) |
| 209 | uses: actions/cache@v2 |
| 210 | with: |
| 211 | path: | |
| 212 | TMessagesProj/src/main/libs |
| 213 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-armeabi-v7a |
| 214 | - name: Native Cache (arm64-v8a) |
| 215 | uses: actions/cache@v2 |
| 216 | with: |
| 217 | path: | |
| 218 | TMessagesProj/src/main/libs |
| 219 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-arm64-v8a |
| 220 | - name: Configure Gradle |
| 221 | run: | |
| 222 | sed -i -e "s/16384/6144/g" gradle.properties |
| 223 | echo "sdk.dir=${ANDROID_HOME}" >> local.properties |
| 224 | - name: Gradle cache |
| 225 | uses: actions/cache@v2 |
| 226 | with: |
| 227 | path: ~/.gradle |
| 228 | key: gradle-${{ hashFiles('**/*.gradle') }} |
| 229 | - name: Release Build |
| 230 | run: | |
| 231 | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" |
| 232 | ./gradlew TMessagesProj:assemble${{ matrix.flavor }} |
| 233 |
| 234 | APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') |
| 235 | APK=$(dirname $APK) |
| 236 | echo "APK=$APK" >> $GITHUB_ENV |
| 237 | - uses: actions/upload-artifact@v2 |
| 238 | with: |
| 239 | name: ${{ matrix.flavor }} |
| 240 | path: ${{ env.APK }} |
| 241 | upload: |
| 242 | name: Upload release |
| 243 | if: github.event.inputs.upload != 'y' |
| 244 | runs-on: ubuntu-latest |
| 245 | needs: |
| 246 | - build |
| 247 | - telegram-bot-api |
| 248 | steps: |
| 249 | - name: Donwload Artifacts |
| 250 | uses: actions/download-artifact@v2 |
| 251 | with: |
| 252 | path: artifacts |
| 253 | - name: Download Telegram Bot API Binary |
| 254 | uses: actions/download-artifact@master |
| 255 | with: |
| 256 | name: telegram-bot-api-binary |
| 257 | path: . |
| 258 | - name: Send to Telegram |
| 259 | run: | |
| 260 | chmod +x telegram-bot-api-binary |
| 261 | function start() { |
| 262 | ./telegram-bot-api-binary --api-id=11535358 --api-hash=33d372962fadb01df47e6ceed4e33cd6 --local 2>&1 > /dev/null & |
| 263 | } |
| 264 | start |
| 265 | curl http://127.0.0.1:8081/ || start |
| 266 | curl http://127.0.0.1:8081/ || start |
| 267 | curl http://127.0.0.1:8081/ || start |
| 268 | # send release via telegram bot api |
| 269 | export mini64=$(find artifacts -name "*mini-arm64-v8a.apk") |
| 270 | export mini32=$(find artifacts -name "*mini-armeabi-v7a.apk") |
| 271 | # export full64=$(find artifacts -name "*full-arm64-v8a.apk") |
| 272 | # export full32=$(find artifacts -name "*full-armeabi-v7a.apk") |
| 273 | export mini64nogcm=$(find artifacts -name "*mini-arm64-v8aNoGcm.apk") |
| 274 | export mini32nogcm=$(find artifacts -name "*mini-armeabi-v7aNoGcm.apk") |
| 275 | # export full64nogcm=$(find artifacts -name "*full-arm64-v8aNoGcm.apk") |
| 276 | # export full32nogcm=$(find artifacts -name "*full-armeabi-v7aNoGcm.apk") |
| 277 |
| 278 | echo $mini64 |
| 279 | echo $mini32 |
| 280 | # echo $full64 |
| 281 | # echo $full32 |
| 282 | echo $mini64nogcm |
| 283 | echo $mini32nogcm |
| 284 | # echo $full64nogcm |
| 285 | # echo $full32nogcm |
| 286 |
| 287 | curl --http0.9 http://127.0.0.1:8081/bot${{ secrets.HELPER_BOT_TOKEN }}/sendMediaGroup --form-string chat_id=${{ secrets.HELPER_BOT_TARGET }} --form apk1=@"${mini64}" --form apk2=@"${mini32}" --form apk3=@"${mini64nogcm}" --form apk4=@"${mini32nogcm}" --form-string media="[{\"type\": \"document\",\"media\": \"attach://apk1\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk2\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk3\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk4\",\"caption\": \"${{ github.event.head_commit.message }}\",\"parse_mode\": \"Markdown\"}]" --verbose >/dev/null |
| 288 |
| 289 | pkill telegram-bot |
| 290 | telegram-bot-api: |
| 291 | name: Telegram Bot API |
| 292 | runs-on: ubuntu-latest |
| 293 | steps: |
| 294 | - name: Checkout |
| 295 | uses: actions/checkout@v2 |
| 296 | - name: Clone Telegram Bot API |
| 297 | run: | |
| 298 | git clone --recursive https://github.com/tdlib/telegram-bot-api.git |
| 299 | git status telegram-bot-api >> telegram-bot-api-status |
| 300 | - name: Cache Bot API Binary |
| 301 | id: cache-bot-api |
| 302 | uses: actions/cache@v2 |
| 303 | with: |
| 304 | path: telegram-bot-api-binary |
| 305 | key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }} |
| 306 | - name: Compile Telegram Bot API |
| 307 | if: steps.cache-bot-api.outputs.cache-hit != 'true' |
| 308 | run: | |
| 309 | sudo apt-get update |
| 310 | sudo apt-get install make git zlib1g-dev libssl-dev gperf cmake g++ |
| 311 | cd telegram-bot-api |
| 312 | rm -rf build |
| 313 | mkdir build |
| 314 | cd build |
| 315 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. .. |
| 316 | cmake --build . --target install -j$(nproc) |
| 317 | cd ../.. |
| 318 | ls -l telegram-bot-api/bin/telegram-bot-api* |
| 319 | cp telegram-bot-api/bin/telegram-bot-api telegram-bot-api-binary |
| 320 | - name: Upload Binary |
| 321 | uses: actions/upload-artifact@master |
| 322 | with: |
| 323 | name: telegram-bot-api-binary |
| 324 | path: telegram-bot-api-binary |
| 325 |