mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-02 08:27:14 +00:00
feat(update): add rolling dev update channel for per-commit builds
Adds an opt-in Dev channel so panels running CI per-commit builds can self-update to the latest commit, mirroring the stable online-update flow. CI publishes/overwrites a single fixed-tag pre-release (dev-latest), force-moved to the newest main commit and marked --latest=false so releases/latest stays the stable tag. Builds stamp the short commit via -ldflags; the panel compares the running commit to the dev release commit to detect an update, and update.sh honors XUI_UPDATE_TAG to install from that tag. Linux/systemd only.
This commit is contained in:
@@ -20,6 +20,15 @@ var version string
|
||||
//go:embed name
|
||||
var name string
|
||||
|
||||
// buildCommit and buildDate are injected at build time via `-ldflags -X` for
|
||||
// CI per-commit (dev channel) builds; see .github/workflows/release.yml. They
|
||||
// stay empty for a plain `go build` and for stable tagged releases, which is how
|
||||
// IsDevBuild tells a rolling dev build apart from a stable/local one.
|
||||
var (
|
||||
buildCommit string
|
||||
buildDate string
|
||||
)
|
||||
|
||||
// LogLevel represents the logging level for the application.
|
||||
type LogLevel string
|
||||
|
||||
@@ -42,6 +51,23 @@ func GetName() string {
|
||||
return strings.TrimSpace(name)
|
||||
}
|
||||
|
||||
// GetBuildCommit returns the short git commit this binary was built from, or an
|
||||
// empty string for a plain/local build or a stable tagged release.
|
||||
func GetBuildCommit() string {
|
||||
return strings.TrimSpace(buildCommit)
|
||||
}
|
||||
|
||||
// GetBuildDate returns the UTC build timestamp injected at build time, or empty.
|
||||
func GetBuildDate() string {
|
||||
return strings.TrimSpace(buildDate)
|
||||
}
|
||||
|
||||
// IsDevBuild reports whether this binary is a CI per-commit (dev channel) build,
|
||||
// detected by the injected commit. Stable releases and local builds return false.
|
||||
func IsDevBuild() bool {
|
||||
return GetBuildCommit() != ""
|
||||
}
|
||||
|
||||
// GetLogLevel returns the current logging level based on environment variables or defaults to Info.
|
||||
func GetLogLevel() LogLevel {
|
||||
if IsDebug() {
|
||||
|
||||
Reference in New Issue
Block a user