Skip to content

Fix release workflow indentation and version comparison#3638

Closed
deepshekhardas wants to merge 6 commits into
triggerdotdev:mainfrom
deepshekhardas:fix/pr-3530-release-branch
Closed

Fix release workflow indentation and version comparison#3638
deepshekhardas wants to merge 6 commits into
triggerdotdev:mainfrom
deepshekhardas:fix/pr-3530-release-branch

Conversation

@deepshekhardas
Copy link
Copy Markdown

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.

ericallam and others added 6 commits May 11, 2026 10:08
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
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 16, 2026

⚠️ No Changeset found

Latest commit: 9c3a802

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e173f57f-f24c-471d-b110-2ea64fad5eaf

📥 Commits

Reviewing files that changed from the base of the PR and between 05d3ab1 and 9c3a802.

📒 Files selected for processing (6)
  • .github/workflows/changesets-pr.yml
  • .github/workflows/publish-webapp.yml
  • .github/workflows/publish-worker-v4.yml
  • .github/workflows/publish.yml
  • .github/workflows/release.yml
  • scripts/enhance-release-pr.mjs

Walkthrough

This PR enables the release workflow system to support hotfix releases on release/** branches alongside main releases. Changes include: (1) expanding branch triggers to listen for both main and release/** branches, (2) dynamically deriving changesets branch names from the source branch instead of hardcoding changeset-release/main, (3) introducing version comparison logic in the release job to compute an is_latest flag that determines whether a release updates npm's latest distribution tag, (4) conditionally applying distribution tags to prevent accidental main-branch promotions of hotfix versions, and (5) propagating is_latest through downstream Docker tagging workflows to control which images receive the global :v4-beta tag.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/pr-3530-release-branch

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot closed this May 16, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment on lines 227 to +230
gh release create "v${VERSION}" \
--title "trigger.dev v${VERSION}" \
--notes-file /tmp/release-body.md \
--target main
--latest="${IS_LATEST}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Suggested change
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}"
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +416 to +446
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 };
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +11 to +15
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants