@git.zone/cli 8.3.2 → 8.5.0

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 (39) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/helpers.workflow.d.ts +29 -0
  3. package/dist_ts/helpers.workflow.js +37 -2
  4. package/dist_ts/mod_config/index.js +45 -3
  5. package/dist_ts/mod_release/classes.releasejournal.d.ts +19 -3
  6. package/dist_ts/mod_release/classes.releasejournal.js +108 -13
  7. package/dist_ts/mod_release/helpers.giteaassets.d.ts +47 -1
  8. package/dist_ts/mod_release/helpers.giteaassets.js +236 -56
  9. package/dist_ts/mod_release/helpers.npmartifact.d.ts +68 -7
  10. package/dist_ts/mod_release/helpers.npmartifact.js +192 -26
  11. package/dist_ts/mod_release/helpers.releasebranch.d.ts +11 -0
  12. package/dist_ts/mod_release/helpers.releasebranch.js +88 -61
  13. package/dist_ts/mod_release/helpers.releaseline.d.ts +60 -0
  14. package/dist_ts/mod_release/helpers.releaseline.js +129 -0
  15. package/dist_ts/mod_release/helpers.releasephase.d.ts +9 -0
  16. package/dist_ts/mod_release/helpers.releasephase.js +25 -0
  17. package/dist_ts/mod_release/helpers.releasepreparation.js +6 -3
  18. package/dist_ts/mod_release/helpers.releasepublication.d.ts +12 -1
  19. package/dist_ts/mod_release/helpers.releasepublication.js +235 -52
  20. package/dist_ts/mod_release/helpers.releaseversion.d.ts +2 -0
  21. package/dist_ts/mod_release/helpers.releaseversion.js +4 -2
  22. package/dist_ts/mod_release/index.js +149 -44
  23. package/dist_ts/mod_release/interfaces.giteaassets.d.ts +16 -0
  24. package/package.json +5 -5
  25. package/readme.md +224 -17
  26. package/ts/00_commitinfo_data.ts +1 -1
  27. package/ts/helpers.workflow.ts +87 -0
  28. package/ts/mod_config/index.ts +50 -1
  29. package/ts/mod_release/classes.releasejournal.ts +165 -14
  30. package/ts/mod_release/helpers.giteaassets.ts +319 -64
  31. package/ts/mod_release/helpers.npmartifact.ts +302 -22
  32. package/ts/mod_release/helpers.releasebranch.ts +120 -45
  33. package/ts/mod_release/helpers.releaseline.ts +214 -0
  34. package/ts/mod_release/helpers.releasephase.ts +26 -0
  35. package/ts/mod_release/helpers.releasepreparation.ts +12 -3
  36. package/ts/mod_release/helpers.releasepublication.ts +425 -78
  37. package/ts/mod_release/helpers.releaseversion.ts +5 -1
  38. package/ts/mod_release/index.ts +213 -32
  39. package/ts/mod_release/interfaces.giteaassets.ts +19 -0
@@ -89,7 +89,11 @@ export const compareReleaseVersions = (
89
89
  return 0;
90
90
  };
91
91
 
92
- const majorOf = (versionArg: string): bigint => parseVersionCore(versionArg)[0];
92
+ /** The major component of a canonical x.y.z version. */
93
+ export const releaseVersionMajor = (versionArg: string): bigint =>
94
+ parseVersionCore(versionArg)[0];
95
+
96
+ const majorOf = releaseVersionMajor;
93
97
 
94
98
  // npm and the version bump arithmetic handle only safe integer components.
95
99
  const hasSafeIntegerComponents = (versionArg: string): boolean =>
