Repository navigation
fix(release): publish patches from git tags - #3338
pratap0007 wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/retest |
There was a problem hiding this comment.
🟡 Changes recommended
Legacy VERSION files still override detected tags, causing Make builds to embed outdated client versions.
1 open finding
What changed in this PR
Moves patch releases toward tag-based versioning without updating protected maintenance branches.
Changes:
- Stops committing VERSION during releases.
- Adds git-derived version fallback for Make builds.
- Selects patch numbers from the highest existing tag and pushes version-specific branches.
| File | Description |
|---|---|
tekton/release.sh |
Removes VERSION updates and release commits. |
Makefile |
Adds git-tag fallback for client version injection. |
.github/workflows/patch-release.yaml |
Updates patch numbering and tag/branch publication. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
/retest |
| else ifneq (,$(wildcard ./VERSION)) | ||
| VERSIONLDFLAG := -X github.com/tektoncd/cli/pkg/cmd/version.clientVersion=$(shell cat VERSION) |
|
@pratap0007 can we also delete those VERSION files from the release branches as well? I don't think it is required anymore. |
Swap version detection priority in Makefile to check GIT_VERSION first, falling back to VERSION file only when no git tag exists. Priority order: GIT_VERSION → VERSION file → RELEASE_VERSION Signed-off-by: pratap0007 <shverma@redhat.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Release source archives downloaded from GitHub don't contain .git metadata, causing version detection to fail. Add git's export-subst mechanism to preserve tag information in archives. Creates .git_archival.txt with a $Format:%D$ placeholder that git-archive expands to include tag names. The Makefile now extracts the version from this file when git commands fail, ensuring correct version reporting when building from archives. Fixes: tektoncd#3338 (comment) Signed-off-by: pratap0007 <shverma@redhat.com> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
||
| # Extract version from .git_archival.txt (populated by git-archive export-subst) | ||
| ARCHIVE_VERSION := $(shell if [ -f .git_archival.txt ]; then \ | ||
| sed -n 's/^ref-names:.*tag: v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' .git_archival.txt | head -n1; \ |
|
/retest |
@divyansh42 should we delete later once patch release automation has been fixed? |
Sure |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved version-selection and release-workflow bugs can produce incorrectly versioned binaries and leave public release tags without triggering publication.
10 open issues
Exclude movable branch refs from source archive metadata · New Filter prerelease tags before selecting the latest stable release · New Check unreleased commits against the latest published tag · New Guard maintenance branches that still rely on VERSION · New Push the branch and tag atomically to avoid orphaned releases · New Prevent Git discovery from finding a parent checkout · New Preserve prerelease suffixes when extracting archive versions · New Reject already-tagged tips before assigning a new version · New Reject ambiguous release tags when determining archive version Preserve version metadata when building from release archives
Review effort: Max
| @@ -0,0 +1 @@ | |||
| ref-names: $Format:%D$ | |||
| if [ -z "$last_tag" ]; then | ||
| echo "::notice::Branch ${branch} has no tags — skipping (initial release handled by branch creation)" | ||
| # Latest release tag contained in this branch. | ||
| last_tag=$(git describe --tags --abbrev=0 --match "v${major}.${minor}.*" "$ref" 2>/dev/null || echo "") |
| # Next patch is one above the highest vX.Y.Z tag for this line. | ||
| # Tags that were pushed but never merged are invisible to describe, | ||
| # so v0.45.2 still advances to v0.45.3. | ||
| highest_tag=$(git tag -l "v${major}.${minor}.*" --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1) |
| git config user.email "tekton-robot@tektoncd.com" | ||
| git add VERSION | ||
| git commit -sm "New version ${RELEASE_VERSION}" || echo "No VERSION changes" | ||
| git tag -a "${RELEASE_VERSION}" -m "Release ${RELEASE_VERSION}" |
| git push origin "${RELEASE_VERSION}" | ||
| git push origin "HEAD:${{ matrix.release.branch }}" | ||
| git push origin "HEAD:release-${RELEASE_VERSION}" |
| GIT_VERSION := $(shell tag=$$(git describe --tags --exact-match --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null); \ | ||
| if [ -z "$$tag" ]; then \ | ||
| line=$$(git rev-parse --abbrev-ref HEAD 2>/dev/null | sed -n 's/^release-v\([0-9][0-9]*\.[0-9][0-9]*\)\.x$$/\1/p'); \ | ||
| if [ -n "$$line" ]; then tag=$$(git describe --tags --abbrev=0 --match "v$$line.*" HEAD 2>/dev/null); fi; \ | ||
| fi; printf '%s' "$$tag" | sed 's/^v//') |
|
|
||
| # Extract version from .git_archival.txt (populated by git-archive export-subst) | ||
| ARCHIVE_VERSION := $(shell if [ -f .git_archival.txt ]; then \ | ||
| sed -n 's/^ref-names:.*tag: v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' .git_archival.txt | head -n1; \ |
| git tag --sign -m \ | ||
| "New version ${RELEASE_VERSION}" \ | ||
| -m "${changelog}" --force ${RELEASE_VERSION} |

Stop patch releases from committing VERSION and pushing the protected release-vX.Y.x branch. Tag the branch tip, push release-vX.Y.Z, and choose the next patch from the highest existing tag so an unmerged tag is not reused. make still injects clientVersion from ldflags.
Assisted-by: Grok 4.7 (via Cursor)
Changes
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make checkmake generatedSee the contribution guide
for more details.
Release Notes