| 5 |
| tag: |
| 6 | description: 'Release Tag' |
| 7 | required: true |
| 8 | play: |
| 9 | description: 'Play: If want ignore' |
| 10 | required: false |
| 11 | upload: |
| 12 | description: 'Upload: If want ignore' |
| 13 | required: false |
| 14 | publish: |
| 15 | description: 'Publish: If want ignore' |
| 16 | required: false |
| 17 | jobs: |
| 18 | check: |
| 19 | name: Check Access |
| 20 | runs-on: ubuntu-latest |
| 21 | steps: |
| 22 | - name: "Check access" |
| 23 | uses: "lannonbr/repo-permission-check-action@2.0.0" |
| 24 | with: |
| 25 | permission: "write" |
| 26 | env: |
| 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 28 | ffmpeg: |
| 29 | name: Native Build (FFmpeg) |
| 30 | runs-on: ubuntu-latest |
| 31 | needs: check |
| 32 | steps: |
| 33 | - name: Checkout |
| 34 | uses: actions/checkout@v2 |
| 35 | - name: Fetch Status |
| 36 | run: git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 37 | - name: FFmpeg Cache |
| 38 | id: cache |
| 39 | uses: actions/cache@v2 |
| 40 | with: |
| 41 | path: | |
| 42 | TMessagesProj/jni/ffmpeg/build |
| 43 | TMessagesProj/jni/libvpx/build |
| 44 | key: ${{ hashFiles('ffmpeg_status', 'libvpx_status', 'TMessagesProj/jni/*ffmpeg*.sh', 'TMessagesProj/jni/*libvpx*.sh', 'TMessagesProj/jni/patches/ffmpeg/*') }} |
| 45 | - name: Setup Android SDK Tools |
| 46 | uses: android-actions/setup-android@v2 |
| 47 | if: steps.cache.outputs.cache-hit != 'true' |
| 48 | - name: Install NDK |
| 49 | if: steps.cache.outputs.cache-hit != 'true' |
| 50 | run: | |
| 51 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 52 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 53 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 54 | - name: Native Build |
| 55 | if: steps.cache.outputs.cache-hit != 'true' |
| 56 | run: | |
| 57 | sudo apt-get install yasm -y |
| 58 | ./run init libs libvpx |
| 59 | ./run init libs ffmpeg |
| 60 | boringssl: |
| 61 | name: Native Build (BoringSSL) |
| 62 | runs-on: ubuntu-latest |
| 63 | needs: check |
| 64 | steps: |
| 65 | - name: Checkout |
| 66 | uses: actions/checkout@v2 |
| 67 | - name: Fetch Status |
| 68 | run: git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 69 | - name: BoringSSL Cache |
| 70 | id: cache |
| 71 | uses: actions/cache@v2 |
| 72 | with: |
| 73 | path: | |
| 74 | TMessagesProj/jni/boringssl/build |
| 75 | key: ${{ hashFiles('boringssl_status') }} |
| 76 | - name: Setup Android SDK Tools |
| 77 | uses: android-actions/setup-android@v2 |
| 78 | if: steps.cache.outputs.cache-hit != 'true' |
| 79 | - name: Install NDK |
| 80 | if: steps.cache.outputs.cache-hit != 'true' |
| 81 | run: | |
| 82 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 83 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 84 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 85 | - name: Native Build |
| 86 | if: steps.cache.outputs.cache-hit != 'true' |
| 87 | run: | |
| 88 | ./run init action boringssl |
| 89 | ./run init libs boringssl |
| 90 | native: |
| 91 | name: Native Build (Telegram) |
| 92 | runs-on: ubuntu-latest |
| 93 | needs: |
| 94 | - ffmpeg |
| 95 | - boringssl |
| 96 | strategy: |
| 97 | matrix: |
| 98 | flavor: |
| 99 | - armeabi-v7a |
| 100 | - arm64-v8a |
| 101 | - x86 |
| 102 | - x86_64 |
| 103 | steps: |
| 104 | - name: Checkout |
| 105 | uses: actions/checkout@v2 |
| 106 | - name: Fetch Status |
| 107 | run: | |
| 108 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 109 | git submodule status TMessagesProj/jni/libvpx > libvpx_status |
| 110 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 111 | - name: Native Cache |
| 112 | id: cache |
| 113 | uses: actions/cache@v2 |
| 114 | with: |
| 115 | path: | |
| 116 | TMessagesProj/src/main/libs |
| 117 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-${{ matrix.flavor }} |
| 118 | - name: Checkout Library |
| 119 | if: steps.cache.outputs.cache-hit != 'true' |
| 120 | run: | |
| 121 | git submodule update --init 'TMessagesProj/jni/*' |
| 122 | - name: FFmpeg Cache |
| 123 | uses: actions/cache@v2 |
| 124 | if: steps.cache.outputs.cache-hit != 'true' |
| 125 | with: |
| 126 | path: | |
| 127 | TMessagesProj/jni/ffmpeg/build |
| 128 | TMessagesProj/jni/libvpx/build |
| 129 | key: ${{ hashFiles('ffmpeg_status', 'libvpx_status', 'TMessagesProj/jni/*ffmpeg*.sh', 'TMessagesProj/jni/*libvpx*.sh', 'TMessagesProj/jni/patches/ffmpeg/*') }} |
| 130 | - name: BoringSSL Cache |
| 131 | uses: actions/cache@v2 |
| 132 | if: steps.cache.outputs.cache-hit != 'true' |
| 133 | with: |
| 134 | path: | |
| 135 | TMessagesProj/jni/boringssl/build |
| 136 | key: ${{ hashFiles('boringssl_status') }} |
| 137 | - name: Setup Android SDK Tools |
| 138 | uses: android-actions/setup-android@v2 |
| 139 | if: steps.cache.outputs.cache-hit != 'true' |
| 140 | - name: Install NDK |
| 141 | if: steps.cache.outputs.cache-hit != 'true' |
| 142 | run: | |
| 143 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 144 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 145 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 146 | - name: Fix BoringSSL |
| 147 | if: steps.cache.outputs.cache-hit != 'true' |
| 148 | run: | |
| 149 | cd TMessagesProj/jni |
| 150 | ./patch_boringssl.sh |
| 151 | - name: Native Build |
| 152 | if: steps.cache.outputs.cache-hit != 'true' |
| 153 | run: | |
| 154 | export NATIVE_TARGET="${{ matrix.flavor }}" |
| 155 | ./run libs native |
| 156 | v2ray: |
| 157 | name: Native Build (V2ray) |
| 158 | runs-on: ubuntu-latest |
| 159 | needs: check |
| 160 | steps: |
| 161 | - name: Checkout |
| 162 | uses: actions/checkout@v2 |
| 163 | - name: Fetch Status |
| 164 | run: git submodule status v2ray > v2ray_status |
| 165 | - name: V2ray Cache |
| 166 | id: cache |
| 167 | uses: actions/cache@v2 |
| 168 | with: |
| 169 | path: | |
| 170 | TMessagesProj/libs/libv2ray.aar |
| 171 | key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} |
| 172 | - name: Setup Android SDK Tools |
| 173 | uses: android-actions/setup-android@v2 |
| 174 | if: steps.cache.outputs.cache-hit != 'true' |
| 175 | - name: Install NDK |
| 176 | if: steps.cache.outputs.cache-hit != 'true' |
| 177 | run: | |
| 178 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 179 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 180 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 181 | - name: Install Golang |
| 182 | uses: actions/setup-go@v2 |
| 183 | if: steps.cache.outputs.cache-hit != 'true' |
| 184 | with: |
| 185 | go-version: 1.16 |
| 186 | - name: Native Build |
| 187 | if: steps.cache.outputs.cache-hit != 'true' |
| 188 | run: ./run libs v2ray |
| 189 | build: |
| 190 | name: Gradle Build |
| 191 | runs-on: ubuntu-latest |
| 192 | needs: |
| 193 | - native |
| 194 | - v2ray |
| 195 | strategy: |
| 196 | matrix: |
| 197 | flavor: |
| 198 | - MiniRelease |
| 199 | - MiniReleaseNoGcm |
| 200 | steps: |
| 201 | - name: Checkout |
| 202 | uses: actions/checkout@v2 |
| 203 | - name: Setup Android SDK Tools |
| 204 | uses: android-actions/setup-android@v2 |
| 205 | - name: Fetch Status |
| 206 | run: | |
| 207 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 208 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 209 | git submodule status v2ray > v2ray_status |
| 210 | - name: Native Cache (armeabi-v7a) |
| 211 | uses: actions/cache@v2 |
| 212 | with: |
| 213 | path: | |
| 214 | TMessagesProj/src/main/libs |
| 215 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-armeabi-v7a |
| 216 | - name: Native Cache (arm64-v8a) |
| 217 | uses: actions/cache@v2 |
| 218 | with: |
| 219 | path: | |
| 220 | TMessagesProj/src/main/libs |
| 221 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-arm64-v8a |
| 222 | - name: Native Cache (x86) |
| 223 | uses: actions/cache@v2 |
| 224 | with: |
| 225 | path: | |
| 226 | TMessagesProj/src/main/libs |
| 227 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86 |
| 228 | - name: Native Cache (x86_64) |
| 229 | uses: actions/cache@v2 |
| 230 | with: |
| 231 | path: | |
| 232 | TMessagesProj/src/main/libs |
| 233 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86_64 |
| 234 | - name: V2ray Cache |
| 235 | uses: actions/cache@v2 |
| 236 | with: |
| 237 | path: | |
| 238 | TMessagesProj/libs/libv2ray.aar |
| 239 | key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} |
| 240 | - name: Fix Gradle Memoery |
| 241 | run: | |
| 242 | sed -i -e "s/16384/6144/g" gradle.properties |
| 243 | echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" > local.properties |
| 244 | - name: Gradle cache |
| 245 | uses: actions/cache@v2 |
| 246 | with: |
| 247 | path: ~/.gradle |
| 248 | key: gradle-${{ hashFiles('**/*.gradle') }} |
| 249 | - name: Release Build |
| 250 | run: | |
| 251 | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" |
| 252 | ./gradlew TMessagesProj:assemble${{ matrix.flavor }} |
| 253 |
| 254 | APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') |
| 255 | APK=$(dirname $APK) |
| 256 | echo "APK=$APK" >> $GITHUB_ENV |
| 257 | - uses: actions/upload-artifact@v2 |
| 258 | with: |
| 259 | name: ${{ matrix.flavor }} |
| 260 | path: ${{ env.APK }} |
| 261 | publish: |
| 262 | name: Publish Release |
| 263 | if: github.event.inputs.publish != 'y' |
| 264 | runs-on: ubuntu-latest |
| 265 | needs: build |
| 266 | steps: |
| 267 | - name: Checkout |
| 268 | uses: actions/checkout@v2 |
| 269 | - name: Donwload Artifacts |
| 270 | uses: actions/download-artifact@v2 |
| 271 | with: |
| 272 | path: artifacts |
| 273 | - name: Release |
| 274 | run: | |
| 275 | wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz |
| 276 | tar -xvf ghr.tar.gz |
| 277 | mv ghr*linux_amd64/ghr . |
| 278 | mkdir apks |
| 279 | find artifacts -name "*.apk" -exec cp {} apks \; |
| 280 | ./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks |
| 281 | upload: |
| 282 | name: Upload Release |
| 283 | if: github.event.inputs.upload != 'y' |
| 284 | runs-on: ubuntu-latest |
| 285 | needs: |
| 286 | - build |
| 287 | - telegram-bot-api |
| 288 | steps: |
| 289 | - name: Donwload Artifacts |
| 290 | uses: actions/download-artifact@v2 |
| 291 | with: |
| 292 | path: artifacts |
| 293 | - name: Download Telegram Bot API Binary |
| 294 | uses: actions/download-artifact@master |
| 295 | with: |
| 296 | name: telegram-bot-api-binary |
| 297 | path: . |
| 298 | - name: Release |
| 299 | run: | |
| 300 | chmod +x telegram-bot-api-binary |
| 301 | ./telegram-bot-api-binary --api-id=21724 --api-hash=3e0cb5efcd52300aec5994fdfc5bdc16 --local 2>&1 > /dev/null & |
| 302 | curl http://127.0.0.1:8081/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage \ |
| 303 | -X POST \ |
| 304 | -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ |
| 305 | -F text="==== ${{ github.event.inputs.tag }} ====" \ |
| 306 | --silent --show-error --fail >/dev/null |
| 307 | mkdir apks |
| 308 | find artifacts -name "*.apk" -exec cp {} apks \; |
| 309 | function upload() { |
| 310 | for apk in $@; do |
| 311 | echo ">> Uploading $apk" |
| 312 | curl http://127.0.0.1:8081/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \ |
| 313 | -X POST \ |
| 314 | -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ |
| 315 | -F document="@$apk" \ |
| 316 | --retry 5 \ |
| 317 | --retry-delay 5 \ |
| 318 | --silent --show-error --fail >/dev/null |
| 319 | sleep 1 |
| 320 | done |
| 321 | } |
| 322 | upload apks/Nagram-*-mini-*-release.apk |
| 323 | upload apks/Nagram-*-mini-*-releaseNoGcm.apk |
| 324 | pkill telegram-bot |
| 325 | telegram-bot-api: |
| 326 | name: Telegram Bot API |
| 327 | runs-on: ubuntu-latest |
| 328 | steps: |
| 329 | - name: Checkout |
| 330 | uses: actions/checkout@v2 |
| 331 | - name: Clone Telegram Bot API |
| 332 | run: | |
| 333 | git clone --recursive https://github.com/tdlib/telegram-bot-api.git |
| 334 | git status telegram-bot-api >> telegram-bot-api-status |
| 335 | - name: Cache Bot API Binary |
| 336 | id: cache-bot-api |
| 337 | uses: actions/cache@v2 |
| 338 | with: |
| 339 | path: telegram-bot-api-binary |
| 340 | key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }} |
| 341 | - name: Compile Telegram Bot API |
| 342 | if: steps.cache-bot-api.outputs.cache-hit != 'true' |
| 343 | run: | |
| 344 | sudo apt-get update |
| 345 | sudo apt-get install make git zlib1g-dev libssl-dev gperf cmake g++ |
| 346 | cd telegram-bot-api |
| 347 | rm -rf build |
| 348 | mkdir build |
| 349 | cd build |
| 350 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. .. |
| 351 | cmake --build . --target install -j$(nproc) |
| 352 | cd ../.. |
| 353 | ls -l telegram-bot-api/bin/telegram-bot-api* |
| 354 | cp telegram-bot-api/bin/telegram-bot-api telegram-bot-api-binary |
| 355 | - name: Upload Binary |
| 356 | uses: actions/upload-artifact@master |
| 357 | with: |
| 358 | name: telegram-bot-api-binary |
| 359 | path: telegram-bot-api-binary |
| 360 |