build: Implement semantic versioning in build system#4468
build: Implement semantic versioning in build system#4468NETIZEN-11 wants to merge 1 commit intokptdev:mainfrom
Conversation
✅ 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 |
b9924d7 to
ed2e0e2
Compare
ed2e0e2 to
114441b
Compare
|
@liamfallon Good catch, thanks for pointing this out! You're right — the previous implementation was incorrectly picking the latest tag even for development builds. I've updated the logic to:
This should now produce the expected version string. Please 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 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- 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 Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
114441b to
805a22c
Compare
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