Skip to content

Commit 7736548

Browse files
committed
dev preview build
1 parent a04f535 commit 7736548

7 files changed

Lines changed: 83 additions & 4 deletions

File tree

.github/workflows/preview.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Preview Build
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
jobs:
6+
libcore:
7+
name: Native Build (LibCore)
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
- name: Golang Status
13+
run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status
14+
- name: Libcore Status
15+
run: git ls-files libcore | xargs cat | sha1sum > libcore_status
16+
- name: LibCore Cache
17+
id: cache
18+
uses: actions/cache@v4
19+
with:
20+
path: |
21+
app/libs/libcore.aar
22+
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}
23+
- name: Install Golang
24+
if: steps.cache.outputs.cache-hit != 'true'
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: ^1.24
28+
- name: Native Build
29+
if: steps.cache.outputs.cache-hit != 'true'
30+
run: ./run lib core
31+
build:
32+
name: Build OSS APK
33+
runs-on: ubuntu-latest
34+
needs:
35+
- libcore
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
- name: Golang Status
40+
run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status
41+
- name: Libcore Status
42+
run: git ls-files libcore | xargs cat | sha1sum > libcore_status
43+
- name: LibCore Cache
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
app/libs/libcore.aar
48+
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}
49+
- name: Gradle cache
50+
uses: actions/cache@v4
51+
with:
52+
path: ~/.gradle
53+
key: gradle-oss-${{ hashFiles('**/*.gradle.kts') }}
54+
- name: Gradle Build
55+
env:
56+
BUILD_PLUGIN: none
57+
run: |
58+
echo "sdk.dir=${ANDROID_HOME}" > local.properties
59+
echo "ndk.dir=${ANDROID_HOME}/ndk/25.0.8775105" >> local.properties
60+
export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
61+
./run init action gradle
62+
./gradlew app:assemblePreviewRelease
63+
APK=$(find app/build/outputs/apk -name '*arm64-v8a*.apk')
64+
APK=$(dirname $APK)
65+
echo "APK=$APK" >> $GITHUB_ENV
66+
- uses: actions/upload-artifact@v4
67+
with:
68+
name: APKs
69+
path: ${{ env.APK }}

app/src/main/java/io/nekohasekai/sagernet/ktx/Utils.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,9 @@ fun Context.getColorAttr(@AttrRes resId: Int): Int {
271271
}
272272

273273
val isExpert: Boolean by lazy { BuildConfig.DEBUG || DataStore.isExpert }
274-
275-
val isExpertFlavor = ((BuildConfig.FLAVOR == "expert") || BuildConfig.DEBUG)
276274
const val isOss = BuildConfig.FLAVOR == "oss"
277-
const val isFdroid = BuildConfig.FLAVOR == "fdroid"
278275
const val isPlay = BuildConfig.FLAVOR == "play"
276+
const val isPreview = BuildConfig.FLAVOR == "preview"
279277

280278
fun <T> Continuation<T>.tryResume(value: T) {
281279
try {

app/src/main/java/io/nekohasekai/sagernet/ui/MainActivity.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import io.nekohasekai.sagernet.group.GroupInterfaceAdapter
4141
import io.nekohasekai.sagernet.group.GroupUpdater
4242
import io.nekohasekai.sagernet.ktx.alert
4343
import io.nekohasekai.sagernet.ktx.isPlay
44+
import io.nekohasekai.sagernet.ktx.isPreview
4445
import io.nekohasekai.sagernet.ktx.launchCustomTab
4546
import io.nekohasekai.sagernet.ktx.onMainDispatcher
4647
import io.nekohasekai.sagernet.ktx.parseProxies
@@ -114,6 +115,13 @@ class MainActivity : ThemedActivity(),
114115
)
115116
}
116117
}
118+
119+
if (isPreview) {
120+
MaterialAlertDialogBuilder(this).setTitle(R.string.preview_version)
121+
.setMessage(R.string.preview_version_hint)
122+
.setPositiveButton(android.R.string.ok, null)
123+
.show()
124+
}
117125
}
118126

119127
fun refreshNavMenu(clashApi: Boolean) {

app/src/main/java/moe/matsuri/nb4a/ui/ColorPickerPreference.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import androidx.preference.PreferenceViewHolder
2020
import com.google.android.material.dialog.MaterialAlertDialogBuilder
2121
import io.nekohasekai.sagernet.R
2222
import io.nekohasekai.sagernet.ktx.getColorAttr
23-
import io.nekohasekai.sagernet.ktx.isExpertFlavor
2423
import kotlin.math.roundToInt
2524

2625
class ColorPickerPreference

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,4 +486,6 @@
486486
<string name="global_allow_insecure">总是跳过 TLS 证书验证</string>
487487
<string name="network_change_reset_connections">当网络发生变化时重置出站连接</string>
488488
<string name="wake_reset_connections">当设备从睡眠状态唤醒时重置出站连接</string>
489+
<string name="preview_version">预览版</string>
490+
<string name="preview_version_hint">本应用为预览版,可能存在诸多问题。若您不愿参与测试,请前往GitHub下载正式发布版本!</string>
489491
</resources>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,4 +566,6 @@
566566
<string name="padding">Padding</string>
567567
<string name="network_change_reset_connections">Reset outbound connections when network changes</string>
568568
<string name="wake_reset_connections">Reset outbound connections when device wake from sleep</string>
569+
<string name="preview_version">Preview version</string>
570+
<string name="preview_version_hint">This application is a preview version and may contain many problems. If you do not want to test it, please go to GitHub to download the Release version!</string>
569571
</resources>

buildSrc/src/main/kotlin/Helpers.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ fun Project.setupApp() {
209209
create("oss")
210210
create("fdroid")
211211
create("play")
212+
create("preview")
212213
}
213214

214215
applicationVariants.all {

0 commit comments

Comments
 (0)