Multi Builds #304
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 | |
steps: | |
- uses: actions/checkout@v4.1.1 | |
with: | |
fetch-depth: 0 | |
- name: get latest go version | |
id: go | |
run: | | |
echo version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/update-versions-manifest-file/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: ${{steps.go.outputs.version}} | |
- name: checkout app repository | |
uses: actions/checkout@v4.1.1 | |
with: | |
path: sfa | |
repository: SagerNet/sing-box-for-android | |
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 | |
- name: get latest build tools version | |
id: sdk | |
run: echo version=$(ls $ANDROID_HOME/build-tools | tail -n 1) >> $GITHUB_OUTPUT | |
- name: get sing-box version | |
id: sing-box | |
run: | | |
git remote add sekai https://github.com/SagerNet/sing-box | |
git fetch --tags sekai | |
version=$(CGO_ENABLED=0 go run ./cmd/internal/read_tag) | |
echo version=$version >> $GITHUB_OUTPUT | |
- name: build libbox | |
env: | |
CC: ${{steps.setup-ndk.outputs.ndk-path}}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang | |
TAGS: with_quic,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_clash_api,with_gvisor | |
VERSION: ${{steps.sing-box.outputs.version}} | |
CGO_ENABLED: '0' | |
run: | | |
make lib_install | |
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 | |
- name: setup build env && build app | |
env: | |
VERSION: ${{steps.sing-box.outputs.version}} | |
KEYSTORE: ${{secrets.SIGN_KEY}} | |
ALIAS_NAME: ${{secrets.ALIAS}} | |
KEYSTORE_PASS: ${{secrets.SIGN_KEY}} | |
run: | | |
mkdir -p sfa/app/libs/ | |
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 app | |
uses: PuerNya/sign-android-release@v2.0.4 | |
env: | |
BUILD_TOOLS_VERSION: ${{steps.sdk.outputs.version}} | |
with: | |
alias: ${{secrets.ALIAS}} | |
releaseDirectory: sfa/app/build/outputs/apk/other/release | |
signingKeyBase64: ${{secrets.SIGN_KEY}} | |
keyStorePassword: ${{secrets.KEY_STORE_PASSWORD}} | |
- name: upload arm64-v8a apk | |
uses: actions/upload-artifact@v4.1.0 | |
env: | |
version: ${{steps.sing-box.outputs.version}} | |
with: | |
name: sfa-${{env.version}}-arm64-v8a | |
path: sfa/app/build/outputs/apk/other/release/*-arm64-v8a-signed.apk | |
compression-level: 9 | |
- name: upload armeabi-v7a apk | |
uses: actions/upload-artifact@v4.1.0 | |
env: | |
version: ${{steps.sing-box.outputs.version}} | |
with: | |
name: sfa-${{env.version}}-armeabi-v7a | |
path: sfa/app/build/outputs/apk/other/release/*-armeabi-v7a-signed.apk | |
compression-level: 9 | |
- name: upload x86_64 apk | |
uses: actions/upload-artifact@v4.1.0 | |
env: | |
version: ${{steps.sing-box.outputs.version}} | |
with: | |
name: sfa-${{env.version}}-x86_64 | |
path: sfa/app/build/outputs/apk/other/release/*-x86_64-signed.apk | |
compression-level: 9 | |
- name: upload x86 apk | |
uses: actions/upload-artifact@v4.1.0 | |
env: | |
version: ${{steps.sing-box.outputs.version}} | |
with: | |
name: sfa-${{env.version}}-x86 | |
path: sfa/app/build/outputs/apk/other/release/*-x86-signed.apk | |
compression-level: 9 | |
- name: upload universal apk | |
uses: actions/upload-artifact@v4.1.0 | |
env: | |
version: ${{steps.sing-box.outputs.version}} | |
with: | |
name: sfa-${{env.version}}-universal | |
path: sfa/app/build/outputs/apk/other/release/*-universal-signed.apk | |
compression-level: 9 |