multi builds #388
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/[email protected] | |
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/[email protected] | |
with: | |
go-version: ${{steps.go.outputs.version}} | |
- name: checkout app repository | |
uses: actions/[email protected] | |
with: | |
path: sfa | |
repository: SagerNet/sing-box-for-android | |
submodules: recursive | |
- name: setup java | |
uses: actions/[email protected] | |
with: | |
distribution: 'oracle' | |
java-version: 21 | |
- 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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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 |