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