@@ -59,20 +59,36 @@ import {
59
59
  import {
60
60
  assertNoLegacyNpmPublisher,
61
61
  assertNoStandaloneTspublishPublisher,
62
+ assertNpmDistTagsAllowPublication,
62
63
  assertNpmRegistryAuthentication,
64
+ assertPnpmDistTagReadCapability,
63
65
  assertPnpmReleaseCapability,
64
66
  hashReleaseDestination,
65
67
  normalizeNpmRegistryUrl,
66
68
  packNpmArtifact,
69
+ readAnonymousNpmDistTags,
67
70
  verifyStoredNpmArtifact,
68
71
  type IPnpmReleaseCapability,
69
72
  } from "./helpers.npmartifact.js";
70
73
  import {
71
74
  describeReleaseNpmPackages,
75
+ getReleaseNpmPublicationOrder,
72
76
  planReleaseNpmPackages,
73
77
  } from "./helpers.npmpackages.js";
78
+ import {
79
+ assertReleaseLineVersion,
80
+ findDistTagPublicationRefusal,
81
+ getReleaseDistTag,
82
+ isSameReleaseLine,
83
+ latestDistTag,
84
+ type IReleaseLine,
85
+ } from "./helpers.releaseline.js";
74
86
  import { executeReleasePublication } from "./helpers.releasepublication.js";
75
87
  import { formatCommandFailure } from "./helpers.commandfailure.js";
88
+ import {
89
+ formatReleaseDuration,
90
+ printReleasePhase,
91
+ } from "./helpers.releasephase.js";
76
92
  import { runTstestCleanup } from "../helpers.tstest.js";
77
93
  import {
78
94
  assertPackageReleaseRecovery,
@@ -92,6 +108,7 @@ import {
92
108
  assertResolvedCurrentVersion,
93
109
  describeAppliedVersionFloor,
94
110
  describeReleaseVersion,
111
+ releaseVersionMajor,
95
112
  resolveReleaseVersion,
96
113
  toReleaseVersionFloorRecord,
97
114
  type IReleaseVersionFloorRecord,
@@ -192,6 +209,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
192
209
  // A detached launch checks in the foreground what the plan checks, and
193
210
  // leaves every mutation to the release it starts.
194
211
  planMode: workflow.confirmation === "plan" || detach,
212
+ releaseLine: workflow.line,
195
213
  gitRemotePolicy: createReleaseGitRemotePolicy(
196
214
  workflow.gitRemoteTimeoutSeconds,
197
215
  ),
@@ -214,7 +232,12 @@ const runInternal = async (argvArg: any): Promise<void> => {
214
232
  levelOverride: readReleaseLevelOverride(argvArg),
215
233
  versionFloor: workflow.versionFloor,
216
234
  });
217
- printReleasePlan(workflow, branchContext, versionResolution);
235
+ assertReleaseLineVersion(
236
+ workflow.line,
237
+ versionResolution.currentVersion,
238
+ versionResolution.version,
239
+ );
240
+ await printReleasePlan(workflow, branchContext, versionResolution);
218
241
  if (workflow.confirmation === "plan") {
219
242
  return;
220
243
  }
@@ -242,6 +265,21 @@ const runInternal = async (argvArg: any): Promise<void> => {
242
265
  }
243
266
 
244
267
  const newVersion = versionResolution.version;
268
+ if (workflow.targets.includes("npm") && workflow.npmPackages) {
269
+ await assertNpmDistTagsAllowPublication({
270
+ reader: {
271
+ smartshell: smartshellInstance,
272
+ cwd: branchContext.sourceCwd,
273
+ capability: pnpmCapability,
274
+ },
275
+ access: workflow.npmAccessLevel,
276
+ registries: workflow.npmRegistries,
277
+ packageNames: getReleaseNpmPublicationOrder(workflow.npmPackages),
278
+ version: newVersion,
279
+ distTag: workflow.npmDistTag,
280
+ nextStep: "release again",
281
+ });
282
+ }
245
283
  if (workflow.giteaAssets) {
246
284
  const { tokenEnv, manifestPath, ...destination } = workflow.giteaAssets;
247
285
  const token = process.env[tokenEnv];
@@ -301,10 +339,9 @@ const runInternal = async (argvArg: any): Promise<void> => {
301
339
  branchContext,
302
340
  );
303
341
  if (workflow.runTests) {
304
- await runCommandStep(
342
+ await runReleaseTests(
305
343
  smartshellInstance,
306
344
  branchContext.sourceCwd,
307
- "Running tests",
308
345
  workflow.testCommand,
309
346
  );
310
347
  }
@@ -312,7 +349,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
312
349
  let releaseCwd = branchContext.sourceCwd;
313
350
  let releasePushUrl = branchContext.pushUrl;
314
351
  let expectedRemoteMainOid = branchContext.remoteMainOid;
315
- if (branchContext.sourceBranch === "main") {
352
+ if (branchContext.sourceBranch === branchContext.releaseBranch) {
316
353
  await revalidatePreparedReleaseBranch(smartshellInstance, branchContext);
317
354
  } else {
318
355
  const integration = await integrateReleaseBranch(
@@ -328,6 +365,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
328
365
  await runChangelogStep(workflow, newVersion, releaseCwd);
329
366
  const releaseCommitOid = await runReleaseCommitStep(
330
367
  smartshellInstance,
368
+ branchContext.releaseBranch,
331
369
  newVersion,
332
370
  releaseCwd,
333
371
  );
@@ -340,6 +378,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
340
378
  const releaseRefs = await captureReleaseRefs(
341
379
  smartshellInstance,
342
380
  releaseCwd,
381
+ branchContext.releaseBranch,
343
382
  newVersion,
344
383
  releaseCommitOid,
345
384
  );
@@ -350,6 +389,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
350
389
  await verifyReleaseRefs(
351
390
  smartshellInstance,
352
391
  releaseCwd,
392
+ branchContext.releaseBranch,
353
393
  newVersion,
354
394
  releaseRefs,
355
395
  );
@@ -400,6 +440,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
400
440
  pushUrl: releasePushUrl,
401
441
  npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
402
442
  giteaAssetTransfer: workflow.giteaAssetTransfer,
443
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
403
444
  gitRemotePolicy: branchContext.gitRemotePolicy,
404
445
  tsdocker: journalContext.tsdocker,
405
446
  ensurePublicationState,
@@ -457,7 +498,7 @@ const assertFreshReleaseCapabilities = async (
457
498
  if (workflowArg.targets.includes("npm")) {
458
499
  await assertNoStandaloneTspublishPublisher(cwdArg);
459
500
  const capability = await assertPnpmReleaseCapability(smartshellArg, cwdArg);
460
- await assertPrivateNpmAuthentication(
501
+ await assertPrivateNpmReleaseCapabilities(
461
502
  smartshellArg,
462
503
  cwdArg,
463
504
  capability,
@@ -470,11 +511,14 @@ const assertFreshReleaseCapabilities = async (
470
511
  };
471
512
 
472
513
  /**
473
- * A private package is verified with the registry's configured
474
- * authentication, so every destination must confirm that authentication
475
- * before anything is committed, tagged or published.
514
+ * A private package is read and verified through the qualified pnpm with the
515
+ * registry's configured authentication. Every path that assembles a pnpm
516
+ * capability for a release (fresh, recorded-intent preparation, recover and
517
+ * resume) runs this before anything is committed, tagged or published: the
518
+ * `pnpm view <name> dist-tags --json` read joins the qualified contract, then
519
+ * every destination must confirm its authentication.
476
520
  */
477
- const assertPrivateNpmAuthentication = async (
521
+ const assertPrivateNpmReleaseCapabilities = async (
478
522
  smartshellArg: plugins.smartshell.Smartshell,
479
523
  cwdArg: string,
480
524
  capabilityArg: IPnpmReleaseCapability,
@@ -483,6 +527,7 @@ const assertPrivateNpmAuthentication = async (
483
527
  nextStepArg: string,
484
528
  ): Promise<void> => {
485
529
  if (accessArg !== "private") return;
530
+ await assertPnpmDistTagReadCapability(smartshellArg, cwdArg, capabilityArg);
486
531
  for (const registry of registriesArg) {
487
532
  await assertNpmRegistryAuthentication(
488
533
  { smartshell: smartshellArg, cwd: cwdArg, capability: capabilityArg },
@@ -632,6 +677,7 @@ const recordReleaseIntent = async (
632
677
  ...(optionsArg.versionFloor
633
678
  ? { versionFloor: optionsArg.versionFloor }
634
679
  : {}),
680
+ ...(optionsArg.workflow.line ? { line: optionsArg.workflow.line } : {}),
635
681
  },
636
682
  plan: {
637
683
  targets: optionsArg.workflow.targets,
@@ -746,6 +792,11 @@ const prepareRecordedRelease = async (
746
792
  const { version } = intentArg.release;
747
793
  const workflow = await resolveReleaseWorkflow({ yes: true }, intentArg.plan);
748
794
  assertReleaseConfiguration(workflow, false);
795
+ if (!isSameReleaseLine(workflow.line, intentArg.release.line)) {
796
+ throw new Error(
797
+ `Current release.line (${describeReleaseLine(workflow.line)}) does not match the recorded release (${describeReleaseLine(intentArg.release.line)}).`,
798
+ );
799
+ }
749
800
  const gitEnabled = workflow.targets.includes("git");
750
801
  if (gitEnabled && intentArg.git?.remote !== workflow.gitRemote) {
751
802
  throw new Error(
@@ -761,18 +812,20 @@ const prepareRecordedRelease = async (
761
812
  pushTags: workflow.pushTags,
762
813
  mergeRequested: false,
763
814
  planMode: false,
815
+ releaseLine: intentArg.release.line,
764
816
  gitRemotePolicy: createReleaseGitRemotePolicy(
765
817
  workflow.gitRemoteTimeoutSeconds,
766
818
  ),
767
819
  });
768
820
  if (branch.sourceOid !== intentArg.release.mainOid) {
769
821
  throw new Error(
770
- "Resume must run from the recorded release commit on main.",
822
+ `Resume must run from the recorded release commit on ${branch.releaseBranch}.`,
771
823
  );
772
824
  }
773
825
  const refs = await captureReleaseRefs(
774
826
  smartshellArg,
775
827
  paths.cwd,
828
+ branch.releaseBranch,
776
829
  version,
777
830
  intentArg.release.mainOid,
778
831
  );
@@ -801,8 +854,8 @@ const prepareRecordedRelease = async (
801
854
  : undefined,
802
855
  `run \`gitzone release resume ${version} -y\``,
803
856
  );
804
- console.log(
805
- `\nPreparing the journal of recorded release v${version} from ${refs.mainOid}`,
857
+ printReleasePhase(
858
+ `Preparing the journal of recorded release v${version} from ${refs.mainOid}`,
806
859
  );
807
860
  await prepareTaggedRelease({
808
861
  pnpmCapability,
@@ -815,7 +868,13 @@ const prepareRecordedRelease = async (
815
868
  versionFloor: intentArg.release.versionFloor,
816
869
  refs,
817
870
  ensurePublicationState: async () => {
818
- await verifyReleaseRefs(smartshellArg, paths.cwd, version, refs);
871
+ await verifyReleaseRefs(
872
+ smartshellArg,
873
+ paths.cwd,
874
+ branch.releaseBranch,
875
+ version,
876
+ refs,
877
+ );
819
878
  await revalidateReleasePublicationState(
820
879
  smartshellArg,
821
880
  branch,
@@ -1013,6 +1072,9 @@ export const createReleaseJournal = async (
1013
1072
  ...(optionsArg.versionFloor
1014
1073
  ? { versionFloor: optionsArg.versionFloor }
1015
1074
  : {}),
1075
+ ...(optionsArg.workflow.line
1076
+ ? { line: optionsArg.workflow.line }
1077
+ : {}),
1016
1078
  },
1017
1079
  artifact,
1018
1080
  ...(packages.length || giteaAssets ? { packages } : {}),
@@ -1033,7 +1095,7 @@ export const createReleaseJournal = async (
1033
1095
  access: optionsArg.workflow.targets.includes("npm")
1034
1096
  ? optionsArg.workflow.npmAccessLevel
1035
1097
  : "public",
1036
- tag: "latest",
1098
+ tag: getReleaseDistTag(optionsArg.workflow.line),
1037
1099
  alreadyPublished: optionsArg.workflow.targets.includes("npm")
1038
1100
  ? optionsArg.workflow.npmAlreadyPublished
1039
1101
  : "success",
@@ -1239,6 +1301,11 @@ const runReleaseRecover = async (
1239
1301
  }
1240
1302
  const workflow = await resolveReleaseWorkflow({ yes: true });
1241
1303
  assertReleaseConfiguration(workflow, false);
1304
+ if (workflow.line) {
1305
+ throw new Error(
1306
+ `gitzone release recover does not support release lines: a ${workflow.line.distTag} release records its intent, so continue it with \`gitzone release resume <version> -y\`.`,
1307
+ );
1308
+ }
1242
1309
  let branch = await inspectReleaseBranch({
1243
1310
  smartshell: shell,
1244
1311
  cwd: paths.cwd,
@@ -1255,6 +1322,7 @@ const runReleaseRecover = async (
1255
1322
  const refs = await captureReleaseRefs(
1256
1323
  shell,
1257
1324
  paths.cwd,
1325
+ branch.releaseBranch,
1258
1326
  version,
1259
1327
  branch.sourceOid,
1260
1328
  );
@@ -1317,7 +1385,7 @@ const runReleaseRecover = async (
1317
1385
  branch = await prepareReleaseIntegration(shell, branch);
1318
1386
  options.branch = branch;
1319
1387
  const ensureState = async (remote = branch.remoteMainOid) => {
1320
- await verifyReleaseRefs(shell, paths.cwd, version, refs);
1388
+ await verifyReleaseRefs(shell, paths.cwd, branch.releaseBranch, version, refs);
1321
1389
  await revalidateReleasePublicationState(
1322
1390
  shell,
1323
1391
  branch,
@@ -1364,6 +1432,7 @@ const runReleaseRecover = async (
1364
1432
  pushUrl: branch.pushUrl,
1365
1433
  npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
1366
1434
  giteaAssetTransfer: workflow.giteaAssetTransfer,
1435
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
1367
1436
  gitRemotePolicy: branch.gitRemotePolicy,
1368
1437
  tsdocker,
1369
1438
  ensurePublicationState: ensureState,
@@ -1519,7 +1588,7 @@ const runReleaseResume = async (
1519
1588
  );
1520
1589
  await assertNoLegacyNpmPublisher(paths.cwd);
1521
1590
  await assertNoStandaloneTspublishPublisher(paths.cwd);
1522
- await assertPrivateNpmAuthentication(
1591
+ await assertPrivateNpmReleaseCapabilities(
1523
1592
  smartshellInstance,
1524
1593
  paths.cwd,
1525
1594
  pnpmCapability,
@@ -1548,6 +1617,7 @@ const runReleaseResume = async (
1548
1617
  pushTags: true,
1549
1618
  mergeRequested: false,
1550
1619
  planMode: false,
1620
+ releaseLine: journal.release.line,
1551
1621
  gitRemotePolicy: createReleaseGitRemotePolicy(
1552
1622
  resumeConfiguration.gitRemoteTimeoutSeconds,
1553
1623
  ),
@@ -1580,6 +1650,7 @@ const runReleaseResume = async (
1580
1650
  await verifyReleaseRefs(
1581
1651
  smartshellInstance,
1582
1652
  paths.cwd,
1653
+ branchContext.releaseBranch,
1583
1654
  version,
1584
1655
  refs,
1585
1656
  verificationOnly,
@@ -1611,6 +1682,7 @@ const runReleaseResume = async (
1611
1682
  npmVerificationWindowMs:
1612
1683
  resumeConfiguration.npmVerificationWindowMinutes * 60_000,
1613
1684
  giteaAssetTransfer: resumeConfiguration.giteaAssetTransfer,
1685
+ giteaAssetConcurrency: resumeConfiguration.giteaAssetConcurrency,
1614
1686
  gitRemotePolicy: branchContext.gitRemotePolicy,
1615
1687
  tsdocker,
1616
1688
  ensurePublicationState,
@@ -1647,6 +1719,11 @@ const assertResumeConfiguration = async (
1647
1719
  journalArg: TReleaseJournal,
1648
1720
  cwdArg: string,
1649
1721
  ): Promise<void> => {
1722
+ if (!isSameReleaseLine(workflowArg.line, journalArg.release.line)) {
1723
+ throw new Error(
1724
+ `Current release.line (${describeReleaseLine(workflowArg.line)}) does not match the journal (${describeReleaseLine(journalArg.release.line)}).`,
1725
+ );
1726
+ }
1650
1727
  if (
1651
1728
  journalArg.git.state !== "skipped" &&
1652
1729
  workflowArg.gitRemote !== journalArg.git.remote
@@ -1701,6 +1778,14 @@ const printReleaseJournalSummary = (journalArg: TReleaseJournal): void => {
1701
1778
  ),
1702
1779
  );
1703
1780
  }
1781
+ if (journalArg.release.line) {
1782
+ console.log(
1783
+ `release line: ${journalArg.release.line.branch} (npm dist-tag ${journalArg.release.line.distTag})`,
1784
+ );
1785
+ }
1786
+ if (journalArg.npm.registries.length > 0) {
1787
+ console.log(`npm dist-tag: ${journalArg.npm.tag}`);
1788
+ }
1704
1789
  console.log(`journal revision: ${journalArg.revision}`);
1705
1790
  console.log(
1706
1791
  `artifact: ${journalArg.artifact ? `${journalArg.artifact.integrity} (${journalArg.artifact.sha256})` : "none"}`,
@@ -1748,13 +1833,34 @@ function readReleaseLevelOverride(
1748
1833
  return undefined;
1749
1834
  }
1750
1835
 
1836
+ /**
1837
+ * The release preflight tests: the configured test command against the
1838
+ * release source. This is the one seam where a release will ask tstest's run
1839
+ * ledger whether the configured full test set already passed for this exact
1840
+ * tree, and skip the run when it did; until tstest publishes that ledger, the
1841
+ * release always runs the tests.
1842
+ */
1843
+ async function runReleaseTests(
1844
+ smartshellInstance: plugins.smartshell.Smartshell,
1845
+ cwdArg: string,
1846
+ testCommandArg: string,
1847
+ ): Promise<void> {
1848
+ await runCommandStep(
1849
+ smartshellInstance,
1850
+ cwdArg,
1851
+ "Running tests",
1852
+ testCommandArg,
1853
+ );
1854
+ }
1855
+
1751
1856
  async function runCommandStep(
1752
1857
  smartshellInstance: plugins.smartshell.Smartshell,
1753
1858
  cwdArg: string,
1754
1859
  label: string,
1755
1860
  command: string,
1756
1861
  ): Promise<void> {
1757
- console.log(`\n${label}`);
1862
+ printReleasePhase(label);
1863
+ const startedAt = Date.now();
1758
1864
  const result = await smartshellInstance.exec(command, { cwd: cwdArg });
1759
1865
  if (result.exitCode !== 0) {
1760
1866
  throw new Error(
@@ -1764,7 +1870,10 @@ async function runCommandStep(
1764
1870
  }),
1765
1871
  );
1766
1872
  }
1767
- logger.log("success", `${label} passed.`);
1873
+ logger.log(
1874
+ "success",
1875
+ `${label} passed in ${formatReleaseDuration(Date.now() - startedAt)}.`,
1876
+ );
1768
1877
  }
1769
1878
 
1770
1879
  async function verifyCleanTree(
@@ -1836,6 +1945,7 @@ async function runChangelogStep(
1836
1945
 
1837
1946
  async function runReleaseCommitStep(
1838
1947
  smartshellInstance: plugins.smartshell.Smartshell,
1948
+ releaseBranchArg: string,
1839
1949
  newVersion: string,
1840
1950
  cwdArg: string,
1841
1951
  ): Promise<string> {
@@ -1886,14 +1996,16 @@ async function runReleaseCommitStep(
1886
1996
  if (branchResult.exitCode !== 0) {
1887
1997
  throw new Error(
1888
1998
  formatCommandFailure(
1889
- "The release commit was not created on main.",
1999
+ `The release commit was not created on ${releaseBranchArg}.`,
1890
2000
  branchResult,
1891
2001
  { command: "git symbolic-ref", timeoutMs: 60_000 },
1892
2002
  ),
1893
2003
  );
1894
2004
  }
1895
- if (branchResult.stdout.trim() !== "refs/heads/main") {
1896
- throw new Error("The release commit was not created on main.");
2005
+ if (branchResult.stdout.trim() !== `refs/heads/${releaseBranchArg}`) {
2006
+ throw new Error(
2007
+ `The release commit was not created on ${releaseBranchArg}.`,
2008
+ );
1897
2009
  }
1898
2010
  const headOid = await resolveGitObjectOid(
1899
2011
  smartshellInstance,
@@ -1903,11 +2015,11 @@ async function runReleaseCommitStep(
1903
2015
  const mainOid = await resolveGitObjectOid(
1904
2016
  smartshellInstance,
1905
2017
  cwdArg,
1906
- "refs/heads/main^{commit}",
2018
+ `refs/heads/${releaseBranchArg}^{commit}`,
1907
2019
  );
1908
2020
  if (headOid !== mainOid) {
1909
2021
  throw new Error(
1910
- "HEAD and main diverged after creating the release commit.",
2022
+ `HEAD and ${releaseBranchArg} diverged after creating the release commit.`,
1911
2023
  );
1912
2024
  }
1913
2025
  return mainOid;
@@ -1986,16 +2098,17 @@ const resolveGitObjectOid = async (
1986
2098
  const captureReleaseRefs = async (
1987
2099
  smartshellInstanceArg: plugins.smartshell.Smartshell,
1988
2100
  cwdArg: string,
2101
+ releaseBranchArg: string,
1989
2102
  newVersionArg: string,
1990
2103
  expectedMainOidArg?: string,
1991
- // Verification reads the release commit through its tag, so main is allowed
1992
- // to carry later commits.
2104
+ // Verification reads the release commit through its tag, so the release
2105
+ // branch is allowed to carry later commits.
1993
2106
  mainMayBeAheadArg = false,
1994
2107
  ): Promise<IReleaseRefs> => {
1995
2108
  const mainOid = await resolveGitObjectOid(
1996
2109
  smartshellInstanceArg,
1997
2110
  cwdArg,
1998
- "refs/heads/main^{commit}",
2111
+ `refs/heads/${releaseBranchArg}^{commit}`,
1999
2112
  );
2000
2113
  const tagOid = await resolveGitObjectOid(
2001
2114
  smartshellInstanceArg,
@@ -2014,7 +2127,7 @@ const captureReleaseRefs = async (
2014
2127
  tagCommitOid !== releaseOid
2015
2128
  ) {
2016
2129
  throw new Error(
2017
- "The release tag is not bound to the captured main release commit.",
2130
+ `The release tag is not bound to the captured ${releaseBranchArg} release commit.`,
2018
2131
  );
2019
2132
  }
2020
2133
  return { mainOid: releaseOid, tagOid };
@@ -2023,6 +2136,7 @@ const captureReleaseRefs = async (
2023
2136
  const verifyReleaseRefs = async (
2024
2137
  smartshellInstanceArg: plugins.smartshell.Smartshell,
2025
2138
  cwdArg: string,
2139
+ releaseBranchArg: string,
2026
2140
  newVersionArg: string,
2027
2141
  expectedRefsArg: IReleaseRefs,
2028
2142
  mainMayBeAheadArg = false,
@@ -2030,6 +2144,7 @@ const verifyReleaseRefs = async (
2030
2144
  const currentRefs = await captureReleaseRefs(
2031
2145
  smartshellInstanceArg,
2032
2146
  cwdArg,
2147
+ releaseBranchArg,
2033
2148
  newVersionArg,
2034
2149
  expectedRefsArg.mainOid,
2035
2150
  mainMayBeAheadArg,
@@ -2039,7 +2154,7 @@ const verifyReleaseRefs = async (
2039
2154
  currentRefs.tagOid !== expectedRefsArg.tagOid
2040
2155
  ) {
2041
2156
  throw new Error(
2042
- "Local release refs changed before publication. Inspect main and the release tag before retrying.",
2157
+ `Local release refs changed before publication. Inspect ${releaseBranchArg} and the release tag before retrying.`,
2043
2158
  );
2044
2159
  }
2045
2160
  };
@@ -2059,7 +2174,7 @@ export const resolveResumeReleaseRefs = async (
2059
2174
  if (branchContextArg.sourceOid !== journalArg.release.mainOid) {
2060
2175
  if (!verificationOnly) {
2061
2176
  throw new Error(
2062
- "Resume must run from the journaled release commit on main.",
2177
+ `Resume must run from the journaled release commit on ${branchContextArg.releaseBranch}.`,
2063
2178
  );
2064
2179
  }
2065
2180
  await verifyReleaseHistoryRetained(
@@ -2071,6 +2186,7 @@ export const resolveResumeReleaseRefs = async (
2071
2186
  const refs = await captureReleaseRefs(
2072
2187
  smartshellInstanceArg,
2073
2188
  cwdArg,
2189
+ branchContextArg.releaseBranch,
2074
2190
  journalArg.release.version,
2075
2191
  journalArg.release.mainOid,
2076
2192
  verificationOnly,
@@ -2132,17 +2248,76 @@ function shellQuote(value: string): string {
2132
2248
  return `'${value.replaceAll("'", "'\\''")}'`;
2133
2249
  }
2134
2250
 
2135
- function printReleasePlan(
2251
+ const describeReleaseLine = (lineArg: IReleaseLine | undefined): string =>
2252
+ lineArg
2253
+ ? `branch ${lineArg.branch}, npm dist-tag ${lineArg.distTag}`
2254
+ : "none, releasing main";
2255
+
2256
+ /**
2257
+ * What a line release would do to each public package's dist-tags, read the
2258
+ * way the release reads them. A private package is read with the registry's
2259
+ * authentication, which the plan does not use.
2260
+ */
2261
+ const describeReleaseLineDistTags = async (
2262
+ workflowArg: IResolvedReleaseWorkflow,
2263
+ versionArg: string,
2264
+ ): Promise<string[]> => {
2265
+ if (!workflowArg.line || !workflowArg.npmPackages) return [];
2266
+ const lines: string[] = [];
2267
+ for (const packageName of getReleaseNpmPublicationOrder(
2268
+ workflowArg.npmPackages,
2269
+ )) {
2270
+ for (const registry of workflowArg.npmRegistries) {
2271
+ const prefix = `npm dist-tags of ${packageName} at ${registry}:`;
2272
+ if (workflowArg.npmAccessLevel === "private") {
2273
+ lines.push(
2274
+ `${prefix} read with the registry's authentication when the release runs`,
2275
+ );
2276
+ continue;
2277
+ }
2278
+ const read = await readAnonymousNpmDistTags(registry, packageName);
2279
+ if (read.status === "inconclusive") {
2280
+ lines.push(
2281
+ `${prefix} unreadable (${read.code}); the release stops until the registry answers`,
2282
+ );
2283
+ continue;
2284
+ }
2285
+ const distTags = read.status === "present" ? read.distTags : undefined;
2286
+ const refusal = findDistTagPublicationRefusal(distTags, {
2287
+ packageName,
2288
+ registry,
2289
+ version: versionArg,
2290
+ distTag: workflowArg.npmDistTag,
2291
+ });
2292
+ if (refusal) {
2293
+ lines.push(`${prefix} refused: ${refusal}`);
2294
+ continue;
2295
+ }
2296
+ const lineVersion = distTags?.[workflowArg.npmDistTag];
2297
+ lines.push(
2298
+ `${prefix} ${workflowArg.npmDistTag} ${typeof lineVersion === "string" ? lineVersion : "(new)"} -> ${versionArg}, ${latestDistTag} ${String(distTags?.[latestDistTag])} unchanged`,
2299
+ );
2300
+ }
2301
+ }
2302
+ return lines;
2303
+ };
2304
+
2305
+ async function printReleasePlan(
2136
2306
  workflow: IResolvedReleaseWorkflow,
2137
2307
  branchContextArg: IReleaseBranchContext,
2138
2308
  versionResolutionArg: IReleaseVersionResolution,
2139
- ): void {
2309
+ ): Promise<void> {
2140
2310
  console.log("");
2141
2311
  console.log("gitzone release - resolved workflow");
2142
2312
  console.log(`confirmation: ${workflow.confirmation}`);
2143
2313
  console.log(`plan: ${workflow.plan.join(" -> ")}`);
2144
2314
  console.log(`source branch: ${branchContextArg.sourceBranch}`);
2145
- if (branchContextArg.sourceBranch !== "main") {
2315
+ if (workflow.line) {
2316
+ console.log(
2317
+ `release line: ${workflow.line.branch} -> npm dist-tag ${workflow.line.distTag} (major ${releaseVersionMajor(versionResolutionArg.currentVersion)}; latest is never moved)`,
2318
+ );
2319
+ }
2320
+ if (branchContextArg.sourceBranch !== branchContextArg.releaseBranch) {
2146
2321
  console.log("release branch: main (fast-forward integration requested)");
2147
2322
  console.log(
2148
2323
  `remote main ancestry: ${branchContextArg.planAncestryVerified ? "verified" : "deferred until execution"}`,
@@ -2161,6 +2336,12 @@ function printReleasePlan(
2161
2336
  console.log(
2162
2337
  `npm registries: ${workflow.npmRegistries.length > 0 ? workflow.npmRegistries.join(", ") : "none"}`,
2163
2338
  );
2339
+ console.log(`npm dist-tag: ${workflow.npmDistTag}`);
2340
+ for (const line of await describeReleaseLineDistTags(
2341
+ workflow,
2342
+ versionResolutionArg.version,
2343
+ ))
2344
+ console.log(line);
2164
2345
  }
2165
2346
  if (workflow.npmPackages) {
2166
2347
  for (const line of describeReleaseNpmPackages(workflow.npmPackages))
@@ -25,6 +25,8 @@ export interface IGiteaRelease {
25
25
  id: number;
26
26
  tag: string;
27
27
  publicUrl: string;
28
+ /** A draft is visible to repository writers only, its attachments too. */
29
+ draft: boolean;
28
30
  }
29
31
 
30
32
  export interface IGiteaAssetInspection {
@@ -78,8 +80,25 @@ export interface IGiteaAssetsClient {
78
80
  asset: IGiteaFrozenAsset,
79
81
  artifactDirectory: string,
80
82
  ): Promise<void>;
83
+ /**
84
+ * The complete set, nothing extra, every frozen identity unchanged. Downloads
85
+ * and hashes every attachment except one this client itself downloaded and
86
+ * hashed whose attachment id and UUID are unchanged since. A draft's
87
+ * attachments are listed and downloaded with the token.
88
+ */
81
89
  verifyComplete(
82
90
  releaseId: number,
83
91
  expected: IGiteaFrozenAsset[],
84
92
  ): Promise<void>;
93
+ /**
94
+ * Publishes a draft release (`draft: false`), then proves the release, its
95
+ * attachment identities and every attachment's anonymous download. Every
96
+ * listed attachment must be the one this client hashed (id and UUID; the id
97
+ * alone on a server without UUIDs), otherwise a destination conflict leaves
98
+ * the release a draft. An already published release is only verified.
99
+ */
100
+ publishRelease(
101
+ releaseId: number,
102
+ expected: IGiteaFrozenAsset[],
103
+ ): Promise<void>;
85
104
  }