Fix release workflow indentation and version comparison#3638
Fix release workflow indentation and version comparison#3638deepshekhardas wants to merge 6 commits into
Conversation
Lets us ship a patch (e.g. 4.4.6) from a release/4.4.x branch without
including unreleased work merged into main, and without the patch
clobbering floating tags incorrectly.
The release-pipeline pieces this touches and how each behaves now:
npm dist-tag latest if version > current latest, else release-<M.m>
Docker :v4-beta same gate (highest version only)
Docker :release-X.Y new per-line floating tag, always set on a semver build
GitHub release --latest=true|false set explicitly (no auto-detect)
How the gate is computed:
release.yml's 'Compare new version to current latest' step queries
npm view @trigger.dev/sdk dist-tags.latest, compares via sort -V,
sets is_latest=true|false. Drives every floating tag.
Triggers / refs:
- pull_request:branches[main, release/**]
- if-conditions allow head.ref starting with 'changeset-release/'
- workflow_dispatch ref must be reachable from main OR a release/* branch
- changesets-pr.yml fires on push to release/** too; PR-enhance step
discovers source branch dynamically (no more hardcoded changeset-release/main)
Other changes:
- gh release create: drop --target main (tag carries right commit)
- dispatch-changelog payload includes is_latest so the marketing site
can render lagged-line releases differently
- enhance-release-pr.mjs prepends a Release prep header on release/*
branches showing version, current latest, and whether the PR will
take the latest dist-tag
release-helm.yml unchanged — already creates as draft+prerelease so it
can't claim Latest. publish-worker.yml (coordinator/provider) unchanged
since those don't have a :v4-beta-equivalent floating tag.
Validated end-to-end in ericallam/pkgring-sandbox across both scenarios:
Scenario A (lagged hotfix): latest stays put, only release-X.Y moves
Scenario B (main has unreleased work, hotfix is highest): latest moves
- enhance-release-pr.mjs: fix dead try/catch, use proper semver comparison - release.yml: add retry loop for npm view to prevent silent failures incorrectly promoting lagged hotfix to :latest
|
|
Hi @deepshekhardas, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughThis PR enables the release workflow system to support hotfix releases on Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| gh release create "v${VERSION}" \ | ||
| --title "trigger.dev v${VERSION}" \ | ||
| --notes-file /tmp/release-body.md \ | ||
| --target main | ||
| --latest="${IS_LATEST}" |
There was a problem hiding this comment.
🔴 Missing --target in gh release create causes release tag to point to wrong commit on release branches
The old --target main was removed and replaced only by --latest="${IS_LATEST}", but no --target is specified. When gh release create "v${VERSION}" runs, the v${VERSION} tag does not yet exist (per-package tags like @trigger.dev/sdk@4.5.0 are created by changeset publish, but the unified v4.5.0 tag is not). Without --target, the GitHub API defaults to creating the tag at the HEAD of the repository's default branch (main). For hotfix releases from release/X.Y.x branches, this means the v4.4.7 tag is created pointing to main's HEAD instead of the actual release commit on the release/4.4.x branch — causing the GitHub release to reference the wrong source code.
| gh release create "v${VERSION}" \ | |
| --title "trigger.dev v${VERSION}" \ | |
| --notes-file /tmp/release-body.md \ | |
| --target main | |
| --latest="${IS_LATEST}" | |
| gh release create "v${VERSION}" \ | |
| --title "trigger.dev v${VERSION}" \ | |
| --notes-file /tmp/release-body.md \ | |
| --target "$(git rev-parse HEAD)" \ | |
| --latest="${IS_LATEST}" |
Was this helpful? React with 👍 or 👎 to provide feedback.
| async function getReleaseContext() { | ||
| const sourceBranch = process.env.SOURCE_BRANCH; | ||
| if (!sourceBranch) return null; | ||
|
|
||
| // Look up current npm `latest` for the canonical package | ||
| let currentLatest = "0.0.0"; | ||
| try { | ||
| const out = await new Promise((resolve) => { | ||
| execFile( | ||
| "npm", | ||
| ["view", "@trigger.dev/sdk", "dist-tags.latest"], | ||
| { maxBuffer: 1024 * 1024 }, | ||
| (err, stdout) => resolve(err ? "" : stdout.trim()) | ||
| ); | ||
| }); | ||
| if (out && out !== "undefined") currentLatest = out; | ||
| } catch { | ||
| // fall through with default | ||
| } | ||
|
|
||
| // Use semver-aware comparison - matches release.yml's sort -V exactly | ||
| // Split versions into parts and compare numerically | ||
| const cmp = (a, b) => | ||
| a.split(".").map(Number).reduce((acc, n, i) => acc || n - (b.split(".").map(Number)[i] ?? 0), 0); | ||
| const willBeLatest = cmp(version, currentLatest) > 0; | ||
|
|
||
| const m = sourceBranch.match(/^release\/(\d+\.\d+)\.x$/); | ||
| const lineMatch = m ? m[1] : null; | ||
|
|
||
| return { sourceBranch, currentLatest, willBeLatest, lineMatch }; | ||
| } |
There was a problem hiding this comment.
🚩 Release prep header now always shown (including main branch)
The getReleaseContext() function at scripts/enhance-release-pr.mjs:416-446 returns non-null whenever SOURCE_BRANCH is set. Since changesets-pr.yml:74 always passes SOURCE_BRANCH="$SOURCE_BRANCH" (which is GITHUB_REF_NAME), the 'Release prep' header will appear on ALL release PRs, including those from main. The JSDoc at line 412 says it 'Returns null when SOURCE_BRANCH is unset (so the header is omitted on plain main releases)' — but in practice it's never unset. The header shows useful info (version, npm comparison) so this may be intentional, but the JSDoc is misleading.
Was this helpful? React with 👍 or 👎 to provide feedback.
| is_latest: | ||
| description: "Whether this version is the highest released version. Drives :v4-beta / :latest tag updates. release.yml computes this via version comparison." | ||
| required: false | ||
| type: boolean | ||
| default: false |
There was a problem hiding this comment.
🚩 Docker v4-beta tag no longer applied on push/workflow_dispatch triggers of publish.yml
Before this PR, any semver Docker build unconditionally got the :v4-beta tag. Now that tag only applies when is_latest is true. When publish.yml is triggered by push (main branch or tag push) or workflow_dispatch (no is_latest input), the input defaults to false and :v4-beta is never set. This is a behavioral change for non-release-workflow triggers. It appears intentional (only the release workflow should control the floating tag), but operators who rely on manual workflow_dispatch of publish.yml to set :v4-beta will need to be aware.
Was this helpful? React with 👍 or 👎 to provide feedback.
This PR fixes indentation in release.yml and improves version comparison in enhance-release-pr.mjs by adding error handling and using numeric version comparison.