| 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 | key: ${{ hashFiles('ffmpeg_status', 'TMessagesProj/jni/*_ffmpeg.sh') }} |
| 44 | - name: Setup Android SDK Tools |
| 45 | uses: android-actions/setup-android@v2 |
| 46 | if: steps.cache.outputs.cache-hit != 'true' |
| 47 | - name: Install NDK |
| 48 | if: steps.cache.outputs.cache-hit != 'true' |
| 49 | run: | |
| 50 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 51 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 52 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 53 | - name: Native Build |
| 54 | if: steps.cache.outputs.cache-hit != 'true' |
| 55 | run: | |
| 56 | ./run init libs ffmpeg |
| 57 | boringssl: |
| 58 | name: Native Build (BoringSSL) |
| 59 | runs-on: ubuntu-latest |
| 60 | needs: check |
| 61 | steps: |
| 62 | - name: Checkout |
| 63 | uses: actions/checkout@v2 |
| 64 | - name: Fetch Status |
| 65 | run: git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 66 | - name: BoringSSL Cache |
| 67 | id: cache |
| 68 | uses: actions/cache@v2 |
| 69 | with: |
| 70 | path: | |
| 71 | TMessagesProj/jni/boringssl/build |
| 72 | key: ${{ hashFiles('boringssl_status') }} |
| 73 | - name: Setup Android SDK Tools |
| 74 | uses: android-actions/setup-android@v2 |
| 75 | if: steps.cache.outputs.cache-hit != 'true' |
| 76 | - name: Install NDK |
| 77 | if: steps.cache.outputs.cache-hit != 'true' |
| 78 | run: | |
| 79 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 80 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 81 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 82 | - name: Native Build |
| 83 | if: steps.cache.outputs.cache-hit != 'true' |
| 84 | run: | |
| 85 | ./run init action boringssl |
| 86 | ./run init libs boringssl |
| 87 | native: |
| 88 | name: Native Build (Telegram) |
| 89 | runs-on: ubuntu-latest |
| 90 | needs: |
| 91 | - ffmpeg |
| 92 | - boringssl |
| 93 | strategy: |
| 94 | matrix: |
| 95 | flavor: |
| 96 | - armeabi-v7a |
| 97 | - arm64-v8a |
| 98 | - x86 |
| 99 | - x86_64 |
| 100 | steps: |
| 101 | - name: Checkout |
| 102 | uses: actions/checkout@v2 |
| 103 | - name: Fetch Status |
| 104 | run: | |
| 105 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 106 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 107 | - name: Native Cache |
| 108 | id: cache |
| 109 | uses: actions/cache@v2 |
| 110 | with: |
| 111 | path: | |
| 112 | TMessagesProj/src/main/libs |
| 113 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-${{ matrix.flavor }} |
| 114 | - name: Checkout Library |
| 115 | if: steps.cache.outputs.cache-hit != 'true' |
| 116 | run: | |
| 117 | git submodule update --init 'TMessagesProj/jni/*' |
| 118 | - name: FFmpeg Cache |
| 119 | uses: actions/cache@v2 |
| 120 | if: steps.cache.outputs.cache-hit != 'true' |
| 121 | with: |
| 122 | path: | |
| 123 | TMessagesProj/jni/ffmpeg/build |
| 124 | key: ${{ hashFiles('ffmpeg_status', 'TMessagesProj/jni/*_ffmpeg.sh') }} |
| 125 | - name: BoringSSL Cache |
| 126 | uses: actions/cache@v2 |
| 127 | if: steps.cache.outputs.cache-hit != 'true' |
| 128 | with: |
| 129 | path: | |
| 130 | TMessagesProj/jni/boringssl/build |
| 131 | key: ${{ hashFiles('boringssl_status') }} |
| 132 | - name: Setup Android SDK Tools |
| 133 | uses: android-actions/setup-android@v2 |
| 134 | if: steps.cache.outputs.cache-hit != 'true' |
| 135 | - name: Install NDK |
| 136 | if: steps.cache.outputs.cache-hit != 'true' |
| 137 | run: | |
| 138 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 139 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 140 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 141 | - name: Fix BoringSSL |
| 142 | if: steps.cache.outputs.cache-hit != 'true' |
| 143 | run: | |
| 144 | cd TMessagesProj/jni |
| 145 | ./patch_boringssl.sh |
| 146 | - name: Native Build |
| 147 | if: steps.cache.outputs.cache-hit != 'true' |
| 148 | run: | |
| 149 | export NATIVE_TARGET="${{ matrix.flavor }}" |
| 150 | ./run libs native |
| 151 | v2ray: |
| 152 | name: Native Build (V2ray) |
| 153 | runs-on: ubuntu-latest |
| 154 | needs: check |
| 155 | steps: |
| 156 | - name: Checkout |
| 157 | uses: actions/checkout@v2 |
| 158 | - name: Fetch Status |
| 159 | run: git submodule status v2ray > v2ray_status |
| 160 | - name: V2ray Cache |
| 161 | id: cache |
| 162 | uses: actions/cache@v2 |
| 163 | with: |
| 164 | path: | |
| 165 | TMessagesProj/libs/libv2ray.aar |
| 166 | key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} |
| 167 | - name: Setup Android SDK Tools |
| 168 | uses: android-actions/setup-android@v2 |
| 169 | if: steps.cache.outputs.cache-hit != 'true' |
| 170 | - name: Install NDK |
| 171 | if: steps.cache.outputs.cache-hit != 'true' |
| 172 | run: | |
| 173 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 174 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 175 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 176 | - name: Install Golang |
| 177 | uses: actions/setup-go@v2 |
| 178 | if: steps.cache.outputs.cache-hit != 'true' |
| 179 | with: |
| 180 | go-version: 1.16 |
| 181 | - name: Native Build |
| 182 | if: steps.cache.outputs.cache-hit != 'true' |
| 183 | run: ./run libs v2ray |
| 184 | shadowsocks: |
| 185 | name: Native Build (Shadowsocks) |
| 186 | runs-on: ubuntu-latest |
| 187 | needs: check |
| 188 | steps: |
| 189 | - name: Checkout |
| 190 | uses: actions/checkout@v2 |
| 191 | - name: Fetch Status |
| 192 | run: git submodule status ss-rust/src/main/rust/shadowsocks-rust > shadowsocks_status |
| 193 | - name: Shadowsocks Cache |
| 194 | id: cache |
| 195 | uses: actions/cache@v2 |
| 196 | with: |
| 197 | path: | |
| 198 | TMessagesProj/libs/ss-rust-release.aar |
| 199 | key: ${{ hashFiles('shadowsocks_status') }} |
| 200 | - name: Setup Android SDK Tools |
| 201 | uses: android-actions/setup-android@v2 |
| 202 | if: steps.cache.outputs.cache-hit != 'true' |
| 203 | - name: Install NDK |
| 204 | if: steps.cache.outputs.cache-hit != 'true' |
| 205 | run: | |
| 206 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 207 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 208 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 209 | - name: Install Rust |
| 210 | if: steps.cache.outputs.cache-hit != 'true' |
| 211 | run: ./run init action shadowsocks |
| 212 | - name: Native Build |
| 213 | if: steps.cache.outputs.cache-hit != 'true' |
| 214 | run: ./run libs shadowsocks |
| 215 | shadowsocksr: |
| 216 | name: Native Build (ShadowsocksR) |
| 217 | runs-on: ubuntu-latest |
| 218 | needs: check |
| 219 | steps: |
| 220 | - name: Checkout |
| 221 | uses: actions/checkout@v2 |
| 222 | - name: Fetch Status |
| 223 | run: git submodule status 'ssr-libev/*' > shadowsocksr_status |
| 224 | - name: ShadowsocksR Cache |
| 225 | id: cache |
| 226 | uses: actions/cache@v2 |
| 227 | with: |
| 228 | path: | |
| 229 | TMessagesProj/libs/ssr-libev-release.aar |
| 230 | key: ${{ hashFiles('shadowsocksr_status') }} |
| 231 | - name: Setup Android SDK Tools |
| 232 | uses: android-actions/setup-android@v2 |
| 233 | if: steps.cache.outputs.cache-hit != 'true' |
| 234 | - name: Install NDK |
| 235 | if: steps.cache.outputs.cache-hit != 'true' |
| 236 | run: | |
| 237 | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null |
| 238 | echo "sdk.dir=${ANDROID_HOME}" > local.properties |
| 239 | echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties |
| 240 | - name: Native Build |
| 241 | if: steps.cache.outputs.cache-hit != 'true' |
| 242 | run: ./run libs ssr |
| 243 | build: |
| 244 | name: Gradle Build |
| 245 | runs-on: ubuntu-latest |
| 246 | needs: |
| 247 | - native |
| 248 | - v2ray |
| 249 | - shadowsocks |
| 250 | - shadowsocksr |
| 251 | strategy: |
| 252 | matrix: |
| 253 | flavor: |
| 254 | - FullRelease |
| 255 | - FullReleaseNoGcm |
| 256 | - MiniRelease |
| 257 | - MiniReleaseNoGcm |
| 258 | steps: |
| 259 | - name: Checkout |
| 260 | uses: actions/checkout@v2 |
| 261 | - name: Setup Android SDK Tools |
| 262 | uses: android-actions/setup-android@v2 |
| 263 | - name: Fetch Status |
| 264 | run: | |
| 265 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 266 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 267 | git submodule status ss-rust/src/main/rust/shadowsocks-rust > shadowsocks_status |
| 268 | git submodule status 'ssr-libev/*' > shadowsocksr_status |
| 269 | git submodule status v2ray > v2ray_status |
| 270 | - name: Native Cache (armeabi-v7a) |
| 271 | uses: actions/cache@v2 |
| 272 | with: |
| 273 | path: | |
| 274 | TMessagesProj/src/main/libs |
| 275 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-armeabi-v7a |
| 276 | - name: Native Cache (arm64-v8a) |
| 277 | uses: actions/cache@v2 |
| 278 | with: |
| 279 | path: | |
| 280 | TMessagesProj/src/main/libs |
| 281 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-arm64-v8a |
| 282 | - name: Native Cache (x86) |
| 283 | uses: actions/cache@v2 |
| 284 | with: |
| 285 | path: | |
| 286 | TMessagesProj/src/main/libs |
| 287 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86 |
| 288 | - name: Native Cache (x86_64) |
| 289 | uses: actions/cache@v2 |
| 290 | with: |
| 291 | path: | |
| 292 | TMessagesProj/src/main/libs |
| 293 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86_64 |
| 294 | - name: V2ray Cache |
| 295 | uses: actions/cache@v2 |
| 296 | with: |
| 297 | path: | |
| 298 | TMessagesProj/libs/libv2ray.aar |
| 299 | key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} |
| 300 | - name: Shadowsocks Cache |
| 301 | uses: actions/cache@v2 |
| 302 | with: |
| 303 | path: | |
| 304 | TMessagesProj/libs/ss-rust-release.aar |
| 305 | key: ${{ hashFiles('shadowsocks_status') }} |
| 306 | - name: ShadowsocksR Cache |
| 307 | uses: actions/cache@v2 |
| 308 | with: |
| 309 | path: | |
| 310 | TMessagesProj/libs/ssr-libev-release.aar |
| 311 | key: ${{ hashFiles('shadowsocksr_status') }} |
| 312 | - name: Fix Gradle Memoery |
| 313 | run: | |
| 314 | sed -i -e "s/16384/6144/g" gradle.properties |
| 315 | echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" > local.properties |
| 316 | - name: Fix Compile SDK 31.0.0 |
| 317 | run: ./run init env |
| 318 | - name: Gradle cache |
| 319 | uses: actions/cache@v2 |
| 320 | with: |
| 321 | path: ~/.gradle |
| 322 | key: gradle-${{ hashFiles('**/*.gradle') }} |
| 323 | - name: Release Build |
| 324 | run: | |
| 325 | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" |
| 326 | ./gradlew TMessagesProj:assemble${{ matrix.flavor }} |
| 327 |
| 328 | APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') |
| 329 | APK=$(dirname $APK) |
| 330 | echo "APK=$APK" >> $GITHUB_ENV |
| 331 | - uses: actions/upload-artifact@v2 |
| 332 | with: |
| 333 | name: ${{ matrix.flavor }} |
| 334 | path: ${{ env.APK }} |
| 335 | publish: |
| 336 | name: Publish Release |
| 337 | if: github.event.inputs.publish != 'y' |
| 338 | runs-on: ubuntu-latest |
| 339 | needs: build |
| 340 | steps: |
| 341 | - name: Checkout |
| 342 | uses: actions/checkout@v2 |
| 343 | - name: Donwload Artifacts |
| 344 | uses: actions/download-artifact@v2 |
| 345 | with: |
| 346 | path: artifacts |
| 347 | - name: Release |
| 348 | run: | |
| 349 | wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz |
| 350 | tar -xvf ghr.tar.gz |
| 351 | mv ghr*linux_amd64/ghr . |
| 352 | mkdir apks |
| 353 | find artifacts -name "*.apk" -exec cp {} apks \; |
| 354 | ./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks |
| 355 | upload: |
| 356 | name: Upload Release |
| 357 | if: github.event.inputs.upload != 'y' |
| 358 | runs-on: ubuntu-latest |
| 359 | needs: build |
| 360 | steps: |
| 361 | - name: Donwload Artifacts |
| 362 | uses: actions/download-artifact@v2 |
| 363 | with: |
| 364 | path: artifacts |
| 365 | - name: Release |
| 366 | run: | |
| 367 | mkdir apks |
| 368 | find artifacts -name "*.apk" -exec cp {} apks \; |
| 369 | function upload() { |
| 370 | for apk in $@; do |
| 371 | echo ">> Uploading $apk" |
| 372 | curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \ |
| 373 | -X POST \ |
| 374 | -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ |
| 375 | -F document="@$apk" \ |
| 376 | --silent --show-error --fail >/dev/null |
| 377 | done |
| 378 | } |
| 379 | upload apks/NekoX-mini-*-release.apk |
| 380 | upload apks/NekoX-mini-*-releaseNoGcm.apk |
| 381 | upload apks/NekoX-full-*-release.apk |
| 382 | upload apks/NekoX-full-*-releaseNoGcm.apk |
| 383 | play: |
| 384 | name: Publish to Play Store |
| 385 | if: github.event.inputs.play != 'y' |
| 386 | runs-on: ubuntu-latest |
| 387 | needs: |
| 388 | - native |
| 389 | - v2ray |
| 390 | - shadowsocks |
| 391 | - shadowsocksr |
| 392 | steps: |
| 393 | - name: Checkout |
| 394 | uses: actions/checkout@v2 |
| 395 | - name: Setup Android SDK Tools |
| 396 | uses: android-actions/setup-android@v2 |
| 397 | - name: Fetch Status |
| 398 | run: | |
| 399 | git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status |
| 400 | git submodule status TMessagesProj/jni/boringssl > boringssl_status |
| 401 | git submodule status ss-rust/src/main/rust/shadowsocks-rust > shadowsocks_status |
| 402 | git submodule status 'ssr-libev/*' > shadowsocksr_status |
| 403 | git submodule status v2ray > v2ray_status |
| 404 | - name: Native Cache (armeabi-v7a) |
| 405 | uses: actions/cache@v2 |
| 406 | with: |
| 407 | path: | |
| 408 | TMessagesProj/src/main/libs |
| 409 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-armeabi-v7a |
| 410 | - name: Native Cache (arm64-v8a) |
| 411 | uses: actions/cache@v2 |
| 412 | with: |
| 413 | path: | |
| 414 | TMessagesProj/src/main/libs |
| 415 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-arm64-v8a |
| 416 | - name: Native Cache (x86) |
| 417 | uses: actions/cache@v2 |
| 418 | with: |
| 419 | path: | |
| 420 | TMessagesProj/src/main/libs |
| 421 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86 |
| 422 | - name: Native Cache (x86_64) |
| 423 | uses: actions/cache@v2 |
| 424 | with: |
| 425 | path: | |
| 426 | TMessagesProj/src/main/libs |
| 427 | key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-x86_64 |
| 428 | - name: V2ray Cache |
| 429 | uses: actions/cache@v2 |
| 430 | with: |
| 431 | path: | |
| 432 | TMessagesProj/libs/libv2ray.aar |
| 433 | key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} |
| 434 | - name: Shadowsocks Cache |
| 435 | uses: actions/cache@v2 |
| 436 | with: |
| 437 | path: | |
| 438 | TMessagesProj/libs/ss-rust-release.aar |
| 439 | key: ${{ hashFiles('shadowsocks_status') }} |
| 440 | - name: ShadowsocksR Cache |
| 441 | uses: actions/cache@v2 |
| 442 | with: |
| 443 | path: | |
| 444 | TMessagesProj/libs/ssr-libev-release.aar |
| 445 | key: ${{ hashFiles('shadowsocksr_status') }} |
| 446 | - name: Fix Gradle Memoery |
| 447 | run: | |
| 448 | sed -i -e "s/16384/6144/g" gradle.properties |
| 449 | echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" > local.properties |
| 450 | - name: Fix Compile SDK 31.0.0 |
| 451 | run: ./run init env |
| 452 | - name: Gradle cache |
| 453 | uses: actions/cache@v2 |
| 454 | with: |
| 455 | path: ~/.gradle |
| 456 | key: gradle-${{ hashFiles('**/*.gradle') }} |
| 457 | - name: Publish to Play Store |
| 458 | run: | |
| 459 | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" |
| 460 | cat > service_account_credentials.json << EOF |
| 461 | ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}" |
| 462 | EOF |
| 463 | sed -i -e 's@<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />@@g' TMessagesProj/src/main/AndroidManifest.xml |
| 464 | ./gradlew TMessagesProj:publishMiniPlayRelease |