@git.zone/cli 8.4.0 → 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.
@@ -19,9 +19,16 @@ import {
19
19
  import {
20
20
  GiteaAssetsClient,
21
21
  GiteaAssetConflictError,
22
+ defaultGiteaAssetConcurrency,
23
+ maximumGiteaAssetConcurrency,
22
24
  validateGiteaAssets,
23
25
  type IGiteaAssetTransferLimits,
26
+ type IGiteaFrozenAsset,
24
27
  } from "./helpers.giteaassets.js";
28
+ import {
29
+ formatReleaseDuration,
30
+ printReleasePhase,
31
+ } from "./helpers.releasephase.js";
25
32
  import { assertGiteaAssetsGitDestination } from "../helpers.workflow.js";
26
33
  import {
27
34
  defaultNpmVerificationWindowMinutes,
@@ -142,6 +149,8 @@ export interface IReleasePublicationOptions {
142
149
  tsdocker?: ITsdockerReleaseClient;
143
150
  /** Transfer bounds for the Gitea client built from the journal's destination. */
144
151
  giteaAssetTransfer?: IGiteaAssetTransferLimits;
152
+ /** Attachments published at the same time; default 2. */
153
+ giteaAssetConcurrency?: number;
145
154
  /** Bound and retries of the Git target's remote inspection. */
146
155
  gitRemotePolicy?: IReleaseGitRemotePolicy;
147
156
  giteaAssets?: Pick<
@@ -152,6 +161,7 @@ export interface IReleasePublicationOptions {
152
161
  | "inspectAssets"
153
162
  | "uploadAsset"
154
163
  | "verifyComplete"
164
+ | "publishRelease"
155
165
  >;
156
166
  ensurePublicationState: (expectedRemoteMainOidArg?: string) => Promise<void>;
157
167
  }
@@ -241,11 +251,19 @@ const updateTarget = async (
241
251
  );
242
252
  }
243
253
  updateArg(status);
244
- return finalizeJournalCompletion(currentArg);
254
+ const finalized = finalizeJournalCompletion(currentArg);
255
+ // A Gitea target never completes a journal on its own: completion is
256
+ // recorded only after the complete attachment set verified.
257
+ return isGiteaSelector(selectorArg) && currentArg.completedAt === null
258
+ ? { ...finalized, completedAt: null }
259
+ : finalized;
245
260
  },
246
261
  );
247
262
  };
248
263
 
264
+ const isGiteaSelector = (selectorArg: TReleaseTargetSelector): boolean =>
265
+ selectorArg.kind === "gitea-release" || selectorArg.kind === "gitea-asset";
266
+
249
267
  const claimTarget = async (
250
268
  storeArg: ReleaseJournalStore,
251
269
  journalArg: TReleaseJournal,
@@ -1763,37 +1781,76 @@ const executeDockerPromotion = async (
1763
1781
  );
1764
1782
  };
1765
1783
 
