From e4fa0cc979f2c2a6b674de7d39f938431f67e05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 26 Jun 2022 19:52:01 +0800 Subject: [PATCH] Update plugin build action --- .github/workflows/debug.yml | 104 ++++++++++---- .github/workflows/release_mieru.yml | 198 +++++++++++++++++++++++++++ .github/workflows/release_tuic.yml | 202 ++++++++++++++++++++++++++++ bin/fdroid/prebuild.sh | 2 +- bin/init/action/rust.sh | 3 + 5 files changed, 483 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/release_mieru.yml create mode 100644 .github/workflows/release_tuic.yml create mode 100755 bin/init/action/rust.sh diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 7bf15cc4..f4c1e882 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -111,31 +111,31 @@ jobs: with: name: "NAIVE-SHA256-${{ matrix.arch }} ${{ env.SHA256SUM }}" path: sha256sum.txt -# pingtunnel: -# name: Native Build (PingTunnel) -# runs-on: ubuntu-latest -# needs: -# - setup -# steps: -# - name: Checkout -# uses: actions/checkout@v2 -# - name: Fetch Status -# run: git submodule status 'plugin/pingtunnel/*' > pt_status -# - name: PingTunnel Cache -# id: cache -# uses: actions/cache@v2 -# with: -# path: | -# plugin/pingtunnel/src/main/jniLibs -# key: ${{ hashFiles('.github/workflows/*', 'bin/lib/pingtunnel/*', 'pt_status') }} -# - name: Install Golang -# uses: actions/setup-go@v2 -# if: steps.cache.outputs.cache-hit != 'true' -# with: -# go-version: 1.16 -# - name: Native Build -# if: steps.cache.outputs.cache-hit != 'true' -# run: ./run plugin pingtunnel + # pingtunnel: + # name: Native Build (PingTunnel) + # runs-on: ubuntu-latest + # needs: + # - setup + # steps: + # - name: Checkout + # uses: actions/checkout@v2 + # - name: Fetch Status + # run: git submodule status 'plugin/pingtunnel/*' > pt_status + # - name: PingTunnel Cache + # id: cache + # uses: actions/cache@v2 + # with: + # path: | + # plugin/pingtunnel/src/main/jniLibs + # key: ${{ hashFiles('.github/workflows/*', 'bin/lib/pingtunnel/*', 'pt_status') }} + # - name: Install Golang + # uses: actions/setup-go@v2 + # if: steps.cache.outputs.cache-hit != 'true' + # with: + # go-version: 1.16 + # - name: Native Build + # if: steps.cache.outputs.cache-hit != 'true' + # run: ./run plugin pingtunnel relaybaton: name: Native Build (RelayBaton) runs-on: ubuntu-latest @@ -211,6 +211,60 @@ jobs: - name: Native Build if: steps.cache.outputs.cache-hit != 'true' run: ./run plugin hysteria + mieru: + name: Native Build (Mieru) + runs-on: ubuntu-latest + needs: + - setup + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/mieru/*' > mieru_status + - name: Mieru Cache + id: cache + uses: actions/cache@v2 + with: + path: | + plugin/mieru/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/mieru/*', 'mieru_status') }} + - name: Install Golang + uses: actions/setup-go@v2 + if: steps.cache.outputs.cache-hit != 'true' + with: + go-version: 1.18.3 + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run plugin mieru + tuic: + name: Native Build (TUIC) + runs-on: ubuntu-latest + needs: + - setup + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/tuic/*' > tuic_status + - name: Tuic Cache + id: cache + uses: actions/cache@v2 + with: + path: | + plugin/tuic/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/tuic/*', 'tuic_status') }} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + if: steps.cache.outputs.cache-hit != 'true' + - name: Install rust android target + run: ./run init action rust + if: steps.cache.outputs.cache-hit != 'true' + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run plugin tuic lint: name: Android Lint runs-on: ubuntu-latest diff --git a/.github/workflows/release_mieru.yml b/.github/workflows/release_mieru.yml new file mode 100644 index 00000000..c3e57792 --- /dev/null +++ b/.github/workflows/release_mieru.yml @@ -0,0 +1,198 @@ +name: Mieru Plugin Release Build +on: + workflow_dispatch: + inputs: + tag: + description: 'Release Tag' + required: true + upload: + description: 'Upload: If want ignore' + required: false + publish: + description: 'Publish: If want ignore' + required: false + play: + description: 'Play: 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 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/mieru/*' > mieru_status + - name: Mieru Cache + id: cache + uses: actions/cache@v2 + with: + path: | + plugin/mieru/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/mieru/*', 'mieru_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle.kts') }} + - name: Install Golang + uses: actions/setup-go@v2 + if: steps.cache.outputs.cache-hit != 'true' + with: + go-version: 1.18.3 + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run plugin mieru + build: + name: Gradle Build + runs-on: ubuntu-latest + needs: + - native + - check + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/mieru/*' > mieru_status + - name: Mieru Cache + uses: actions/cache@v2 + with: + path: | + plugin/mieru/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/mieru/*', 'mieru_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle.kts') }} + - name: Release Build + env: + SKIP_BUILD: on + BUILD_PLUGIN: mieru + run: | + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/23.1.7779620" >> local.properties + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" + ./run init action library + ./gradlew :plugin:mieru:assembleOssRelease + APK=$(find plugin/mieru/build/outputs/apk -name '*arm64-v8a*.apk') + APK=$(dirname $APK) + echo "APK=$APK" >> $GITHUB_ENV + - uses: actions/upload-artifact@v2 + with: + name: APKs + path: ${{ env.APK }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-ARM ${{ env.SHA256_ARM }}" + path: ${{ env.SUM_ARM }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-ARM64 ${{ env.SHA256_ARM64 }}" + path: ${{ env.SUM_ARM64 }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-X64 ${{ env.SHA256_X64 }}" + path: ${{ env.SUM_X64 }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-X86 ${{ env.SHA256_X86 }}" + path: ${{ env.SUM_X86 }} + 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: + name: APKs + 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 \; + find artifacts -name "*.sha256sum.txt" -exec cp {} apks \; + ./ghr -delete -prerelease -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: + name: APKs + 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/* + play: + name: Publish to Play Store + if: github.event.inputs.play != 'y' + runs-on: ubuntu-latest + needs: + - native + - check + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/mieru/*' > mieru_status + - name: Hysteria Cache + uses: actions/cache@v2 + with: + path: | + plugin/mieru/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/mieru/*', 'mieru_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle.kts') }} + - name: Release Build + env: + SKIP_BUILD: on + BUILD_PLUGIN: mieru + run: | + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/23.1.7779620" >> local.properties + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" + cat > service_account_credentials.json << EOF + ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}" + EOF + ./run init action library + ./gradlew :plugin:mieru:publishPlayReleaseBundle \ No newline at end of file diff --git a/.github/workflows/release_tuic.yml b/.github/workflows/release_tuic.yml new file mode 100644 index 00000000..84827c13 --- /dev/null +++ b/.github/workflows/release_tuic.yml @@ -0,0 +1,202 @@ +name: TUIC Plugin Release Build +on: + workflow_dispatch: + inputs: + tag: + description: 'Release Tag' + required: true + upload: + description: 'Upload: If want ignore' + required: false + publish: + description: 'Publish: If want ignore' + required: false + play: + description: 'Play: 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 + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/tuic/*' > tuic_status + - name: TUIC Cache + id: cache + uses: actions/cache@v2 + with: + path: | + plugin/tuic/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/tuic/*', 'tuic_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle.kts') }} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + if: steps.cache.outputs.cache-hit != 'true' + - name: Install rust android target + run: ./run init action rust + if: steps.cache.outputs.cache-hit != 'true' + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run plugin tuic + build: + name: Gradle Build + runs-on: ubuntu-latest + needs: + - native + - check + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/tuic/*' > tuic_status + - name: TUIC Cache + uses: actions/cache@v2 + with: + path: | + plugin/tuic/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/tuic/*', 'tuic_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle.kts') }} + - name: Release Build + env: + SKIP_BUILD: on + BUILD_PLUGIN: tuic + run: | + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/23.1.7779620" >> local.properties + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" + ./run init action library + ./gradlew :plugin:tuic:assembleOssRelease + APK=$(find plugin/tuic/build/outputs/apk -name '*arm64-v8a*.apk') + APK=$(dirname $APK) + echo "APK=$APK" >> $GITHUB_ENV + - uses: actions/upload-artifact@v2 + with: + name: APKs + path: ${{ env.APK }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-ARM ${{ env.SHA256_ARM }}" + path: ${{ env.SUM_ARM }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-ARM64 ${{ env.SHA256_ARM64 }}" + path: ${{ env.SUM_ARM64 }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-X64 ${{ env.SHA256_X64 }}" + path: ${{ env.SUM_X64 }} + - uses: actions/upload-artifact@v2 + with: + name: "SHA256-X86 ${{ env.SHA256_X86 }}" + path: ${{ env.SUM_X86 }} + 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: + name: APKs + 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 \; + find artifacts -name "*.sha256sum.txt" -exec cp {} apks \; + ./ghr -delete -prerelease -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: + name: APKs + 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/* + play: + name: Publish to Play Store + if: github.event.inputs.play != 'y' + runs-on: ubuntu-latest + needs: + - native + - check + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/tuic/*' > tuic_status + - name: Hysteria Cache + uses: actions/cache@v2 + with: + path: | + plugin/tuic/src/main/jniLibs + key: ${{ hashFiles('.github/workflows/*', 'bin/lib/tuic/*', 'tuic_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle.kts') }} + - name: Release Build + env: + SKIP_BUILD: on + BUILD_PLUGIN: tuic + run: | + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/23.1.7779620" >> local.properties + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" + cat > service_account_credentials.json << EOF + ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}" + EOF + ./run init action library + ./gradlew :plugin:tuic:publishPlayReleaseBundle \ No newline at end of file diff --git a/bin/fdroid/prebuild.sh b/bin/fdroid/prebuild.sh index b143fb82..ce0cf5dd 100755 --- a/bin/fdroid/prebuild.sh +++ b/bin/fdroid/prebuild.sh @@ -5,7 +5,7 @@ source "bin/init/env.sh" git submodule update --init 'external/*' git submodule update --init 'library/*' -bin/fdroid/install_golang.sh 1.18.2 +bin/fdroid/install_golang.sh 1.18.3 echo "sdk.dir=$ANDROID_HOME" >>local.properties echo "ndk.dir=$ANDROID_NDK_HOME" >>local.properties diff --git a/bin/init/action/rust.sh b/bin/init/action/rust.sh new file mode 100755 index 00000000..d6c20f08 --- /dev/null +++ b/bin/init/action/rust.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +rustup target add armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android