name: Release Build on: workflow_dispatch: inputs: tag: description: 'Release Tag' required: true play: description: 'Play: If want ignore' required: false upload: description: 'Upload: If want ignore' required: false publish: description: 'Publish: If want ignore' required: false jobs: check: name: Check Access runs-on: ubuntu-latest steps: - name: "Check access" uses: "lannonbr/repo-permission-check-action@2.0.0" with: permission: "write" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} native: name: Native Build needs: check runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Setup Android SDK Tools uses: android-actions/setup-android@v2 - name: Native Cache uses: actions/cache@main with: path: | TMessagesProj/libs TMessagesProj/src/main/libs key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} - name: Check Cache run: | [ -f "TMessagesProj/libs/libv2ray.aar" ] && echo "Cache found." || echo "CONTINUE=true" >> $GITHUB_ENV - name: Install NDK if: env.CONTINUE run: | echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties - name: Install Go uses: actions/setup-go@v2 if: env.CONTINUE with: go-version: ^1.15 - name: Native Build if: env.CONTINUE run: | ./run init action ./run init libs ./run libs update build: name: Release Build runs-on: ubuntu-latest needs: native strategy: matrix: flavor: - FullRelease - FullReleaseNoGcm - FullAppleEmojiRelease - FullAppleEmojiReleaseNoGcm - MiniRelease - MiniReleaseNoGcm - MiniAppleEmojiRelease - MiniAppleEmojiReleaseNoGcm steps: - name: Checkout uses: actions/checkout@v2 - name: Setup Android SDK Tools uses: android-actions/setup-android@v2 - name: Native Cache uses: actions/cache@main with: path: | TMessagesProj/libs TMessagesProj/src/main/libs key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} - name: Fix Gradle Memoery run: | sed -i -e "s/16384/6144/g" gradle.properties echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" > local.properties - name: Gradle cache uses: actions/cache@main with: path: ~/.gradle key: gradle-${{ hashFiles('**/*.gradle') }} - name: Release Build run: | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" ./gradlew TMessagesProj:assemble${{ matrix.flavor }} APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: name: ${{ matrix.flavor }} path: ${{ env.APK }} publish: name: Publish Release if: github.event.inputs.publish != 'y' runs-on: ubuntu-latest needs: build steps: - name: Checkout uses: actions/checkout@v2 - name: Donwload Artifacts uses: actions/download-artifact@v2 with: path: artifacts - name: Release run: | wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz tar -xvf ghr.tar.gz mv ghr*linux_amd64/ghr . mkdir apks find artifacts -name "*.apk" -exec cp {} apks \; ./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks upload: name: Upload Release if: github.event.inputs.upload != 'y' runs-on: ubuntu-latest needs: build steps: - name: Donwload Artifacts uses: actions/download-artifact@v2 with: path: artifacts - name: Release run: | mkdir apks find artifacts -name "*.apk" -exec cp {} apks \; function upload() { for apk in $@; do echo ">> Uploading $apk" curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \ -X POST \ -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ -F document="@$apk" \ --silent --show-error --fail >/dev/null & done for job in $(jobs -p); do wait $job || exit 1 done } upload apks/NekoX-full-*-release.apk upload apks/NekoX-full-*-releaseNoGcm.apk upload apks/NekoX-mini-*-release.apk upload apks/NekoX-mini-*-releaseNoGcm.apk play: name: Publish to Play Store if: github.event.inputs.play != 'y' runs-on: ubuntu-latest needs: native steps: - name: Checkout uses: actions/checkout@v2 - name: Setup Android SDK Tools uses: android-actions/setup-android@v2 - name: Native Cache uses: actions/cache@main with: path: | TMessagesProj/libs TMessagesProj/src/main/libs key: ${{ hashFiles('TMessagesProj/jni/**', 'ss-rust/src/main/rust/**') }} - name: Fix Gradle Memoery run: | sed -i -e "s/16384/6144/g" gradle.properties echo "ndk.dir=${ANDROID_HOME}/ndk-bundle" > local.properties - name: Gradle cache uses: actions/cache@main with: path: ~/.gradle key: gradle-${{ hashFiles('**/*.gradle') }} - name: Publish to Play Store run: | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" cat > service_account_credentials.json << EOF ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}" EOF sed -i -e 's@@@g' TMessagesProj/src/main/AndroidManifest.xml ./gradlew TMessagesProj:publishFullPlayRelease