@ucdjs/release-scripts 0.1.0-beta.53 → 0.1.0-beta.55

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.
Files changed (2) hide show
  1. package/dist/index.mjs +86 -16
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -569,6 +569,63 @@ function toGitError(operation, error) {
569
569
  stderr: formatted.stderr
570
570
  };
571
571
  }
572
+ function isMissingGitIdentityError(error) {
573
+ const formatted = formatUnknownError(error);
574
+ const combined = `${formatted.message}\n${formatted.stderr ?? ""}`;
575
+ return combined.includes("Author identity unknown") || combined.includes("empty ident name") || combined.includes("Please tell me who you are");
576
+ }
577
+ async function ensureLocalGitIdentity(workspaceRoot) {
578
+ try {
579
+ const actor = process.env.GITHUB_ACTOR?.trim();
580
+ const name = process.env.GIT_AUTHOR_NAME?.trim() || process.env.GIT_COMMITTER_NAME?.trim() || actor || "github-actions[bot]";
581
+ const email = process.env.GIT_AUTHOR_EMAIL?.trim() || process.env.GIT_COMMITTER_EMAIL?.trim() || (actor ? `${actor}@users.noreply.github.com` : "github-actions[bot]@users.noreply.github.com");
582
+ logger.warn("Git author identity missing. Configuring repository-local git identity for this run.");
583
+ await runIfNotDry("git", [
584
+ "config",
585
+ "user.name",
586
+ name
587
+ ], { nodeOptions: {
588
+ cwd: workspaceRoot,
589
+ stdio: "pipe"
590
+ } });
591
+ await runIfNotDry("git", [
592
+ "config",
593
+ "user.email",
594
+ email
595
+ ], { nodeOptions: {
596
+ cwd: workspaceRoot,
597
+ stdio: "pipe"
598
+ } });
599
+ logger.info(`Configured git identity: ${farver.dim(`${name} <${email}>`)}`);
600
+ return ok(void 0);
601
+ } catch (error) {
602
+ return err(toGitError("ensureLocalGitIdentity", error));
603
+ }
604
+ }
605
+ async function commitWithRetryOnMissingIdentity(message, workspaceRoot, operation) {
606
+ const runCommit = async () => runIfNotDry("git", [
607
+ "commit",
608
+ "-m",
609
+ message
610
+ ], { nodeOptions: {
611
+ cwd: workspaceRoot,
612
+ stdio: "pipe"
613
+ } });
614
+ try {
615
+ await runCommit();
616
+ return ok(void 0);
617
+ } catch (error) {
618
+ if (!isMissingGitIdentityError(error)) return err(toGitError(operation, error));
619
+ const configured = await ensureLocalGitIdentity(workspaceRoot);
620
+ if (!configured.ok) return configured;
621
+ try {
622
+ await runCommit();
623
+ return ok(void 0);
624
+ } catch (retryError) {
625
+ return err(toGitError(operation, retryError));
626
+ }
627
+ }
628
+ }
572
629
  async function isWorkingDirectoryClean(workspaceRoot) {
573
630
  try {
574
631
  return ok((await run("git", ["status", "--porcelain"], { nodeOptions: {
@@ -725,14 +782,8 @@ async function commitChanges(message, workspaceRoot) {
725
782
  const isClean = await isWorkingDirectoryClean(workspaceRoot);
726
783
  if (!isClean.ok || isClean.value) return ok(false);
727
784
  logger.info(`Committing changes: ${farver.dim(message)}`);
728
- await runIfNotDry("git", [
729
- "commit",
730
- "-m",
731
- message
732
- ], { nodeOptions: {
733
- cwd: workspaceRoot,
734
- stdio: "pipe"
735
- } });
785
+ const committed = await commitWithRetryOnMissingIdentity(message, workspaceRoot, "commitChanges");
786
+ if (!committed.ok) return committed;
736
787
  return ok(true);
737
788
  } catch (error) {
738
789
  const gitError = toGitError("commitChanges", error);
@@ -761,14 +812,8 @@ async function commitPaths(paths, message, workspaceRoot) {
761
812
  stdio: "pipe"
762
813
  } })).stdout.trim() === "") return ok(false);
763
814
  logger.info(`Committing changes: ${farver.dim(message)}`);
764
- await runIfNotDry("git", [
765
- "commit",
766
- "-m",
767
- message
768
- ], { nodeOptions: {
769
- cwd: workspaceRoot,
770
- stdio: "pipe"
771
- } });
815
+ const committed = await commitWithRetryOnMissingIdentity(message, workspaceRoot, "commitPaths");
816
+ if (!committed.ok) return committed;
772
817
  return ok(true);
773
818
  } catch (error) {
774
819
  const gitError = toGitError("commitPaths", error);
@@ -2366,6 +2411,29 @@ async function publishPackage(packageName, version, workspaceRoot, options) {
2366
2411
 
2367
2412
  //#endregion
2368
2413
  //#region src/workflows/publish.ts
2414
+ async function getReleaseBodyFromChangelog(workspaceRoot, packageName, packagePath, version) {
2415
+ const changelogPath = join(packagePath, "CHANGELOG.md");
2416
+ try {
2417
+ const entry = parseChangelog(await readFile(changelogPath, "utf-8")).versions.find((v) => v.version === version);
2418
+ if (!entry) return [
2419
+ `## ${packageName}@${version}`,
2420
+ "",
2421
+ "⚠️ Could not find a matching changelog entry for this version.",
2422
+ "",
2423
+ `Expected version ${version} in ${changelogPath}.`
2424
+ ].join("\n");
2425
+ return entry.content.trim();
2426
+ } catch {
2427
+ logger.verbose(`Could not read changelog entry for ${version} at ${changelogPath}`);
2428
+ return [
2429
+ `## ${packageName}@${version}`,
2430
+ "",
2431
+ "⚠️ Could not read package changelog while creating this release.",
2432
+ "",
2433
+ `Expected changelog file: ${changelogPath}`
2434
+ ].join("\n");
2435
+ }
2436
+ }
2369
2437
  async function cleanupPublishedOverrides(options, workspacePackages, publishedPackageNames) {
2370
2438
  if (publishedPackageNames.length === 0) return false;
2371
2439
  if (options.dryRun) {
@@ -2463,9 +2531,11 @@ async function publishWorkflow(options) {
2463
2531
  logger.success(`Created and pushed tag ${farver.cyan(tagName)}`);
2464
2532
  logger.step(`Creating GitHub release for ${farver.cyan(tagName)}...`);
2465
2533
  try {
2534
+ const releaseBody = await getReleaseBodyFromChangelog(options.workspaceRoot, packageName, pkg.path, version);
2466
2535
  const releaseResult = await options.githubClient.upsertReleaseByTag({
2467
2536
  tagName,
2468
2537
  name: tagName,
2538
+ body: releaseBody,
2469
2539
  prerelease: Boolean(semver.prerelease(version))
2470
2540
  });
2471
2541
  if (releaseResult.release.htmlUrl) logger.success(`${releaseResult.created ? "Created" : "Updated"} GitHub release: ${releaseResult.release.htmlUrl}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucdjs/release-scripts",
3
- "version": "0.1.0-beta.53",
3
+ "version": "0.1.0-beta.55",
4
4
  "description": "@ucdjs release scripts",
5
5
  "type": "module",
6
6
  "license": "MIT",