@ucdjs/release-scripts 0.1.0-beta.27 ā 0.1.0-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +52 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -344,6 +344,14 @@ var GitService = class extends Effect.Service()("@ucdjs/release-scripts/GitServi
|
|
|
344
344
|
message
|
|
345
345
|
]);
|
|
346
346
|
}
|
|
347
|
+
function writeEmptyCommit(message) {
|
|
348
|
+
return execGitCommandIfNotDry([
|
|
349
|
+
"commit",
|
|
350
|
+
"--allow-empty",
|
|
351
|
+
"-m",
|
|
352
|
+
message
|
|
353
|
+
]);
|
|
354
|
+
}
|
|
347
355
|
function pushChanges(branch, remote = "origin") {
|
|
348
356
|
return execGitCommandIfNotDry([
|
|
349
357
|
"push",
|
|
@@ -459,6 +467,7 @@ var GitService = class extends Effect.Service()("@ucdjs/release-scripts/GitServi
|
|
|
459
467
|
commits: {
|
|
460
468
|
stage: stageChanges,
|
|
461
469
|
write: writeCommit,
|
|
470
|
+
writeEmpty: writeEmptyCommit,
|
|
462
471
|
push: pushChanges,
|
|
463
472
|
forcePush: forcePushChanges,
|
|
464
473
|
get: getCommits,
|
|
@@ -586,6 +595,16 @@ var GitHubService = class extends Effect.Service()("@ucdjs/release-scripts/GitHu
|
|
|
586
595
|
cause: e.cause
|
|
587
596
|
})));
|
|
588
597
|
}
|
|
598
|
+
function createPullRequest(options) {
|
|
599
|
+
return makeRequest("pulls", PullRequestSchema, {
|
|
600
|
+
method: "POST",
|
|
601
|
+
body: JSON.stringify(options)
|
|
602
|
+
}).pipe(Effect.mapError((e) => new GitHubError({
|
|
603
|
+
message: e.message,
|
|
604
|
+
operation: "createPullRequest",
|
|
605
|
+
cause: e.cause
|
|
606
|
+
})));
|
|
607
|
+
}
|
|
589
608
|
const prBodyTemplate = `## Release Summary
|
|
590
609
|
|
|
591
610
|
This PR prepares the release of <%= it.count %> package<%= it.count === 1 ? "" : "s" %>:
|
|
@@ -609,6 +628,7 @@ See individual package changelogs for details.
|
|
|
609
628
|
return {
|
|
610
629
|
getPullRequestByBranch,
|
|
611
630
|
setCommitStatus,
|
|
631
|
+
createPullRequest,
|
|
612
632
|
updatePullRequest,
|
|
613
633
|
generateReleasePRBody
|
|
614
634
|
};
|
|
@@ -1168,16 +1188,23 @@ function constructPrepareProgram(config) {
|
|
|
1168
1188
|
const versionCalculator = yield* VersionCalculatorService;
|
|
1169
1189
|
const workspace = yield* WorkspaceService;
|
|
1170
1190
|
yield* git.workspace.assertWorkspaceReady;
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
yield*
|
|
1191
|
+
let releasePullRequest = yield* github.getPullRequestByBranch(config.branch.release);
|
|
1192
|
+
const isNewRelease = !releasePullRequest;
|
|
1193
|
+
const branchExists = yield* git.branches.exists(config.branch.release);
|
|
1194
|
+
if (!branchExists) {
|
|
1195
|
+
yield* Console.log(`šæ Creating release branch "${config.branch.release}" from "${config.branch.default}"...`);
|
|
1196
|
+
yield* git.branches.create(config.branch.release, config.branch.default);
|
|
1197
|
+
yield* Console.log(`ā
Release branch created.`);
|
|
1198
|
+
}
|
|
1174
1199
|
if ((yield* git.branches.get) !== config.branch.release) {
|
|
1175
1200
|
yield* git.branches.checkout(config.branch.release);
|
|
1176
1201
|
yield* Console.log(`ā
Checked out to release branch "${config.branch.release}".`);
|
|
1177
1202
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1203
|
+
if (!isNewRelease || branchExists) {
|
|
1204
|
+
yield* Console.log(`š Rebasing "${config.branch.release}" onto "${config.branch.default}"...`);
|
|
1205
|
+
yield* git.branches.rebase(config.branch.default);
|
|
1206
|
+
yield* Console.log(`ā
Rebase complete.`);
|
|
1207
|
+
}
|
|
1181
1208
|
const overrides = yield* loadOverrides({
|
|
1182
1209
|
sha: config.branch.default,
|
|
1183
1210
|
overridesPath: ".github/ucdjs-release.overrides.json"
|
|
@@ -1220,17 +1247,30 @@ ${releases.map((r) => ` - ${r.package.name}@${r.newVersion}`).join("\n")}`;
|
|
|
1220
1247
|
yield* Console.log("š¾ Creating commit...");
|
|
1221
1248
|
yield* git.commits.write(commitMessage);
|
|
1222
1249
|
yield* Console.log("ā
Commit created.");
|
|
1223
|
-
yield* Console.log(`ā¬ļø
|
|
1224
|
-
yield* git.commits.
|
|
1225
|
-
yield*
|
|
1226
|
-
yield* Console.log(
|
|
1250
|
+
yield* Console.log(`ā¬ļø Pushing to "${config.branch.release}"...`);
|
|
1251
|
+
if (isNewRelease && !branchExists) yield* git.commits.push(config.branch.release);
|
|
1252
|
+
else yield* git.commits.forcePush(config.branch.release);
|
|
1253
|
+
yield* Console.log(`ā
Push complete.`);
|
|
1227
1254
|
const prBody = yield* github.generateReleasePRBody(releases.map((r) => ({
|
|
1228
1255
|
packageName: r.package.name,
|
|
1229
1256
|
version: r.newVersion,
|
|
1230
1257
|
previousVersion: r.package.version
|
|
1231
1258
|
})));
|
|
1232
|
-
|
|
1233
|
-
|
|
1259
|
+
if (isNewRelease) {
|
|
1260
|
+
yield* Console.log("š Creating release pull request...");
|
|
1261
|
+
releasePullRequest = yield* github.createPullRequest({
|
|
1262
|
+
title: config.pullRequest.title,
|
|
1263
|
+
body: prBody,
|
|
1264
|
+
head: config.branch.release,
|
|
1265
|
+
base: config.branch.default,
|
|
1266
|
+
draft: true
|
|
1267
|
+
});
|
|
1268
|
+
yield* Console.log(`ā
Release pull request #${releasePullRequest.number} created.`);
|
|
1269
|
+
} else {
|
|
1270
|
+
yield* Console.log("š Updating pull request...");
|
|
1271
|
+
yield* github.updatePullRequest(releasePullRequest.number, { body: prBody });
|
|
1272
|
+
yield* Console.log("ā
Pull request updated.");
|
|
1273
|
+
}
|
|
1234
1274
|
yield* Console.log(`\nš Release preparation complete! View PR: #${releasePullRequest.number}`);
|
|
1235
1275
|
});
|
|
1236
1276
|
}
|