Skip to content

add build and version information if shallow copy or fork#13417

Open
egypcio wants to merge 17 commits intokubernetes-sigs:mainfrom
egypcio:add-build-information-if-shallow-copy
Open

add build and version information if shallow copy or fork#13417
egypcio wants to merge 17 commits intokubernetes-sigs:mainfrom
egypcio:add-build-information-if-shallow-copy

Conversation

@egypcio
Copy link

@egypcio egypcio commented Mar 7, 2026

What this PR does / why we need it:

by merging this PR, we would:

  • keep building normally as usual;
  • ensure all changes met shellcheck's criterias;
  • fix added ldflags via hack/version.sh;
  • identify detailed version information that built the binaries (e.g.:clusterctl);
  • log that the binary was built from a development source code.

tested on Linux and Mac.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

motivation behind these changes should fix:

  • the check to abort the build process while no SEMVER was found was broken;
  • ldflags didn't get properly added to the go build parameters;
  • folks should be given a more precise information of the commit and tag that built the artifacts.

How to reproduce

reproduce.sh

/bin/sh reproduce.sh

clusterctl version current output

  • official repo
clusterctl version: &version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.0-rc.0.408-2056a9f66d773d", GitCommit:"2056a9f66d773d7f04e9e0a05afb8c4e5647e4ff", GitTreeState:"clean", BuildDate:"2026-03-07T08:19:35Z", GoVersion:"go1.25.7", Compiler:"gc", Platform:"linux/amd64"}

New clusterctl version available: v1.12.0-rc.0.408-2056a9f66d773d -> v1.12.3
sigs.k8s.io/cluster-api
  • official repo (SHALLOW)
clusterctl version: &version.Info{Major:"", Minor:"", GitVersion:"", GitCommit:"", GitTreeState:"", BuildDate:"", GoVersion:"go1.25.7", Compiler:"gc", Platform:"linux/amd64"}

clusterctl version proposed output, if shallow or fork

clusterctl version: &version.Info{Major:"0", Minor:"0", GitVersion:"v0.0.0-fb881cc2b88072-fork", GitCommit:"fb881cc2b88072c42016a84f0e33ceeae79929d1", GitTreeState:"clean", BuildDate:"2026-03-07T08:25:50Z", GoVersion:"go1.25.7", Compiler:"gc", Platform:"linux/amd64"}

managers build target gets also the benefits of proposed changes

$ make clusterctl managers
$ find bin
bin
bin/kubeadm-control-plane-manager
bin/clusterctl
bin/manager
bin/capd-manager
bin/kubeadm-bootstrap-manager
  • before
"Version:  (git commit: )" logger="setup"
  • after
 "Version: v0.0.0-fb881cc2b88072-fork (git commit: fb881cc2b88072c42016a84f0e33ceeae79929d1)" logger="setup"

egypcio added 17 commits March 7, 2026 09:03
  - before this patch, code built on shallow copies but didn't provide
    proper versioning information (e.g.: git commit, or tree state);
  - we now inject data from the git repository into "version" commands'
    output

Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
  - tree could be clean, but clone is a shallow copy anyway;
  - rework how the interruption of a build is done (we need at least a
    tag for that proper parsing)

Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
Signed-off-by: vinícius <651124+egypcio@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label labels Mar 7, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joelspeed for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Hi @egypcio. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 7, 2026
@egypcio
Copy link
Author

egypcio commented Mar 7, 2026

/area clusterctl

@k8s-ci-robot k8s-ci-robot added area/clusterctl Issues or PRs related to clusterctl and removed do-not-merge/needs-area PR is missing an area label labels Mar 7, 2026
@egypcio
Copy link
Author

egypcio commented Mar 8, 2026

/area misc

@k8s-ci-robot k8s-ci-robot added the area/misc Issues or PRs not related to any other area label Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/clusterctl Issues or PRs related to clusterctl area/misc Issues or PRs not related to any other area cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants