Skip to content

Commit 02e810e

Browse files
committed
feat(publish): warn when publishing from a non-default branch
Publishing from a feature or release branch is almost always unintentional. Check the current branch at the start of publishWorkflow and emit a warning if it differs from options.branch.default so the operator is informed before any packages are pushed to the registry.
1 parent b2cdb27 commit 02e810e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/workflows/publish.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ async function cleanupPublishedOverrides(
115115
export async function publishWorkflow(options: NormalizedReleaseScriptsOptions): Promise<void> {
116116
logger.section("📦 Publishing Packages");
117117

118+
// Warn if not on the expected default branch — publishing from a feature/release branch is unusual
119+
const currentBranch = await getCurrentBranch(options.workspaceRoot);
120+
if (currentBranch.ok && currentBranch.value !== options.branch.default) {
121+
logger.warn(
122+
`Publishing from branch "${currentBranch.value}" instead of the default branch "${options.branch.default}". `
123+
+ `Pass --force if this is intentional.`,
124+
);
125+
}
126+
118127
// Discover workspace packages
119128
const discovered = await discoverWorkspacePackages(options.workspaceRoot, options);
120129
if (!discovered.ok) {

0 commit comments

Comments
 (0)