MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / main

Function main

scripts/tagLinearIssuesWithRelease.mjs:253–326  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

251}
252
253async function main() {
254 const version = process.argv[2];
255
256 if (!version) {
257 console.error("Usage: node tagLinearIssuesWithRelease.mjs <version>");
258 console.error("Example: node tagLinearIssuesWithRelease.mjs 4.11.4");
259 process.exit(1);
260 }
261
262 const teamKey = process.env.LINEAR_TEAM_ID;
263 if (!teamKey) {
264 console.error("LINEAR_TEAM_ID environment variable is required");
265 process.exit(1);
266 }
267
268 console.log(`Tagging Linear issues for release v${version}`);
269
270 // Find the changelog file
271 const changelogPath = path.join(process.cwd(), "CHANGELOG.md");
272 if (!fs.existsSync(changelogPath)) {
273 console.error(`Changelog not found at: ${changelogPath}`);
274 process.exit(1);
275 }
276
277 // Step 1: Parse changelog for PR numbers
278 console.log("\n1. Parsing changelog for PR numbers...");
279 const prNumbers = getPRsForVersion(changelogPath, version);
280 if (prNumbers.length === 0) {
281 console.log(`No PRs found for version ${version}`);
282 process.exit(0);
283 }
284 console.log(` Found ${prNumbers.length} PRs: ${prNumbers.join(", ")}`);
285
286 // Step 2: Find Linear issues for these PRs
287 console.log("\n2. Finding Linear issues linked to these PRs...");
288 const issues = await findLinearIssuesForPRs(prNumbers);
289 if (issues.length === 0) {
290 console.log(" No Linear issues found linked to these PRs");
291 process.exit(0);
292 }
293 console.log(` Found ${issues.length} Linear issues:`);
294 for (const issue of issues) {
295 console.log(` - ${issue.identifier}: ${issue.title} (PR #${issue.prNumber})`);
296 }
297
298 // Step 3: Get team ID and find/create release label
299 console.log("\n3. Finding or creating release label...");
300 const teamId = await getTeamId(teamKey);
301 const labelId = await findOrCreateReleaseLabel(teamId, version);
302
303 // Step 4: Add label to all issues
304 console.log("\n4. Adding release label to issues...");
305 let successCount = 0;
306 for (const issue of issues) {
307 const existingLabelIds = issue.existingLabels.map((l) => l.id);
308
309 // Check if issue already has the label
310 if (issue.existingLabels.some((l) => l.name === `v${version}`)) {

Callers 1

Calls 5

getPRsForVersionFunction · 0.85
findLinearIssuesForPRsFunction · 0.85
getTeamIdFunction · 0.85
findOrCreateReleaseLabelFunction · 0.85
addLabelToIssueFunction · 0.85

Tested by

no test coverage detected