fix matrix #75
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build APK | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_tag: | ||
required: false | ||
type: string | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
Build libhysteria2: | ||
Check failure on line 14 in .github/workflows/build.yml
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: | ||
- { clang: "aarch64-linux-android21", goarch: "arm64", abi: "arm64-v8a" } | ||
- { clang: "armv7a-linux-androideabi21", goarch: "arm", abi: "armeabi-v7a"} | ||
- { clang: "x86_64-linux-android21", goarch: "amd64", abi: "x86_64" } | ||
- { clang: "i686-linux-android21", goarch: "i386", abi: "x86" } | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Check cache | ||
id: cache-libhysteria2-check | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ${{ github.workspace }}/hysteria/libs | ||
key: libhysteria2-${{ runner.os }}-${{ hashFiles('.git/modules/hysteria/HEAD') }} | ||
- name: Fetch Go version from AndroidLibXrayLite | ||
if: steps.cache-libhysteria2-check.outputs.cache-hit != 'true' | ||
run: | | ||
GO_VERSION=$(curl -sL https://github.com/2dust/AndroidLibXrayLite/raw/refs/heads/main/go.mod | sed -n -E 's/.*go ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p') | ||
echo "Go version: $GO_VERSION" | ||
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV | ||
- name: Setup Golang | ||
if: steps.cache-libhysteria2-check.outputs.cache-hit != 'true' | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '${{ env.GO_VERSION }}' | ||
- name: Setup Android NDK | ||
uses: nttld/setup-ndk@v1 | ||
if: steps.cache-libhysteria2-check.outputs.cache-hit != 'true' | ||
id: setup-ndk | ||
# Same version as https://gitlab.com/fdroid/fdroiddata/metadata/com.v2ray.ang.yml | ||
with: | ||
ndk-version: r27 | ||
add-to-path: true | ||
link-to-sdk: true | ||
local-cache: true | ||
- name: Build libhysteria2 | ||
if: steps.cache-libhysteria2-check.outputs.cache-hit != 'true' | ||
run: | | ||
cd ${{ github.workspace }}/hyseria | ||
go build -v -o libs/$FOLDER/libhysteria2.so -trimpath -ldflags "-s -w -buildid=" ./app | ||
env: | ||
CC: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.target.ndk_target }}-clang | ||
CGO_ENABLED: 1 | ||
CGO_LDFLAGS: "-Wl,-z,max-page-size=16384" | ||
GOOS: android | ||
GOARCH: ${{ matrix.target.arch }} | ||
FOLDER: ${{ matrix.target.abi }} | ||
- name: Save libhysteria2 | ||
if: steps.cache-libtun2socks-check.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ${{ github.workspace }}/hysteria/libs | ||
key: libhysteria2-${{ runner.os }}-${{ hashFiles('.git/modules/hysteria/HEAD') }} | ||
Build v2rayNG: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
- name: Setup Android environment | ||
uses: android-actions/setup-android@v3 | ||
- name: Setup Android NDK | ||
uses: nttld/setup-ndk@v1 | ||
id: setup-ndk | ||
# Same version as https://gitlab.com/fdroid/fdroiddata/metadata/com.v2ray.ang.yml | ||
with: | ||
ndk-version: r27 | ||
add-to-path: true | ||
link-to-sdk: true | ||
local-cache: true | ||
- name: Restore Android Symlinks | ||
run: | | ||
directory="${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin" | ||
find "$directory" -type l | while read link; do | ||
current_target=$(readlink "$link") | ||
new_target="$directory/$(basename "$current_target")" | ||
ln -sf "$new_target" "$link" | ||
echo "Changed $(basename "$link") from $current_target to $new_target" | ||
done | ||
- name: Prepare build dir | ||
run: | | ||
mkdir ${{ github.workspace }}/build | ||
- name: Fetch AndroidLibV2rayLite | ||
run: | | ||
cd ${{ github.workspace }}/build | ||
git clone --depth=1 -b master https://github.com/2dust/AndroidLibV2rayLite.git | ||
cd AndroidLibV2rayLite | ||
git submodule update --init | ||
- name: Restore cached libtun2socks | ||
id: cache-libtun2socks-restore | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ${{ github.workspace }}/build/AndroidLibV2rayLite/libs | ||
key: libtun2socks-${{ runner.os }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/refs/heads/master') }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/modules/badvpn/HEAD') }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/modules/libancillary/HEAD') }} | ||
- name: Build libtun2socks | ||
if: steps.cache-libtun2socks-restore.outputs.cache-hit != 'true' | ||
run: | | ||
cd ${{ github.workspace }}/build/AndroidLibV2rayLite | ||
bash compile-tun2socks.sh | ||
tar -xvzf libtun2socks.so.tgz | ||
env: | ||
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | ||
- name: Save libtun2socks | ||
if: steps.cache-libtun2socks-restore.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ${{ github.workspace }}/build/AndroidLibV2rayLite/libs | ||
key: libtun2socks-${{ runner.os }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/refs/heads/master') }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/modules/badvpn/HEAD') }}-${{ hashFiles('build/AndroidLibV2rayLite/.git/modules/libancillary/HEAD') }} | ||
- name: Copy libtun2socks | ||
run: | | ||
cp -r ${{ github.workspace }}/build/AndroidLibV2rayLite/libs/* ${{ github.workspace }}/V2rayNG/app/libs/ | ||
- name: Restore cached libhysteria2 | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ${{ github.workspace }}/hysteria/libs | ||
key: libhysteria2-${{ runner.os }}-${{ hashFiles('.git/modules/hysteria/HEAD') }} | ||
- name: Copy libhysteria2 | ||
run: | | ||
cp -r ${{ github.workspace }}/hysteria/libs ${{ github.workspace }}/V2rayNG/app | ||
- name: Download libv2ray | ||
uses: robinraju/release-downloader@v1 | ||
with: | ||
repository: '2dust/AndroidLibXrayLite' | ||
latest: true | ||
fileName: 'libv2ray.aar' | ||
out-file-path: V2rayNG/app/libs/ | ||
- name: Build APK | ||
run: | | ||
cd ${{ github.workspace }}/V2rayNG | ||
chmod 755 gradlew | ||
./gradlew licenseFdroidReleaseReport | ||
./gradlew assembleFdroidRelease | ||
env: | ||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | ||
- name: Upload arm64-v8a APK | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ success() }} | ||
with: | ||
name: arm64-v8a | ||
path: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/*/release/*arm64-v8a*.apk | ||
- name: Upload armeabi-v7a APK | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ success() }} | ||
with: | ||
name: armeabi-v7a | ||
path: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/*/release/*armeabi-v7a*.apk | ||
- name: Upload x86 APK | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ success() }} | ||
with: | ||
name: x86-apk | ||
path: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/*/release/*x86*.apk | ||
- name: Upload to release | ||
uses: svenstaro/upload-release-action@v2 | ||
if: github.event.inputs.release_tag != '' | ||
with: | ||
file: ${{ github.workspace }}/V2rayNG/app/build/outputs/apk/*playstore*/release/*.apk | ||
tag: ${{ github.event.inputs.release_tag }} | ||
file_glob: true | ||
prerelease: true |