fix version naming (#20)

* wip

* cursor stuff

* fixes

* undo unneeded

* tag nit

* version cleaned
This commit is contained in:
Cal Bera 2025-07-24 13:56:00 -07:00 committed by GitHub
parent c0886119b3
commit 3058f19298
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 51 additions and 34 deletions

View file

@ -2,7 +2,7 @@ name: CI
on:
push:
branches: [ main ]
branches: [ main, "release/*" ]
pull_request:
branches: [ main ]
workflow_dispatch:

View file

@ -8,6 +8,11 @@ GOBIN = ./build/bin
GO ?= latest
GORUN = go run
COMMIT = $(shell git log -1 --format='%H')
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
TAG := $(shell git describe --tags --abbrev=0 --match "v*")
BUILD_FLAGS := -git-commit=$(COMMIT) -git-branch=$(BRANCH) -git-tag=$(TAG)
#? geth: Build geth.
geth:
$(GORUN) build/ci.go install ./cmd/geth

View file

@ -362,8 +362,8 @@ type ExecutionPayloadBody struct {
// Client identifiers to support ClientVersionV1.
const (
ClientCode = "GE"
ClientName = "go-ethereum"
ClientCode = "BG"
ClientName = "bera-geth"
)
// ClientVersionV1 contains information which identifies a client implementation.

View file

@ -237,6 +237,7 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (
if env.Commit != "" {
ld = append(ld, "-X", "github.com/ethereum/go-ethereum/internal/version.gitCommit="+env.Commit)
ld = append(ld, "-X", "github.com/ethereum/go-ethereum/internal/version.gitDate="+env.Date)
ld = append(ld, "-X", "github.com/ethereum/go-ethereum/internal/version.gitTag="+env.Tag)
}
// Strip DWARF on darwin. This used to be required for certain things,
// and there is no downside to this, so we just keep doing it.

View file

@ -69,7 +69,7 @@ func TestConsoleWelcome(t *testing.T) {
geth.Expect(`
Welcome to the Geth JavaScript console!
instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
instance: bera-geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
at block: 0 ({{niltime}})
datadir: {{.Datadir}}
modules: {{apis}}
@ -89,9 +89,9 @@ func TestAttachWelcome(t *testing.T) {
)
// Configure the instance for IPC attachment
if runtime.GOOS == "windows" {
ipc = `\\.\pipe\geth` + strconv.Itoa(trulyRandInt(100000, 999999))
ipc = `\\.\pipe\bera-geth` + strconv.Itoa(trulyRandInt(100000, 999999))
} else {
ipc = filepath.Join(t.TempDir(), "geth.ipc")
ipc = filepath.Join(t.TempDir(), "bera-geth.ipc")
}
// And HTTP + WS attachment
p := trulyRandInt(1024, 65533) // Yeah, sometimes this will fail, sorry :P
@ -140,7 +140,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
attach.Expect(`
Welcome to the Geth JavaScript console!
instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
instance: bera-geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
at block: 0 ({{niltime}}){{if ipc}}
datadir: {{datadir}}{{end}}
modules: {{apis}}

View file

@ -46,7 +46,7 @@ import (
)
const (
clientIdentifier = "geth" // Client identifier to advertise over the network
clientIdentifier = "bera-geth" // Client identifier to advertise over the network
)
var (

View file

@ -72,7 +72,12 @@ func printVersion(ctx *cli.Context) error {
git, _ := version.VCS()
fmt.Println(strings.Title(clientIdentifier))
fmt.Println("Version:", version.WithMeta)
// Use git tag if available, otherwise fall back to hardcoded version
if git.Tag != "" {
fmt.Println("Version:", git.Tag)
} else {
fmt.Println("Version:", version.WithMeta)
}
if git.Commit != "" {
fmt.Println("Git Commit:", git.Commit)
}

View file

@ -59,9 +59,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
gethversion "github.com/ethereum/go-ethereum/version"
)
const (
@ -359,13 +357,14 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
func makeExtraData(extra []byte) []byte {
if len(extra) == 0 {
// create default extradata
extra, _ = rlp.EncodeToBytes([]interface{}{
uint(gethversion.Major<<16 | gethversion.Minor<<8 | gethversion.Patch),
"geth",
runtime.Version(),
runtime.GOOS,
})
// create default extradata in ASCII format similar to reth
// Format: "bera-geth/vX.Y.Z/platform"
tag := version.WithMeta
if vcs, ok := version.VCS(); ok && vcs.Tag != "" {
tag = vcs.Tag
}
versionStr := fmt.Sprintf("bera-geth/v%s/%s", tag, runtime.GOOS)
extra = []byte(versionStr)
}
if uint64(len(extra)) > params.MaximumExtraDataSize {
log.Warn("Miner extra data exceed limit", "extra", hexutil.Bytes(extra), "limit", params.MaximumExtraDataSize)

View file

@ -1034,14 +1034,18 @@ func (api *ConsensusAPI) ExchangeCapabilities([]string) []string {
func (api *ConsensusAPI) GetClientVersionV1(info engine.ClientVersionV1) []engine.ClientVersionV1 {
log.Trace("Engine API request received", "method", "GetClientVersionV1", "info", info.String())
commit := make([]byte, 4)
vsn := version.WithMeta
if vcs, ok := version.VCS(); ok {
commit = common.FromHex(vcs.Commit)[0:4]
if vcs.Tag != "" {
vsn = vcs.Tag
}
}
return []engine.ClientVersionV1{
{
Code: engine.ClientCode,
Name: engine.ClientName,
Version: version.WithMeta,
Version: vsn,
Commit: hexutil.Encode(commit),
},
}

View file

@ -172,7 +172,12 @@ func LocalEnv() Environment {
}
}
if info, err := os.Stat(".git/objects"); err == nil && info.IsDir() && env.Tag == "" {
// Try to get tag at HEAD first
env.Tag = firstLine(RunGit("tag", "-l", "--points-at", "HEAD"))
// If no tag points at HEAD, get the most recent tag
if env.Tag == "" {
env.Tag = firstLine(RunGit("describe", "--tags", "--abbrev=0"))
}
}
return env
}

View file

@ -30,10 +30,11 @@ const (
// These variables are set at build-time by the linker when the build is
// done by build/ci.go.
var gitCommit, gitDate string
var gitCommit, gitDate, gitTag string
// VCSInfo represents the git repository state.
type VCSInfo struct {
Tag string // git tag
Commit string // head commit hash
Date string // commit time in YYYYMMDD format
Dirty bool
@ -43,7 +44,7 @@ type VCSInfo struct {
func VCS() (VCSInfo, bool) {
if gitCommit != "" {
// Use information set by the build script if present.
return VCSInfo{Commit: gitCommit, Date: gitDate}, true
return VCSInfo{Tag: gitTag, Commit: gitCommit, Date: gitDate}, true
}
if buildInfo, ok := debug.ReadBuildInfo(); ok {
if buildInfo.Main.Path == ourPath {

View file

@ -28,9 +28,6 @@ import (
const ourPath = "github.com/ethereum/go-ethereum" // Path to our module
// Family holds the textual version string for major.minor
var Family = fmt.Sprintf("%d.%d", version.Major, version.Minor)
// Semantic holds the textual version string for major.minor.patch.
var Semantic = fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch)
@ -114,9 +111,9 @@ func Info() (version, vcs string) {
// information. If it is unable to determine which module is related to our
// package it falls back to the hardcoded values in the params package.
func versionInfo(info *debug.BuildInfo) string {
// If the main package is from our repo, prefix version with "geth".
// If the main package is from our repo, prefix version with "bera-geth".
if strings.HasPrefix(info.Path, ourPath) {
return fmt.Sprintf("geth %s", info.Main.Version)
return fmt.Sprintf("bera-geth %s", info.Main.Version)
}
// Not our main package, so explicitly print out the module path and
// version.
@ -130,7 +127,7 @@ func versionInfo(info *debug.BuildInfo) string {
// If our module path wasn't imported, it's unclear which
// version of our code they are running. Fallback to hardcoded
// version.
return version + fmt.Sprintf("geth %s", WithMeta)
return version + fmt.Sprintf("bera-geth %s", WithMeta)
}
// Our package is a dependency for the main module. Return path and
// version data for both.

View file

@ -79,15 +79,15 @@ func TestIPCPathResolution(t *testing.T) {
}{
{"", "", false, ""},
{"data", "", false, ""},
{"", "geth.ipc", false, filepath.Join(os.TempDir(), "geth.ipc")},
{"data", "geth.ipc", false, "data/geth.ipc"},
{"data", "./geth.ipc", false, "./geth.ipc"},
{"data", "/geth.ipc", false, "/geth.ipc"},
{"", "bera-geth.ipc", false, filepath.Join(os.TempDir(), "bera-geth.ipc")},
{"data", "bera-geth.ipc", false, "data/bera-geth.ipc"},
{"data", "./bera-geth.ipc", false, "./bera-geth.ipc"},
{"data", "/bera-geth.ipc", false, "/bera-geth.ipc"},
{"", "", true, ``},
{"data", "", true, ``},
{"", "geth.ipc", true, `\\.\pipe\geth.ipc`},
{"data", "geth.ipc", true, `\\.\pipe\geth.ipc`},
{"data", `\\.\pipe\geth.ipc`, true, `\\.\pipe\geth.ipc`},
{"", "bera-geth.ipc", true, `\\.\pipe\bera-geth.ipc`},
{"data", "bera-geth.ipc", true, `\\.\pipe\bera-geth.ipc`},
{"data", `\\.\pipe\bera-geth.ipc`, true, `\\.\pipe\bera-geth.ipc`},
}
for i, test := range tests {
// Only run when platform/test match