diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3be5de3..a87c034 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -30,16 +30,19 @@ jobs: uses: android-actions/setup-android@v3 - name: Set up NDK + id: setup_ndk uses: nttld/setup-ndk@v1 with: ndk-version: r26d - link-to-sdk: true + add-to-path: false - name: Compile Go libs run: | pushd 'app/src' ./build.sh popd + env: + ANDROID_NDK_HOME: ${{ steps.setup_ndk.outputs.ndk-path }} - name: Build with Gradle run: ./gradlew --no-daemon assembleRelease @@ -55,6 +58,12 @@ jobs: env: BUILD_TOOLS_VERSION: "34.0.0" + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: Signed app bundle + path: ${{steps.sign_app.outputs.signedReleaseFile}} + - name: Attest APK uses: actions/attest-build-provenance@v1 with: diff --git a/app/build.gradle b/app/build.gradle index 248183f..25eb7a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,6 @@ apply plugin: 'kotlin-android-extensions' android { compileSdk 34 buildToolsVersion "34.0.0" - ndkVersion "21.3.6528147" defaultConfig { applicationId "com.github.shadowsocks.plugin.ck_client" minSdkVersion 21 @@ -42,15 +41,3 @@ dependencies { androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } - -task printVersionName { - doLast { - println android.defaultConfig.versionName - } -} - -task printNDKPath { - doLast { - println android.sdkComponents.ndkDirectory.get() - } -} diff --git a/app/src/build.sh b/app/src/build.sh index 56bf805..2f3542b 100755 --- a/app/src/build.sh +++ b/app/src/build.sh @@ -53,14 +53,10 @@ function getHostTag() { #This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. #You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. -pushd ../.. -ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-$(./gradlew -q printNDKPath)}" -popd - -while [ ! -d "$ANDROID_NDK_HOME" ]; do - echo "Path to ndk-bundle not found" +if [ ! -d "$ANDROID_NDK_HOME" ]; then + echo "Path to NDK not found" exit -1 -done +fi getHostTag MIN_API=21 @@ -82,19 +78,19 @@ go get ./... cd cmd/ck-client echo "Cross compiling ckclient for arm" -env CGO_ENABLED=1 CC="$ANDROID_ARM_CC" GOOS=android GOARCH=arm GOARM=7 go build -ldflags="-s -w" +env CGO_ENABLED=1 CC="$ANDROID_ARM_CC" GOOS=android GOARCH=arm GOARM=7 go build -trimpath -ldflags="-s -w -buildid=" mv ck-client "$SRC_DIR/main/jniLibs/armeabi-v7a/libck-client.so" echo "Cross compiling ckclient for arm64" -env CGO_ENABLED=1 CC="$ANDROID_ARM64_CC" GOOS=android GOARCH=arm64 go build -ldflags="-s -w" +env CGO_ENABLED=1 CC="$ANDROID_ARM64_CC" GOOS=android GOARCH=arm64 go build -trimpath -ldflags="-s -w -buildid=" mv ck-client "$SRC_DIR/main/jniLibs/arm64-v8a/libck-client.so" echo "Cross compiling ckclient for x86" -env CGO_ENABLED=1 CC="$ANDROID_X86_CC" GOOS=android GOARCH=386 go build -ldflags="-s -w" +env CGO_ENABLED=1 CC="$ANDROID_X86_CC" GOOS=android GOARCH=386 go build -trimpath -ldflags="-s -w -buildid=" mv ck-client "$SRC_DIR/main/jniLibs/x86/libck-client.so" echo "Cross compiling ckclient for x86_64" -env CGO_ENABLED=1 CC="$ANDROID_X86_64_CC" GOOS=android GOARCH=amd64 go build -ldflags="-s -w" +env CGO_ENABLED=1 CC="$ANDROID_X86_64_CC" GOOS=android GOARCH=amd64 go build -trimpath -ldflags="-s -w -buildid=" mv ck-client "$SRC_DIR/main/jniLibs/x86_64/libck-client.so" echo "Success"