1784
+ /**
1785
+ * Serializes journal transactions of work that runs concurrently: every
1786
+ * update starts from the journal the previous one produced, so concurrent
1787
+ * attachment publications never race on the journal revision.
1788
+ */
1789
+ interface IReleaseJournalWriter {
1790
+ current(): TReleaseJournal;
1791
+ write(
1792
+ updateArg: (journalArg: TReleaseJournal) => Promise<TReleaseJournal>,
1793
+ ): Promise<TReleaseJournal>;
1794
+ }
1795
+
1796
+ const createReleaseJournalWriter = (
1797
+ journalArg: TReleaseJournal,
1798
+ ): IReleaseJournalWriter => {
1799
+ let current = journalArg;
1800
+ let tail: Promise<unknown> = Promise.resolve();
1801
+ return {
1802
+ current: () => current,
1803
+ write: (updateArg) => {
1804
+ const next = tail.then(async () => {
1805
+ current = await updateArg(current);
1806
+ return current;
1807
+ });
1808
+ tail = next.catch(() => undefined);
1809
+ return next;
1810
+ },
1811
+ };
1812
+ };
1813
+
1814
+ const requireGiteaJournal = (
1815
+ journalArg: TReleaseJournal,
1816
+ ): IReleaseJournalV4 => {
1817
+ if (journalArg.schemaVersion !== 4)
1818
+ throw new Error("Release journal has no Gitea assets.");
1819
+ return journalArg;
1820
+ };
1821
+
1766
1822
  const executeGiteaTarget = async (
1767
1823
  options: IReleasePublicationOptions,
1768
- journalArg: TReleaseJournal,
1824
+ writer: IReleaseJournalWriter,
1769
1825
  selector: TReleaseTargetSelector,
1770
1826
  /** `verifyBytes` is false only for a target the journal already recorded as verified. */
1771
1827
  inspect: (verifyBytes: boolean) => Promise<boolean>,
1772
1828
  publish: () => Promise<void>,
1773
1829
  onVerified?: (target: IReleaseTargetStatus) => void,
1774
- ): Promise<TReleaseJournal> => {
1775
- let journal = journalArg;
1776
- let status = getTargetStatus(journal, selector);
1830
+ ): Promise<void> => {
1831
+ const status = getTargetStatus(writer.current(), selector);
1777
1832
  if (status.state === "conflict")
1778
1833
  throw new Error("Gitea publication has a recorded destination conflict.");
1779
1834
  const mark = async (
1780
1835
  state: "verified" | "failed" | "conflict",
1781
1836
  error: TReleaseErrorCode | null,
1782
1837
  ) => {
1783
- status = getTargetStatus(journal, selector);
1784
- journal = await updateTarget(
1785
- options.store,
1786
- journal,
1787
- selector,
1788
- status.state,
1789
- status.attempt?.id || null,
1790
- (target) => {
1791
- target.state = state;
1792
- target.error = error;
1793
- target.attempt = null;
1794
- if (state === "verified") onVerified?.(target);
1795
- },
1796
- );
1838
+ await writer.write(async (journal) => {
1839
+ const current = getTargetStatus(journal, selector);
1840
+ return updateTarget(
1841
+ options.store,
1842
+ journal,
1843
+ selector,
1844
+ current.state,
1845
+ current.attempt?.id || null,
1846
+ (target) => {
1847
+ target.state = state;
1848
+ target.error = error;
1849
+ target.attempt = null;
1850
+ if (state === "verified") onVerified?.(target);
1851
+ },
1852
+ );
1853
+ });
1797
1854
  };
1798
1855
  let present: boolean;
1799
1856
  try {
@@ -1807,7 +1864,7 @@ const executeGiteaTarget = async (
1807
1864
  }
1808
1865
  if (present) {
1809
1866
  if (status.state !== "verified") await mark("verified", null);
1810
- return journal;
1867
+ return;
1811
1868
  }
1812
1869
  if (status.state === "verified") {
1813
1870
  await mark("conflict", "destination-conflict");
@@ -1816,15 +1873,19 @@ const executeGiteaTarget = async (
1816
1873
  );
1817
1874
  }
1818
1875
  if (status.state === "publishing") {
1819
- journal = await recoverPublishingTarget(
1820
- options.store,
1821
- journal,
1822
- selector,
1823
- options.recoveryAttemptId,
1876
+ await writer.write((journal) =>
1877
+ recoverPublishingTarget(
1878
+ options.store,
1879
+ journal,
1880
+ selector,
1881
+ options.recoveryAttemptId,
1882
+ ),
1824
1883
  );
1825
1884
  }
1826
- await options.ensurePublicationState(journal.release.mainOid);
1827
- journal = await claimTarget(options.store, journal, selector);
1885
+ await options.ensurePublicationState(writer.current().release.mainOid);
1886
+ await writer.write((journal) =>
1887
+ claimTarget(options.store, journal, selector),
1888
+ );
1828
1889
  // One mutation per claimed attempt. Reconcile an accepted request even when
1829
1890
  // its response was lost; never overwrite an attachment or recreate a tag.
1830
1891
  let publicationError: unknown;
@@ -1846,7 +1907,7 @@ const executeGiteaTarget = async (
1846
1907
  }
1847
1908
  if (present) {
1848
1909
  await mark("verified", null);
1849
- return journal;
1910
+ return;
1850
1911
  }
1851
1912
  await mark(
1852
1913
  publicationError instanceof GiteaAssetConflictError ? "conflict" : "failed",
@@ -1862,15 +1923,78 @@ const executeGiteaTarget = async (
1862
1923
  );
1863
1924
  };
1864
1925
 
1926
+ /**
1927
+ * Runs `workArg` for every item with at most `concurrencyArg` at a time,
1928
+ * starting them in the items' order. After the first failure no further item starts; the ones
1929
+ * already running finish, because cutting a running transfer off would leave
1930
+ * its result inconclusive. Every failure is reported.
1931
+ */
1932
+ export const runBoundedInOrder = async <T>(
1933
+ itemsArg: readonly T[],
1934
+ concurrencyArg: number,
1935
+ workArg: (itemArg: T) => Promise<void>,
1936
+ describeArg: (itemArg: T) => string,
1937
+ ): Promise<void> => {
1938
+ const failures: { item: T; error: unknown }[] = [];
1939
+ let nextIndex = 0;
1940
+ const worker = async (): Promise<void> => {
1941
+ while (failures.length === 0 && nextIndex < itemsArg.length) {
1942
+ const item = itemsArg[nextIndex];
1943
+ nextIndex += 1;
1944
+ try {
1945
+ await workArg(item);
1946
+ } catch (error) {
1947
+ failures.push({ item, error });
1948
+ }
1949
+ }
1950
+ };
1951
+ await Promise.all(
1952
+ Array.from(
1953
+ { length: Math.max(1, Math.min(concurrencyArg, itemsArg.length)) },
1954
+ () => worker(),
1955
+ ),
1956
+ );
1957
+ if (failures.length === 1) throw failures[0].error;
1958
+ if (failures.length > 1)
1959
+ throw new AggregateError(
1960
+ failures.map(({ error }) => error),
1961
+ `${failures.length} publications failed: ${failures
1962
+ .map(
1963
+ ({ item, error }) =>
1964
+ `${describeArg(item)}: ${error instanceof Error ? error.message : String(error)}`,
1965
+ )
1966
+ .join("; ")}`,
1967
+ );
1968
+ };
1969
+
1970
+ const resolveGiteaAssetConcurrency = (valueArg: number | undefined): number => {
1971
+ const value = valueArg ?? defaultGiteaAssetConcurrency;
1972
+ if (
1973
+ !Number.isSafeInteger(value) ||
1974
+ value < 1 ||
1975
+ value > maximumGiteaAssetConcurrency
1976
+ )
1977
+ throw new Error(
1978
+ `Gitea asset concurrency must be a whole number between 1 and ${maximumGiteaAssetConcurrency}.`,
1979
+ );
1980
+ return value;
1981
+ };
1982
+
1865
1983
  const executeGiteaAssets = async (
1866
1984
  options: IReleasePublicationOptions,
1867
1985
  journalArg: IReleaseJournalV4,
1868
1986
  client: NonNullable<IReleasePublicationOptions["giteaAssets"]>,
1869
1987
  ): Promise<IReleaseJournalV4> => {
1988
+ const concurrency = resolveGiteaAssetConcurrency(
1989
+ options.giteaAssetConcurrency,
1990
+ );
1991
+ const writer = createReleaseJournalWriter(journalArg);
1870
1992
  let releaseId = journalArg.giteaAssets.release.id;
1871
- let journal = (await executeGiteaTarget(
1993
+ let releaseIsDraft = true;
1994
+ printReleasePhase("Gitea release");
1995
+ await executeGiteaTarget(
1872
1996
  options,
1873
- journalArg,
1997
+ writer,
1874
1998
  { kind: "gitea-release" },
1875
1999
  async () => {
1876
2000
  const release = await client.inspectRelease();
@@ -1878,56 +2002,117 @@ const executeGiteaAssets = async (
1878
2002
  if (releaseId !== null && release.id !== releaseId)
1879
2003
  throw new GiteaAssetConflictError("Gitea release identity changed.");
1880
2004
  releaseId = release.id;
2005
+ releaseIsDraft = release.draft;
1881
2006
  return true;
1882
2007
  },
1883
2008
  async () => {
1884
2009
  await client.createRelease();
1885
2010
  },
1886
2011
  (target) => {
1887
- (target as IReleaseJournalV4["giteaAssets"]["release"]).id = releaseId;
2012
+ if ("id" in target) target.id = releaseId;
1888
2013
  },
1889
- )) as IReleaseJournalV4;
1890
- if (releaseId === null)
2014
+ );
2015
+ const verifiedReleaseId = releaseId;
2016
+ if (verifiedReleaseId === null)
1891
2017
  throw new Error("Gitea release has no verified identity.");
2018
+ const journal = requireGiteaJournal(writer.current());
1892
2019
  const expected = journal.giteaAssets.assets.map((entry) => entry.asset);
1893
2020
  const directory = options.store.getReleaseDirectory(journal.release.version);
1894
- for (const { asset } of journal.giteaAssets.assets) {
1895
- journal = (await executeGiteaTarget(
1896
- options,
1897
- journal,
1898
- { kind: "gitea-asset", name: asset.name },
1899
- async (verifyBytes) => {
1900
- const inspection = await client.inspectAssets(
1901
- releaseId!,
1902
- expected,
1903
- verifyBytes ? [asset] : [],
2021
+ // A draft stays invisible until every attachment verified, so no attachment
2022
+ // is public before the notices and sources beside it: the largest start
2023
+ // first, which shortens the whole publication. A release an older gitzone
2024
+ // already published shows every attachment the moment it lands, so its
2025
+ // missing attachments upload one at a time in manifest order, sources and
2026
+ // notices first, as that gitzone did.
2027
+ const order = releaseIsDraft
2028
+ ? expected
2029
+ .map((asset, index) => ({ asset, index }))
2030
+ .sort((a, b) => b.asset.size - a.asset.size || a.index - b.index)
2031
+ .map(({ asset }) => asset)
2032
+ : expected;
2033
+ const effectiveConcurrency = releaseIsDraft ? concurrency : 1;
2034
+ printReleasePhase(
2035
+ releaseIsDraft
2036
+ ? `Gitea assets: ${expected.length} attachments into the draft, ${effectiveConcurrency} at a time, largest first`
2037
+ : `Gitea assets: ${expected.length} attachments into the already published release, one at a time in manifest order`,
2038
+ );
2039
+ await runBoundedInOrder(
2040
+ order,
2041
+ effectiveConcurrency,
2042
+ async (asset: IGiteaFrozenAsset) => {
2043
+ let startedAt: number | undefined;
2044
+ await executeGiteaTarget(
2045
+ options,
2046
+ writer,
2047
+ { kind: "gitea-asset", name: asset.name },
2048
+ async (verifyBytes) => {
2049
+ const inspection = await client.inspectAssets(
2050
+ verifiedReleaseId,
2051
+ expected,
2052
+ verifyBytes ? [asset] : [],
2053
+ );
2054
+ return inspection.present.some((entry) => entry.name === asset.name);
2055
+ },
2056
+ async () => {
2057
+ startedAt = Date.now();
2058
+ printReleasePhase(
2059
+ `Gitea asset ${asset.name}: uploading ${asset.size} bytes`,
2060
+ );
2061
+ await validateGiteaAssets(directory, [asset]);
2062
+ await client.uploadAsset(verifiedReleaseId, asset, directory);
2063
+ },
2064
+ );
2065
+ if (startedAt !== undefined)
2066
+ printReleasePhase(
2067
+ `Gitea asset ${asset.name}: uploaded, downloaded and hashed in ${formatReleaseDuration(Date.now() - startedAt)}`,
1904
2068
  );
1905
- return inspection.present.some((entry) => entry.name === asset.name);
1906
- },
1907
- async () => {
1908
- await validateGiteaAssets(directory, expected);
1909
- await client.uploadAsset(releaseId!, asset, directory);
1910
- },
1911
- )) as IReleaseJournalV4;
1912
- }
1913
- // One full anonymous verification immediately before entering the npm phase.
1914
- // Resume always repeats it, including an otherwise completed journal.
2069
+ },
2070
+ (asset) => `Gitea asset ${asset.name}`,
2071
+ );
2072
+ // One full verification of the set immediately before publishing it and
2073
+ // before npm: authenticated while the release is a draft, anonymous for a
2074
+ // published one. The client downloads again every attachment it did not
2075
+ // itself hash in this run, so a resume, even of a completed journal,
2076
+ // downloads them all.
2077
+ printReleasePhase("Gitea assets: verifying the complete attachment set");
1915
2078
  try {
1916
- await client.verifyComplete(releaseId, expected);
2079
+ await client.verifyComplete(verifiedReleaseId, expected);
2080
+ // Publish the draft only now. A release published by an older gitzone is
2081
+ // only verified. Setting `draft: false` is idempotent and observable, so
2082
+ // it needs no journal attempt: a resume after a crash finds the release
2083
+ // published, verifies it and continues.
2084
+ printReleasePhase("Gitea release: publishing the verified draft");
2085
+ await client.publishRelease(verifiedReleaseId, expected);
1917
2086
  } catch (error) {
1918
2087
  if (error instanceof GiteaAssetConflictError) {
1919
- await markUnclaimedTarget(
1920
- options.store,
1921
- journal,
1922
- { kind: "gitea-release" },
1923
- ["verified"],
1924
- "conflict",
1925
- "destination-conflict",
2088
+ await writer.write((current) =>
2089
+ markUnclaimedTarget(
2090
+ options.store,
2091
+ current,
2092
+ { kind: "gitea-release" },
2093
+ ["verified"],
2094
+ "conflict",
2095
+ "destination-conflict",
2096
+ ),
1926
2097
  );
1927
2098
  }
1928
2099
  throw error;
1929
2100
  }
1930
- return journal;
2101
+ // Only now may a journal whose last target was a Gitea attachment record
2102
+ // its completion.
2103
+ const verified = writer.current();
2104
+ if (
2105
+ verified.completedAt === null &&
2106
+ finalizeJournalCompletion(verified).completedAt !== null
2107
+ )
2108
+ await writer.write((current) =>
2109
+ options.store.transact(
2110
+ current.release.version,
2111
+ current.revision,
2112
+ (latest) => finalizeJournalCompletion(latest),
2113
+ ),
2114
+ );
2115
+ return requireGiteaJournal(writer.current());
1931
2116
  };
1932
2117
 
1933
2118
  export const executeReleasePublication = async (
@@ -1969,6 +2154,7 @@ export const executeReleasePublication = async (
1969
2154
  await giteaClient.preflight();
1970
2155
  }
1971
2156
  if (journal.schemaVersion === 2) {
2157
+ printReleasePhase("Docker qualification");
1972
2158
  journal = await executeDockerQualification(optionsArg, journal);
1973
2159
  if (
1974
2160
  journal.docker.cleanup.state === "publishing" ||
@@ -1977,6 +2163,7 @@ export const executeReleasePublication = async (
1977
2163
  journal = await executeDockerCleanup(optionsArg, journal);
1978
2164
  }
1979
2165
  }
2166
+ printReleasePhase("Git target");
1980
2167
  journal = await executeGitTarget(optionsArg, journal);
1981
2168
  if (journal.schemaVersion === 4)
1982
2169
  journal = await executeGiteaAssets(optionsArg, journal, giteaClient!);
@@ -1985,6 +2172,9 @@ export const executeReleasePublication = async (
1985
2172
  ? journal.release.mainOid
1986
2173
  : journal.git.expectedRemoteMainOid || undefined;
1987
2174
  for (const registry of journal.npm.registries) {
2175
+ printReleasePhase(
2176
+ `npm ${describeNpmTarget(registry.registry, registry.packageName)}`,
2177
+ );
1988
2178
  await optionsArg.ensurePublicationState(expectedRemoteMainOid);
1989
2179
  journal = await executeNpmRegistry(
1990
2180
  optionsArg,
@@ -1999,6 +2189,9 @@ export const executeReleasePublication = async (
1999
2189
  if (hasReleasePackages(journal)) {
2000
2190
  for (const registry of journal.npm.registries) {
2001
2191
  if (registry.state !== "accepted") continue;
2192
+ printReleasePhase(
2193
+ `npm availability of ${describeNpmTarget(registry.registry, registry.packageName)}`,
2194
+ );
2002
2195
  await optionsArg.ensurePublicationState(expectedRemoteMainOid);
2003
2196
  journal = await executeNpmRegistry(
2004
2197
  optionsArg,
@@ -2028,12 +2221,14 @@ export const executeReleasePublication = async (
2028
2221
  journal.docker.cleanup.state !== "verified"
2029
2222
  ) {
2030
2223
  for (const promotion of journal.docker.promotions) {
2224
+ printReleasePhase(`Docker promotion ${promotion.promotionId}`);
2031
2225
  journal = await executeDockerPromotion(
2032
2226
  optionsArg,
2033
2227
  journal,
2034
2228
  promotion.promotionId,
2035
2229
  );
2036
2230
  }
2231
+ printReleasePhase("Docker cleanup");
2037
2232
  journal = await executeDockerCleanup(optionsArg, journal);
2038
2233
  }
2039
2234
  return journal;
@@ -85,6 +85,10 @@ import {
85
85
  } from "./helpers.releaseline.js";
86
86
  import { executeReleasePublication } from "./helpers.releasepublication.js";
87
87
  import { formatCommandFailure } from "./helpers.commandfailure.js";
88
+ import {
89
+ formatReleaseDuration,
90
+ printReleasePhase,
91
+ } from "./helpers.releasephase.js";
88
92
  import { runTstestCleanup } from "../helpers.tstest.js";
89
93
  import {
90
94
  assertPackageReleaseRecovery,
@@ -335,10 +339,9 @@ const runInternal = async (argvArg: any): Promise<void> => {
335
339
  branchContext,
336
340
  );
337
341
  if (workflow.runTests) {
338
- await runCommandStep(
342
+ await runReleaseTests(
339
343
  smartshellInstance,
340
344
  branchContext.sourceCwd,
341
- "Running tests",
342
345
  workflow.testCommand,
343
346
  );
344
347
  }
@@ -437,6 +440,7 @@ const runInternal = async (argvArg: any): Promise<void> => {
437
440
  pushUrl: releasePushUrl,
438
441
  npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
439
442
  giteaAssetTransfer: workflow.giteaAssetTransfer,
443
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
440
444
  gitRemotePolicy: branchContext.gitRemotePolicy,
441
445
  tsdocker: journalContext.tsdocker,
442
446
  ensurePublicationState,
@@ -850,8 +854,8 @@ const prepareRecordedRelease = async (
850
854
  : undefined,
851
855
  `run \`gitzone release resume ${version} -y\``,
852
856
  );
853
- console.log(
854
- `\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}`,
855
859
  );
856
860
  await prepareTaggedRelease({
857
861
  pnpmCapability,
@@ -1428,6 +1432,7 @@ const runReleaseRecover = async (
1428
1432
  pushUrl: branch.pushUrl,
1429
1433
  npmVerificationWindowMs: workflow.npmVerificationWindowMinutes * 60_000,
1430
1434
  giteaAssetTransfer: workflow.giteaAssetTransfer,
1435
+ giteaAssetConcurrency: workflow.giteaAssetConcurrency,
1431
1436
  gitRemotePolicy: branch.gitRemotePolicy,
1432
1437
  tsdocker,
1433
1438
  ensurePublicationState: ensureState,
@@ -1677,6 +1682,7 @@ const runReleaseResume = async (
1677
1682
  npmVerificationWindowMs:
1678
1683
  resumeConfiguration.npmVerificationWindowMinutes * 60_000,
1679
1684
  giteaAssetTransfer: resumeConfiguration.giteaAssetTransfer,
1685
+ giteaAssetConcurrency: resumeConfiguration.giteaAssetConcurrency,
1680
1686
  gitRemotePolicy: branchContext.gitRemotePolicy,
1681
1687
  tsdocker,
1682
1688
  ensurePublicationState,
@@ -1827,13 +1833,34 @@ function readReleaseLevelOverride(
1827
1833
  return undefined;
1828
1834
  }
1829
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
+
1830
1856
  async function runCommandStep(
1831
1857
  smartshellInstance: plugins.smartshell.Smartshell,
1832
1858
  cwdArg: string,
1833
1859
  label: string,
1834
1860
  command: string,
1835
1861
  ): Promise<void> {
1836
- console.log(`\n${label}`);
1862
+ printReleasePhase(label);
1863
+ const startedAt = Date.now();
1837
1864
  const result = await smartshellInstance.exec(command, { cwd: cwdArg });
1838
1865
  if (result.exitCode !== 0) {
1839
1866
  throw new Error(
@@ -1843,7 +1870,10 @@ async function runCommandStep(
1843
1870
  }),
1844
1871
  );
1845
1872
  }
1846
- logger.log("success", `${label} passed.`);
1873
+ logger.log(
1874
+ "success",
1875
+ `${label} passed in ${formatReleaseDuration(Date.now() - startedAt)}.`,
1876
+ );
1847
1877
  }
1848
1878
 
1849
1879
  async function verifyCleanTree(
@@ -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
  }