ZDDC/zddc/internal/apps/versions.go
2026-06-11 13:32:31 -05:00

39 lines
1.1 KiB
Go

package apps
import (
"strings"
_ "embed"
)
// embeddedVersionsRaw is the manifest written by the top-level build.sh
// at compile time. Format is one `<app>=<build label>` line per app —
// e.g. `archive=v0.0.5-beta · 2026-05-01 14:00:00 · abc1234`. An empty
// or missing value indicates the embedded slot was not populated (a fresh
// clone where build.sh hasn't run yet).
//
//go:embed embedded/versions.txt
var embeddedVersionsRaw []byte
// EmbeddedVersions returns the build label of each tool baked into the
// binary, keyed by canonical app name. Apps with empty values are
// omitted. Caller copies the map if mutation is needed.
func EmbeddedVersions() map[string]string {
out := make(map[string]string, 5)
for _, line := range strings.Split(string(embeddedVersionsRaw), "\n") {
line = strings.TrimSpace(line)
if line == "" || strings.HasPrefix(line, "#") {
continue
}
eq := strings.IndexByte(line, '=')
if eq <= 0 {
continue
}
key := strings.TrimSpace(line[:eq])
val := strings.TrimSpace(line[eq+1:])
if val != "" {
out[key] = val
}
}
return out
}