cloudflare/kumo

Public

mirrored fromhttps://github.com/cloudflare/kumoAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ab273fe184fe56ca777f342fa4f1912f726563a8

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

ci/scripts/create-release-pr.ts

121lines · modecode

1#!/usr/bin/env tsx
2
3/**
4 * Create a pull request for package release
5 * Used by release-production.sh to create release PRs on GitHub
6 */
7
8import { createPullRequest } from "../utils/github-api";
9
10interface CliArgs {
11 sourceBranch: string;
12 targetBranch: string;
13 packageName: string;
14 version: string;
15 token: string;
16}
17
18function parseArgs(): CliArgs {
19 const args = process.argv.slice(2);
20 const parsed: Partial<CliArgs> = {};
21
22 for (const arg of args) {
23 if (arg.startsWith("--source-branch=")) {
24 parsed.sourceBranch = arg.split("=")[1];
25 } else if (arg.startsWith("--target-branch=")) {
26 parsed.targetBranch = arg.split("=")[1];
27 } else if (arg.startsWith("--package-name=")) {
28 parsed.packageName = arg.split("=")[1];
29 } else if (arg.startsWith("--version=")) {
30 parsed.version = arg.split("=")[1];
31 } else if (arg.startsWith("--token=")) {
32 parsed.token = arg.split("=")[1];
33 }
34 }
35
36 // Validate required arguments
37 const required: (keyof CliArgs)[] = [
38 "sourceBranch",
39 "targetBranch",
40 "packageName",
41 "version",
42 "token",
43 ];
44 for (const key of required) {
45 if (!parsed[key]) {
46 console.error(
47 `Missing required argument: --${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`,
48 );
49 process.exit(1);
50 }
51 }
52
53 return parsed as CliArgs;
54}
55
56function buildDescription(
57 packageName: string,
58 version: string,
59 releaseBranch: string,
60): string {
61 return `## Production Release
62
63- **Package:** \`${packageName}\`
64- **Version:** \`v${version}\`
65- **Generated by:** Kumo CI Manual Release Pipeline
66
67### Changes
68
69- Version bump and changelog updates
70- Published to npm registry
71
72### Installation
73
74\`\`\`bash
75npm install ${packageName}@${version}
76# or
77pnpm add ${packageName}@${version}
78\`\`\`
79
80### Checklist
81
82- [x] Package published successfully
83- [x] Version bumped in package.json
84- [x] Changelog updated
85- [ ] Manual review completed
86
87**Release branch:** \`${releaseBranch}\`
88
89---
90*Auto-generated by GitHub Actions*`;
91}
92
93async function main() {
94 try {
95 const args = parseArgs();
96
97 console.log(
98 `Creating pull request for ${args.packageName}@${args.version}...`,
99 );
100
101 const result = await createPullRequest(args.token, {
102 sourceBranch: args.sourceBranch,
103 targetBranch: args.targetBranch,
104 title: `chore: release ${args.packageName}@${args.version}`,
105 description: buildDescription(
106 args.packageName,
107 args.version,
108 args.sourceBranch,
109 ),
110 });
111
112 console.log(
113 `Pull request created: ${result.html_url} (PR #${result.number})`,
114 );
115 } catch (error) {
116 console.error("Failed to create pull request:", error);
117 process.exit(1);
118 }
119}
120
121main();
122