forked from SagerNet/sing-box-for-android
-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (164 loc) · 6.66 KB
/
SFA- PuerNya.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Build SFA PuerNya
on:
workflow_dispatch: # 只保留手动触发选项
#schedule:
#- cron: '0 22,12 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sing-box repository
uses: actions/[email protected]
with:
path: sing-box
repository: PuerNya/sing-box
ref: building
fetch-depth: 0
- uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('sing-box/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup latest stable Go
uses: actions/[email protected]
with:
go-version: 'stable'
- name: Get latest commit message
id: get_commit_message
run: |
cd sing-box
echo "commit_message=$(git log -1 --pretty=%B)" >> $GITHUB_OUTPUT
- name: Setup Java
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '22'
- name: Setup ndk
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26b
add-to-path: false
- 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
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'
GOMAXPROCS: 4
run: |
cd sing-box
go mod tidy
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=" -gcflags=all="-l -B" ./experimental/libbox
- name: Checkout app repository
uses: actions/[email protected]
with:
path: sfa
repository: LQ2002/sing-box-for-android
submodules: recursive
- name: Setup Android SDK and Gradle/caches
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 'latest'
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Install latest necessary SDK components
run: |
BUILD_TOOLS_VERSION=$(sdkmanager --list | grep "build-tools;" | sort -rV | head -n 1 | awk '{print $1}')
PLATFORM_VERSION=$(sdkmanager --list | grep "platforms;android-" | sort -rV | head -n 1 | awk '{print $1}')
sdkmanager --install "${BUILD_TOOLS_VERSION}" "${PLATFORM_VERSION}" "platform-tools"
shell: bash
- name: Debug Keystore
run: |
ls -l sfa/app/
file sfa/app/release.keystore
echo "KEYSTORE_PASSWORD length: ${#KEYSTORE_PASSWORD}"
echo "KEY_ALIAS length: ${#KEY_ALIAS}"
echo "KEY_PASSWORD length: ${#KEY_PASSWORD}"
- name: Setup build env && build app
env:
VERSION: ${{steps.sing-box.outputs.version}}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
mkdir -p sfa/app/libs/
cp ./sing-box/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
chmod +x ./gradlew
./gradlew assembleRelease --parallel --daemon --max-workers=4 \
-Dorg.gradle.caching=true \
-Dorg.gradle.configureondemand=true \
-Dkotlin.incremental=false \
-Dkotlin.compiler.execution.strategy=in-process \
-Pandroid.injected.signing.store.file=$PWD/app/release.keystore \
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
-Pandroid.injected.signing.key.alias=$KEY_ALIAS \
-Pandroid.injected.signing.key.password=$KEY_PASSWORD \
-Pandroid.injected.signing.v1-signing-enabled=true \
-Pandroid.injected.signing.v2-signing-enabled=true \
-Pandroid.injected.signing.v3-signing-enabled=true \
-Pandroid.injected.signing.v4-signing-enabled=true
- name: List build output directory
run: |
echo "Listing APK files in build output directory:"
find sfa/app/build/outputs -name "*.apk"
- name: Verify APK signatures
run: |
APKSIGNER="$ANDROID_HOME/build-tools/$(ls $ANDROID_HOME/build-tools | sort -V | tail -n 1)/apksigner"
for apk in sfa/app/build/outputs/apk/other/release/*.apk; do
"$APKSIGNER" verify --verbose "$apk"
done
for apk in sfa/app/build/outputs/apk/play/release/*.apk; do
"$APKSIGNER" verify --verbose "$apk"
done
shell: bash
- name: Upload APKs
uses: actions/[email protected]
env:
version: ${{steps.sing-box.outputs.version}}
with:
name: SFA-PuerNya-${{env.version}}
path: sfa/app/build/outputs/apk/**/*.apk
compression-level: 9
#- name: 创建发布标签
#run: |
#echo "RELEASE_TAG=v${{steps.sing-box.outputs.version}}" >> $GITHUB_ENV
#- name: 创建发布
#uses: softprops/action-gh-release@v2
#env:
#GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#with:
#tag_name: ${{ env.RELEASE_TAG }}
#name: Release ${{ env.RELEASE_TAG }}
#body: ${{ steps.get_commit_message.outputs.commit_message }}
#draft: false
#prerelease: false
#files: |
#sfa/app/build/outputs/apk/other/release/*.apk