Skip to content

Commit 021f700

Browse files
authored
Update build.yml
1 parent e55592c commit 021f700

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,43 @@ on:
55

66
jobs:
77
build:
8-
runs-on: self-hosted
9-
env:
10-
ANDROID_NDK_ZIP: android-ndk-r28c-linux.zip
11-
ANDROID_NDK_DIR: android-ndk-r28c
12-
# go install will put the binary here
13-
GOBIN: ${{ github.workspace }}/out
8+
runs-on: ubuntu-latest
149

1510
steps:
1611
- uses: actions/checkout@v4
1712

18-
# - name: Set up Go
19-
# uses: actions/setup-go@v5
20-
# with:
21-
# go-version: '1.22.x'
13+
- name: Set up Go
14+
uses: actions/setup-go@v5
15+
with:
16+
go-version: '1.22.x'
2217

23-
# - name: Get Android NDK
24-
# run: |
25-
# wget https://dl.google.com/android/repository/${ANDROID_NDK_ZIP}
26-
# unzip -q ${ANDROID_NDK_ZIP}
18+
- name: Download Android NDK (r28c)
19+
run: |
20+
# wget -q https://dl.google.com/android/repository/android-ndk-r28c-linux.zip
21+
# unzip -q android-ndk-r28c-linux.zip
22+
echo "ANDROID_NDK=$PWD/android-ndk-r28c" >> $GITHUB_ENV
2723
28-
- name: Build Kopia (Android/arm64, CGO, netcgo)
24+
- name: Build Kopia (Android/arm64, CGO, netcgo) via go install
2925
env:
3026
ANDROID_NDK: ${{ env.ANDROID_NDK }}
3127
run: |
28+
# Android/arm64 cross-compile with CGO and cgo DNS resolver
3229
export CC="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
3330
export CXX="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++"
34-
export GOOS=android GOARCH=arm64 CGO_ENABLED=1
35-
# crucial: GOBIN must be unset for cross installs
31+
export GOOS=android
32+
export GOARCH=arm64
33+
export CGO_ENABLED=1
34+
35+
# IMPORTANT: GOBIN must be unset for cross-installs
36+
# go install will place the binary under: $(go env GOPATH)/bin/${GOOS}_${GOARCH}/kopia
3637
env -u GOBIN go install -tags netcgo github.com/kopia/[email protected]
38+
39+
# Collect the cross-compiled binary
40+
TARGET_BIN_DIR="$(go env GOPATH)/bin/${GOOS}_${GOARCH}"
41+
ls -l "$TARGET_BIN_DIR"
3742
mkdir -p out
38-
cp "$(go env GOPATH)/bin/kopia" out/kopia
43+
cp "$TARGET_BIN_DIR/kopia" out/kopia
44+
file out/kopia
3945
4046
- name: Upload Android binary
4147
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)