dev preview build

This commit is contained in:
armv9 2025-09-02 18:02:03 +09:00
parent a04f535811
commit 7736548e4f
7 changed files with 83 additions and 4 deletions

69
.github/workflows/preview.yml vendored Normal file
View File

@ -0,0 +1,69 @@
name: Preview Build
on:
workflow_dispatch:
inputs:
jobs:
libcore:
name: Native Build (LibCore)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Golang Status
run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status
- name: Libcore Status
run: git ls-files libcore | xargs cat | sha1sum > libcore_status
- name: LibCore Cache
id: cache
uses: actions/cache@v4
with:
path: |
app/libs/libcore.aar
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}
- name: Install Golang
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version: ^1.24
- name: Native Build
if: steps.cache.outputs.cache-hit != 'true'
run: ./run lib core
build:
name: Build OSS APK
runs-on: ubuntu-latest
needs:
- libcore
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Golang Status
run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status
- name: Libcore Status
run: git ls-files libcore | xargs cat | sha1sum > libcore_status
- name: LibCore Cache
uses: actions/cache@v4
with:
path: |
app/libs/libcore.aar
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}
- name: Gradle cache
uses: actions/cache@v4
with:
path: ~/.gradle
key: gradle-oss-${{ hashFiles('**/*.gradle.kts') }}
- name: Gradle Build
env:
BUILD_PLUGIN: none
run: |
echo "sdk.dir=${ANDROID_HOME}" > local.properties
echo "ndk.dir=${ANDROID_HOME}/ndk/25.0.8775105" >> local.properties
export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
./run init action gradle
./gradlew app:assemblePreviewRelease
APK=$(find app/build/outputs/apk -name '*arm64-v8a*.apk')
APK=$(dirname $APK)
echo "APK=$APK" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: APKs
path: ${{ env.APK }}

View File

@ -271,11 +271,9 @@ fun Context.getColorAttr(@AttrRes resId: Int): Int {
}
val isExpert: Boolean by lazy { BuildConfig.DEBUG || DataStore.isExpert }
val isExpertFlavor = ((BuildConfig.FLAVOR == "expert") || BuildConfig.DEBUG)
const val isOss = BuildConfig.FLAVOR == "oss"
const val isFdroid = BuildConfig.FLAVOR == "fdroid"
const val isPlay = BuildConfig.FLAVOR == "play"
const val isPreview = BuildConfig.FLAVOR == "preview"
fun <T> Continuation<T>.tryResume(value: T) {
try {

View File

@ -41,6 +41,7 @@ import io.nekohasekai.sagernet.group.GroupInterfaceAdapter
import io.nekohasekai.sagernet.group.GroupUpdater
import io.nekohasekai.sagernet.ktx.alert
import io.nekohasekai.sagernet.ktx.isPlay
import io.nekohasekai.sagernet.ktx.isPreview
import io.nekohasekai.sagernet.ktx.launchCustomTab
import io.nekohasekai.sagernet.ktx.onMainDispatcher
import io.nekohasekai.sagernet.ktx.parseProxies
@ -114,6 +115,13 @@ class MainActivity : ThemedActivity(),
)
}
}
if (isPreview) {
MaterialAlertDialogBuilder(this).setTitle(R.string.preview_version)
.setMessage(R.string.preview_version_hint)
.setPositiveButton(android.R.string.ok, null)
.show()
}
}
fun refreshNavMenu(clashApi: Boolean) {

View File

@ -20,7 +20,6 @@ import androidx.preference.PreferenceViewHolder
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import io.nekohasekai.sagernet.R
import io.nekohasekai.sagernet.ktx.getColorAttr
import io.nekohasekai.sagernet.ktx.isExpertFlavor
import kotlin.math.roundToInt
class ColorPickerPreference

View File

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

View File

@ -566,4 +566,6 @@
<string name="padding">Padding</string>
<string name="network_change_reset_connections">Reset outbound connections when network changes</string>
<string name="wake_reset_connections">Reset outbound connections when device wake from sleep</string>
<string name="preview_version">Preview version</string>
<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>
</resources>

View File

@ -209,6 +209,7 @@ fun Project.setupApp() {
create("oss")
create("fdroid")
create("play")
create("preview")
}
applicationVariants.all {