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