mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
chore(version): Use git tag for version reporting (#51)
* chore: miscellaneous nits * use correct default chain configs * add validation and logs around prague1 checks * fix unit tests * chore(version): Use git tag for version reporting * docker + release binaries fix * redeclare docker args in build stage
This commit is contained in:
parent
497e1a4e42
commit
c7f3b7b72b
9 changed files with 77 additions and 17 deletions
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
|
|
@ -19,7 +19,10 @@ jobs:
|
|||
|
||||
linux-intel:
|
||||
name: Linux Build (intel)
|
||||
needs: [extract-version]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
VERSION: ${{ needs.extract-version.outputs.VERSION }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
|
@ -36,7 +39,7 @@ jobs:
|
|||
|
||||
- name: Build (amd64)
|
||||
run: |
|
||||
go run build/ci.go install -static -arch amd64 -dlgo
|
||||
go run build/ci.go install -static -arch amd64 -dlgo -git-tag="${{ env.VERSION }}"
|
||||
|
||||
- name: Create archive (amd64)
|
||||
run: |
|
||||
|
|
@ -57,7 +60,10 @@ jobs:
|
|||
|
||||
linux-arm:
|
||||
name: Linux Build (arm)
|
||||
needs: [extract-version]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
VERSION: ${{ needs.extract-version.outputs.VERSION }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
|
@ -75,7 +81,7 @@ jobs:
|
|||
|
||||
- name: Build (arm64)
|
||||
run: |
|
||||
go run build/ci.go install -static -dlgo -arch arm64 -cc aarch64-linux-gnu-gcc
|
||||
go run build/ci.go install -static -dlgo -arch arm64 -cc aarch64-linux-gnu-gcc -git-tag="${{ env.VERSION }}"
|
||||
|
||||
- name: Create archive (arm64)
|
||||
run: |
|
||||
|
|
|
|||
14
Dockerfile
14
Dockerfile
|
|
@ -6,6 +6,11 @@ ARG BUILDNUM=""
|
|||
# Build Geth in a stock Go builder container
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
# These build arguments need to be redeclared in the builder stage
|
||||
ARG COMMIT
|
||||
ARG VERSION
|
||||
ARG BUILDNUM
|
||||
|
||||
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||
|
||||
# Get dependencies - will also be cached if we won't change go.mod/go.sum
|
||||
|
|
@ -14,7 +19,14 @@ COPY go.sum /bera-geth/
|
|||
RUN cd /bera-geth && go mod download
|
||||
|
||||
ADD . /bera-geth
|
||||
RUN cd /bera-geth && go run build/ci.go install -static ./cmd/bera-geth
|
||||
# Pass git information to the build process
|
||||
# When VERSION is provided (e.g., from CI), use it as the git tag
|
||||
RUN cd /bera-geth && \
|
||||
if [ -n "$VERSION" ]; then \
|
||||
go run build/ci.go install -static -git-tag="$VERSION" -git-commit="$COMMIT" ./cmd/bera-geth; \
|
||||
else \
|
||||
go run build/ci.go install -static ./cmd/bera-geth; \
|
||||
fi
|
||||
|
||||
# Pull Geth into a second stage deploy alpine container
|
||||
FROM alpine:latest
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ ARG BUILDNUM=""
|
|||
# Build Geth in a stock Go builder container
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
# These build arguments need to be redeclared in the builder stage
|
||||
ARG COMMIT
|
||||
ARG VERSION
|
||||
ARG BUILDNUM
|
||||
|
||||
RUN apk add --no-cache gcc musl-dev linux-headers git
|
||||
|
||||
# Get dependencies - will also be cached if we won't change go.mod/go.sum
|
||||
|
|
@ -19,9 +24,20 @@ ADD . /bera-geth
|
|||
# makes it so that under certain circumstances, the docker layer can be cached,
|
||||
# and the builder can jump to the next (build all) command, with the go cache fully loaded.
|
||||
#
|
||||
RUN cd /bera-geth && go run build/ci.go install -static ./cmd/bera-geth
|
||||
# Pass git information to the build process when provided
|
||||
RUN cd /bera-geth && \
|
||||
if [ -n "$VERSION" ]; then \
|
||||
go run build/ci.go install -static -git-tag="$VERSION" -git-commit="$COMMIT" ./cmd/bera-geth; \
|
||||
else \
|
||||
go run build/ci.go install -static ./cmd/bera-geth; \
|
||||
fi
|
||||
|
||||
RUN cd /bera-geth && go run build/ci.go install -static
|
||||
RUN cd /bera-geth && \
|
||||
if [ -n "$VERSION" ]; then \
|
||||
go run build/ci.go install -static -git-tag="$VERSION" -git-commit="$COMMIT"; \
|
||||
else \
|
||||
go run build/ci.go install -static; \
|
||||
fi
|
||||
|
||||
# Pull all binaries into a second stage deploy alpine container
|
||||
FROM alpine:latest
|
||||
|
|
|
|||
5
Makefile
5
Makefile
|
|
@ -8,11 +8,6 @@ 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)
|
||||
|
||||
#? bera-geth: Build bera-geth.
|
||||
bera-geth:
|
||||
$(GORUN) build/ci.go install ./cmd/bera-geth
|
||||
|
|
|
|||
|
|
@ -705,9 +705,14 @@ func doDockerBuildx(cmdline []string) {
|
|||
{file: "Dockerfile.alltools", base: fmt.Sprintf("%s:alltools-", *hubImage)},
|
||||
} {
|
||||
gethImage := fmt.Sprintf("%s%s", spec.base, tag)
|
||||
// Prefer tag when present for VERSION
|
||||
dockerVersion := version.WithMeta
|
||||
if env.Tag != "" {
|
||||
dockerVersion = env.Tag
|
||||
}
|
||||
cmd := exec.Command("docker", "buildx", "build",
|
||||
"--build-arg", "COMMIT="+env.Commit,
|
||||
"--build-arg", "VERSION="+version.WithMeta,
|
||||
"--build-arg", "VERSION="+dockerVersion,
|
||||
"--build-arg", "BUILDNUM="+env.Buildnum,
|
||||
"--tag", gethImage,
|
||||
"--platform", *platform,
|
||||
|
|
|
|||
|
|
@ -131,7 +131,13 @@ func defaultNodeConfig() node.Config {
|
|||
git, _ := version.VCS()
|
||||
cfg := node.DefaultConfig
|
||||
cfg.Name = clientIdentifier
|
||||
cfg.Version = version.WithCommit(git.Commit, git.Date)
|
||||
// Prefer git tag for the advertised version (used in web3_clientVersion),
|
||||
// trimming any leading 'v' because NodeName adds the 'v' prefix itself.
|
||||
ver := version.WithMeta
|
||||
if git.Tag != "" {
|
||||
ver = strings.TrimPrefix(git.Tag, "v")
|
||||
}
|
||||
cfg.Version = ver
|
||||
cfg.HTTPModules = append(cfg.HTTPModules, "eth")
|
||||
cfg.WSModules = append(cfg.WSModules, "eth")
|
||||
cfg.IPCPath = clientIdentifier + ".ipc"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
"math"
|
||||
"math/big"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
|
@ -357,13 +358,21 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
|
||||
func makeExtraData(extra []byte) []byte {
|
||||
if len(extra) == 0 {
|
||||
// create default extradata in ASCII format similar to reth
|
||||
// Format: "bera-geth/vX.Y.Z/platform"
|
||||
// Create default extradata in ASCII format similar to reth
|
||||
// Desired format examples:
|
||||
// - bera-geth/v1.011602.0-rc5/linux when tag exists
|
||||
// - bera-geth/v<with-meta>/linux as fallback
|
||||
tag := version.WithMeta
|
||||
if vcs, ok := version.VCS(); ok && vcs.Tag != "" {
|
||||
// Use tag as-is here because the desired extradata includes the leading 'v'
|
||||
tag = vcs.Tag
|
||||
}
|
||||
versionStr := fmt.Sprintf("bera-geth/v%s/%s", tag, runtime.GOOS)
|
||||
versionStr := fmt.Sprintf("bera-geth/%s/%s", func() string {
|
||||
if strings.HasPrefix(tag, "v") {
|
||||
return tag
|
||||
}
|
||||
return "v" + tag
|
||||
}(), runtime.GOOS)
|
||||
extra = []byte(versionStr)
|
||||
}
|
||||
if uint64(len(extra)) > params.MaximumExtraDataSize {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,12 @@ func NewApp(usage string) *cli.App {
|
|||
git, _ := version.VCS()
|
||||
app := cli.NewApp()
|
||||
app.EnableBashCompletion = true
|
||||
// Prefer git tag for the concise CLI version (-v), falling back to commit-based string
|
||||
if git.Tag != "" {
|
||||
app.Version = git.Tag
|
||||
} else {
|
||||
app.Version = version.WithCommit(git.Commit, git.Date)
|
||||
}
|
||||
app.Usage = usage
|
||||
app.Copyright = "Copyright 2013-2025 The go-ethereum Authors"
|
||||
app.Before = func(ctx *cli.Context) error {
|
||||
|
|
|
|||
|
|
@ -69,9 +69,15 @@ func Archive(tag, gitCommit string) string {
|
|||
// conventions in the Ethereum p2p network.
|
||||
func ClientName(clientIdentifier string) string {
|
||||
git, _ := VCS()
|
||||
// Compose version for client name: prefer git tag (without leading 'v'),
|
||||
// otherwise fall back to WithCommit (which includes meta/commit/date if needed).
|
||||
ver := WithCommit(git.Commit, git.Date)
|
||||
if git.Tag != "" {
|
||||
ver = strings.TrimPrefix(git.Tag, "v")
|
||||
}
|
||||
return fmt.Sprintf("%s/v%v/%v-%v/%v",
|
||||
strings.Title(clientIdentifier),
|
||||
WithCommit(git.Commit, git.Date),
|
||||
ver,
|
||||
runtime.GOOS, runtime.GOARCH,
|
||||
runtime.Version(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue