Skip to content

Commit

Permalink
fix matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
UjuiUjuMandan committed Jan 3, 2025
1 parent 70ff901 commit a16fbfb
Showing 1 changed file with 66 additions and 35 deletions.
101 changes: 66 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,71 @@ on:
- master

jobs:
build:
Build libhysteria2:
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:
Expand Down Expand Up @@ -86,47 +150,14 @@ jobs:
cp -r ${{ github.workspace }}/build/AndroidLibV2rayLite/libs/* ${{ github.workspace }}/V2rayNG/app/libs/
- name: Restore cached libhysteria2
id: cache-libhysteria2-restore
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/hysteria/libs
key: libhysteria2-${{ runner.os }}-${{ hashFiles('.git/modules/hysteria/HEAD') }}

- name: Fetch AndroidLibXrayLite
if: steps.cache-libhysteria2-restore.outputs.cache-hit != 'true'
run: |
cd ${{ github.workspace }}/build
git clone --depth=1 -b master https://github.com/2dust/AndroidLibV2rayLite.git
- name: Setup Golang
if: steps.cache-libhysteria2-restore.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version-file: '${{ github.workspace }}/build/AndroidLibXrayLite/go.mod'

- name: Build libhysteria2
if: steps.cache-libhysteria2-restore.outputs.cache-hit != 'true'
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" }
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: Copy libhysteria2
run: |
cp -r ${{ github.workspace }}/hysteria/libs/* ${{ github.workspace }}/V2rayNG/app/libs/
cp -r ${{ github.workspace }}/hysteria/libs ${{ github.workspace }}/V2rayNG/app
- name: Download libv2ray
uses: robinraju/release-downloader@v1
Expand Down

0 comments on commit a16fbfb

Please sign in to comment.