Skip to content

Commit 3448c2c

Browse files
committed
fix(add-repo): use explicit marker for publish.yml insert point
The previous anchor was the literal text of the "Push to Develop" step in publish.yml, which was removed in 0e6ecee when the release pipeline was restructured. With the anchor gone, `npm run refresh-gh-workflow` quietly warned and dropped any new "Publish <pkg>" step, so the next `add-repo.sh` invocation would land a workspace without a publish entry. Add an explicit comment marker in publish.yml at the bottom of the cd: job's steps, matched by an indent-tolerant regex anchored to start-of-line. A missing marker now throws instead of warning so future workflow drift surfaces immediately.
1 parent 3fc01b3 commit 3448c2c

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ jobs:
242242
env:
243243
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
244244

245+
# update-gha-workflows.ts: insert new "Publish <package>" steps before this line.
246+
245247
finalize:
246248
name: Push release to origin
247249
needs:

‎scripts/update-gha-workflows.ts‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ function generatePathFilters(workspaces: Workspace[], workspaceMap: Map<string,
141141

142142
// ─── publish.yml update ──────────────────────────────────────────────────────
143143

144-
const PUBLISH_STEP_MARKER = ' - name: Push to Develop';
144+
const PUBLISH_STEP_MARKER =
145+
'# update-gha-workflows.ts: insert new "Publish <package>" steps before this line.';
145146

146147
/**
147148
* Scans publish.yml for existing "Publish <name>" steps and adds a default
@@ -184,17 +185,26 @@ function updatePublishWorkflow(content: string, workspaces: Workspace[]): string
184185
].join('\n');
185186
}).join('\n\n');
186187

187-
// Insert before "Push to Develop"
188-
const insertIndex = content.indexOf(PUBLISH_STEP_MARKER);
189-
if (insertIndex === -1) {
190-
console.warn('Warning: Could not find "Push to Develop" step in publish.yml.');
191-
console.warn('New publish steps were NOT added. Please add them manually:');
192-
for (const ws of missing) {
193-
console.warn(` - Publish ${ws.bareName}`);
194-
}
195-
return content;
188+
// A missing marker is fatal rather than a warning: silently dropping
189+
// publish steps would let workflow drift go unnoticed. The match is
190+
// indent-tolerant so the YAML formatter is free to pick a column.
191+
const markerRegex = new RegExp(
192+
`^[ \\t]*${PUBLISH_STEP_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[ \\t]*$`,
193+
'm',
194+
);
195+
const markerMatch = markerRegex.exec(content);
196+
if (!markerMatch) {
197+
const wanted = missing.map(ws => ` - Publish ${ws.bareName}`).join('\n');
198+
throw new Error(
199+
`Could not find the insert marker in publish.yml. ` +
200+
`Expected to find a line containing:\n ${PUBLISH_STEP_MARKER}\n` +
201+
`Add it back (at the bottom of the cd: job's steps, before the next job) ` +
202+
`or update PUBLISH_STEP_MARKER in scripts/update-gha-workflows.ts.\n` +
203+
`New publish steps that were NOT added:\n${wanted}`,
204+
);
196205
}
197206

207+
const insertIndex = markerMatch.index;
198208
return content.slice(0, insertIndex) + newSteps + '\n\n' + content.slice(insertIndex);
199209
}
200210

0 commit comments

Comments
 (0)