Build SFA #226
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 SFA | |
on: | |
push: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
TAGS: "with_quic,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api,with_grpc,with_gvisor" | |
steps: | |
- uses: actions/checkout@v4.1.1 | |
with: | |
fetch-depth: 0 | |
- name: Get latest go version | |
id: go_version | |
run: | | |
echo go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') >> $GITHUB_OUTPUT | |
- name: Setup Go | |
uses: actions/setup-go@v4.1.0 | |
with: | |
go-version: 1.21.5 | |
- name: Checkout SFA Repository | |
uses: actions/checkout@v4.1.1 | |
with: | |
repository: SagerNet/sing-box-for-android | |
path: SFA | |
submodules: recursive | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'oracle' | |
java-version: 20 | |
- name: Setup NDK | |
uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: r26b | |
add-to-path: false | |
local-cache: false | |
- name: Build SFA | |
env: | |
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | |
run: | | |
git remote add sekai https://github.com/SagerNet/sing-box | |
git fetch sekai | |
mkdir -p SFA/app/libs/ | |
make lib_install | |
version=$(CGO_ENABLED=0 go run ./cmd/internal/read_tag) | |
CC=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang | |
CGO_ENABLED=0 gomobile bind -v -a -trimpath -androidapi 21 -javapkg=io.nekohasekai -libname=box -tags ${TAGS} -ldflags "-X github.com/sagernet/sing-box/constant.Version=${version} -s -w -buildid=" ./experimental/libbox | |
cp ./libbox.aar SFA/app/libs/ | |
cd SFA | |
echo "" >> gradle.properties | |
echo "org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 -XX:+UseParallelGC" >> gradle.properties | |
echo "org.gradle.caching=true" >> gradle.properties | |
echo "org.gradle.parallel=true" >> gradle.properties | |
echo "VERSION_NAME=${version}" > local.properties | |
echo "VERSION_CODE=$(date +%Y%m%d%H)" >> local.properties | |
sed -i '/signingConfigs\.release/d' app/build.gradle | |
chmod +x ./gradlew | |
./gradlew assembleRelease --debug | |
- name: Sign SFA | |
uses: PuerNya/sign-android-release@v2 | |
with: | |
releaseDirectory: SFA/app/build/outputs/apk/other/release | |
signingKeyBase64: ${{ secrets.SIGN_KEY }} | |
alias: ${{ secrets.ALIAS }} | |
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
- name: Upload arm64-v8a artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: SFA-arm64-v8a | |
path: | | |
SFA/app/build/outputs/apk/other/release/*-arm64-v8a-signed.apk | |
SFA/app/build/outputs/apk/other/release/*-arm64-v8a-*-signed.apk | |
- name: Upload armeabi-v7a artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: SFA-armeabi-v7a | |
path: | | |
SFA/app/build/outputs/apk/other/release/*-armeabi-v7a-signed.apk | |
SFA/app/build/outputs/apk/other/release/*-armeabi-v7a-*-signed.apk | |
- name: Upload x86_64 artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: SFA-x86_64 | |
path: | | |
SFA/app/build/outputs/apk/other/release/*-x86_64-signed.apk | |
SFA/app/build/outputs/apk/other/release/*-x86_64-*-signed.apk | |
- name: Upload x86 artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: SFA-x86 | |
path: | | |
SFA/app/build/outputs/apk/other/release/*-x86-signed.apk | |
SFA/app/build/outputs/apk/other/release/*-x86-*-signed.apk | |
- name: Upload universal artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: SFA-universal | |
path: | | |
SFA/app/build/outputs/apk/other/release/*-universal-signed.apk | |
SFA/app/build/outputs/apk/other/release/*-universal-*-signed.apk |