build: Implement semantic versioning in build system#4468
build: Implement semantic versioning in build system#4468NETIZEN-11 wants to merge 9 commits intokptdev:mainfrom
Conversation
…nctions - Upgrade sigs.k8s.io/kustomize/api from v0.20.1 to v0.21.0 - Upgrade sigs.k8s.io/kustomize/kyaml from v0.20.1 to v0.21.0 - Upgrade k8s.io/api from v0.34.1 to v0.35.0 - Upgrade k8s.io/apimachinery from v0.34.1 to v0.35.0 - Upgrade k8s.io/kubectl from v0.34.1 to v0.35.0 - Upgrade github.com/kptdev/krm-functions-catalog/functions/go/apply-setters from v0.2.2 to v0.2.4 - Update catalog function registry to reference new apply-setters version - Run go mod tidy to resolve transitive dependencies Resolves GitHub Issue kptdev#4406 All catalog functions remain compatible with new APIs - zero breaking changes encountered. Zero compilation errors and zero failing tests across repository. Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR implements semantic versioning in the kpt build system using Git tags. It detects versions from Git tags (matching the pattern v*) and injects them into the binary at build time. For development builds, it falls back to a dev version format with the commit hash. The PR also includes a major refactoring of the package update functionality with improved code structure and documentation, along with comprehensive render status tracking to capture detailed pipeline execution results.
Changes:
- Semantic version detection via git describe in Makefile with automatic fallback for dev builds
- Refactored PkgUpdate implementation with helper functions for better maintainability and clearer error handling
- Enhanced render status tracking throughout the pipeline execution to capture mutation and validation step results
- Cross-platform path handling improvements in Kptfile validation
- Updated Kubernetes dependencies to v0.35.0
- Updated krm-functions-catalog apply-setters from v0.2.2 to v0.2.4
- Build tag updates for wasmtime runtime support detection
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Added semantic version detection using git describe with GIT_COMMIT fallback |
| pkg/lib/kptops/pkgupdate.go | Refactored PkgUpdate into focused helper functions with improved documentation and error handling |
| pkg/api/kptfile/v1/validation.go | Fixed path validation to use path.IsAbs instead of filepath.IsAbs for cross-platform correctness |
| pkg/api/kptfile/v1/types.go | Added Resource field to ResultItem for render status tracking |
| internal/util/render/executor.go | Comprehensive render status tracking with pipeline step results and error aggregation |
| internal/util/render/executor_test.go | Updated tests with cross-platform path handling and render status verification; fixed mkdir bugs |
| internal/fnruntime/wasmtime.go | Updated build tags to exclude Windows from cgo-based wasmtime support |
| internal/fnruntime/wasmtime_unsupported.go | Updated build tags and fixed error message typos |
| internal/fnruntime/utils.go | Code style improvements (YAML string extraction) |
| internal/builtins/pkg_context.go | Improved path normalization and root package detection logic |
| internal/kptops/testdata/ | Updated function version references from v0.2.0 to v0.2.4 |
| go.mod | Updated Kubernetes and related dependencies to v0.35.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Please fix the DCO issue by following these instructions: https://github.com/kptdev/kpt/pull/4468/checks?check_run_id=70060980850 |
fb05e73 to
f8a8606
Compare
- Remove duplicate setRenderStatus function in executor.go - Add TODO comment for unused opts parameter in pkgupdate.go - Fix path handling inconsistency in validation.go (use path.Clean instead of filepath.Clean) Resolves code review feedback from PR kptdev#4468 Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
|
@CsatariGergely Thanks for pointing this out. I've fixed the DCO issue and updated the commits. Kindly take another look. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @NETIZEN-11, Thanks for your PR and contribution! This currently has 23 commits, many of which are unrelated to the build versioning scope. They got included in your branch as part of a merge, This makes it hard to review what's actually part of your change. Could you rebase cleanly onto main so only the semantic versioning changes are visible in the diff? I'd also request the same for your other open PRs. That will make reviews much easier across the board and help get things merged faster. Thanks! |
ddf69bb to
b9924d7
Compare
|
Hi @aravindtga, Thanks for the feedback. I’ve rebased the branch onto main and cleaned up the commits. Now the PR only contains the relevant semantic versioning changes. Could you please take another look? Thanks! |
I tested the solution and it does not seem to work correctly for development builds.
|
The solution here does not insert the correct version string into the binary when building a development version of kpt, see this log: Before fix: After fix: I think the last version string should be |
|
This still doesn't seem to be working (on a cheked out tag), see below: |
|
Hi @liamfallon 👋 Thanks for pointing this out. The issue was caused by a typo in the Makefile ( Also, regarding your test case: the working tree is currently dirty ( Once the working tree is clean, it should correctly pick up the tag (e.g. Could you please pull the latest changes and verify again? Thanks! |
Yes, I know it was dirty. I pulled a tagged version and pasted in your change; your change is not merged so it is not in a tagged version yet. |
|
Also when you have updated a PR, feel free to remove the "awaiting author action" label so we can see that the PR comments are addressed without having to dig into the PR. |
|
I think we should reconsider the whole approach here. I think the way we did this for For local Makefile builds, we use the Makefile and code in the
For releases and builds on Github we use a Github action: |
805a22c to
42d677e
Compare
be8799f to
af44a14
Compare
…n, and CRLF fix: resolve test failures from apply-setters version, path validation, and CRLF - Update testdata Kptfiles to use apply-setters:v0.2.4 (was v0.2.0) which is not registered in the functions map, causing TestRender failures - Fix validateFnConfigPathSyntax to use path.IsAbs (forward-slash) instead of filepath.IsAbs so absolute path detection works correctly on all platforms - Normalize CRLF to LF in pkg_context_test.go when reading expected output files to fix TestPkgContextGenerator on Windows - Remove unused absPath helper and os import from executor_test.go Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
fix: clean up invalid go.mod after rebase - Remove duplicate entries for apply-setters (v0.2.2) and krm-functions-sdk (v1.0.2) - Bump k8s.io/apiextensions-apiserver from v0.34.1 to v0.35.0 to align all k8s deps - Remove gogo/protobuf indirect dep (no longer needed) - Run go mod tidy to validate Addresses reviewer feedback on PR kptdev#4432 Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
…ility fix: keep apply-setters v0.2.0 in functions map for backward compatibility The PR bumps apply-setters to v0.2.4 in go.mod. Adding v0.2.4 to the functions registry is required so Kptfiles referencing the new version work with the built-in runner. v0.2.0 is kept for backward compatibility with existing Kptfiles that already reference that version. Also revert testdata Kptfiles back to v0.2.0 since both versions are now supported by the functions map. Addresses reviewer question on PR kptdev#4432 Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
fix: correct version string for development builds - Use git describe --exact-match to detect tagged commits - Check for dirty working tree with git status --porcelain - Use tag version ONLY if exact match AND clean working tree - Otherwise fallback to v0.0.0-dev+<commit-hash> format - Fixes issue where development builds showed old release tags This ensures that: 1. Tagged commits with clean tree show release version (e.g., v1.0.0-beta.62) 2. Development builds show v0.0.0-dev+<commit-hash> format 3. Dirty working tree always shows dev version (cherry picked from commit 805a22c) Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
fix: separate local build version from release versioning Adopt the porchctl approach for version management: Local development builds: - Makefile injects v0.0.0-dev+<commit> via ldflags - Runtime code reads VCS revision from Go build info - Falls back to dev version format for builds without proper version Release builds (goreleaser): - goreleaser.yaml already injects proper semver tags (e.g., v1.0.0-beta.62) - Runtime code preserves release versions set by goreleaser This resolves the issue where local Makefile builds on a tagged checkout would incorrectly show the tag version instead of dev version. Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
af44a14 to
f6e2858
Compare
Replaced init() with direct initVersion() call in GetMain() to comply with gochecknoinits linter rule. Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
c7837e1 to
fe65dd3
Compare
|
Hi @liamfallon 👋 I've refactored the implementation based on your feedback.
This should address the concerns around maintainability and separation of local vs release builds. Could you please take another look and let me know your thoughts? Thanks! |
Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
Description
This PR implements semantic versioning in the kpt build system using Git tags. It ensures that the version is correctly injected into the binary at build time and provides consistent version output across all architectures.
Part of #4450 - Stabilize kpt API to version 1
Changes Made
Makefile Updates
Semantic Version Detection
git describe --tags --match='v*'to automatically detect version from Git tagsv0.0.0-dev+{commit-hash}for development buildsVersion Injection via ldflags
github.com/kptdev/kpt/run.versionvariableHow It Works