revert: 恢复版本号动态注入,本地构建回退为 dev

本地运行不再硬编码 0.3.3,改回 dev;build.sh 通过 git describe
注入真实 tag 并经 ldflags 覆盖 main.version。

Claude-Session: https://claude.ai/code/session_01HMRoSjvobCcuH5gbKkStFF
This commit is contained in:
Autumn-27 committed 2026-08-23 03:55:10 -04:00
1 parent ca1d22b227
commit 070784d43c
2 files changed
+11 -5

No files matched your search

+8 -2
View File
@@ -8,7 +8,7 @@
# ARTEX_TARGET_OS=linux One target OS in single-target mode.
# ARTEX_TARGET_ARCH=amd64 One target arch in single-target mode.
# ARTEX_TARGETS=linux/amd64,... Comma-separated targets for multi-target mode.
# ARTEX_BUILD_VERSION=0.3.3 Version embedded in the binary and archive name.
# ARTEX_BUILD_VERSION=v0.3.3 Version embedded in the binary and archive name.
# ARTEX_OUTPUT=/path/to/artex Explicit binary path in single-target mode.
# ARTEX_OUTPUT_DIR=dist Directory for default binary paths.
# ARTEX_PACKAGE=1 Create a zip archive for each target.
@@ -90,7 +90,13 @@ done
command -v go >/dev/null 2>&1 || die "未检测到 Go(项目需要 Go 1.26 或更高版本)"
ARTEX_GOSUMDB="${ARTEX_GOSUMDB:-sum.golang.org}"
ARTEX_BUILD_VERSION="${ARTEX_BUILD_VERSION:-0.3.3}"
if [ -z "${ARTEX_BUILD_VERSION:-}" ]; then
if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
ARTEX_BUILD_VERSION="$(git describe --tags --always --dirty)"
else
ARTEX_BUILD_VERSION="dev"
fi
fi
# Release tags are commonly passed as v0.3.3; keep the binary version consistent.
ARTEX_BUILD_VERSION="${ARTEX_BUILD_VERSION#v}"
ARTEX_OUTPUT_DIR="${ARTEX_OUTPUT_DIR:-dist}"
+3 -3
View File
@@ -21,9 +21,9 @@ import (
"github.com/Autumn-27/artex/server"
)
// version is the application version. Release builds may override it via
// -ldflags "-X main.version=<version>".
var version = "0.3.3"
// version is the build version, injected at release time via
// -ldflags "-X main.version=<tag>". Defaults to "dev" for local builds.
var version = "dev"
const banner = `
_ ____ _____ _______ __