Skip to content

Commit

Permalink
Improve reproducibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeuw committed Jul 7, 2024
1 parent 097ffcf commit 187b377
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
13 changes: 0 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
18 changes: 7 additions & 11 deletions app/src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

0 comments on commit 187b377

Please sign in to comment.