diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 54367056..6015efa0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,8 +16,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Fetch tags - run: git fetch --tags origin - name: Setup Go uses: actions/setup-go@v5 @@ -120,8 +118,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Fetch tags - run: git fetch --tags origin - name: Docker meta id: meta @@ -179,8 +175,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Fetch tags - run: git fetch --tags origin - name: Docker meta id: meta-hw @@ -236,8 +230,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Fetch tags - run: git fetch --tags origin - name: Docker meta id: meta-rk diff --git a/internal/app/app.go b/internal/app/app.go index 1d96965f..cbce37e3 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -7,7 +7,6 @@ import ( "os/exec" "runtime" "runtime/debug" - "strings" ) var ( @@ -92,14 +91,6 @@ func Init() { func readRevisionTime() (revision, vcsTime string) { if info, ok := debug.ReadBuildInfo(); ok { - // Rewrite version from -buildvcs info if it is valid. - // Format for tagged version: v1.9.13 - // Format for custom commit: v1.9.14-0.20251215184105-753d6617ab58 - // Format for modified code: v1.9.14-0.20251215184105-753d6617ab58+dirty - if s, ok := strings.CutPrefix(info.Main.Version, "v"); ok { - Version = s - } - for _, setting := range info.Settings { switch setting.Key { case "vcs.revision": @@ -112,10 +103,20 @@ func readRevisionTime() (revision, vcsTime string) { vcsTime = setting.Value case "vcs.modified": if setting.Value == "true" { - revision += "+dirty" + revision += ".dirty" } } } + + // Check version from -buildvcs info + // Format for tagged version : v1.9.13 + // Format for modified code: v1.9.14-0.20251215184105-753d6617ab58+dirty + if info.Main.Version != "v"+Version { + // Format: 1.9.13+dev.753d661[.dirty] + // Compatible with "awesomeversion" and "packaging.version" from python. + // Version will be larger than the previous release, but smaller than the next release. + Version += "+dev." + revision + } } return }