rylease 3.1.0 → 3.2.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.
@@ -389,9 +389,9 @@ function inComponent(env, component, path) {
389
389
  * Resolves globs, relative to `cwd` unless absolute, to the absolute paths of
390
390
  * the files they match, sorted; a directory stands for every file in it.
391
391
  * Every pattern must match something, so a typo fails instead of uploading
392
- * nothing.
392
+ * nothing, unless `allowNoMatch` is set, as for files only some runs build.
393
393
  */
394
- async function resolveFiles(cwd, patterns) {
394
+ async function resolveFiles(cwd, patterns, { allowNoMatch = false } = {}) {
395
395
  const files = /* @__PURE__ */ new Set();
396
396
  for (const pattern of patterns) {
397
397
  const normalized = pattern.replaceAll("\\", "/");
@@ -403,7 +403,7 @@ async function resolveFiles(cwd, patterns) {
403
403
  matched = true;
404
404
  }
405
405
  }
406
- if (!matched) throw new Error(`no files match '${pattern}'`);
406
+ if (!matched && !allowNoMatch) throw new Error(`no files match '${pattern}'`);
407
407
  }
408
408
  return [...files].sort();
409
409
  }
@@ -3506,13 +3506,14 @@ const dotnetPublish = defineStep({
3506
3506
  description: "Pushes the component's packed `.nupkg` packages of the release's version to nuget.org, or another source, with `dotnet nuget push`.",
3507
3507
  options: {
3508
3508
  files: z.union([z.string(), z.array(z.string()).min(1)]).default("**/*.nupkg").describe("Globs of the packages, relative to the component's directory; those of other versions, and symbol packages, are left out."),
3509
+ allowNoMatch: z.boolean().default(false).describe("Push nothing, instead of failing, when there are no packages of the version, e.g. in a job that doesn't pack them."),
3509
3510
  source: z.string().default(NUGET),
3510
3511
  token: z.string().optional().describe("The API key; defaults to `NUGET_API_KEY`. Without one, the source's credentials in NuGet's config are used.")
3511
3512
  },
3512
3513
  run: async ({ env, component, version, options }) => {
3513
3514
  const dir = inComponent(env, component, ".").file;
3514
3515
  const patterns = [options.files].flat();
3515
- const all = (await resolveFiles(dir, patterns).catch((error) => {
3516
+ const all = (await resolveFiles(dir, patterns, { allowNoMatch: options.allowNoMatch }).catch((error) => {
3516
3517
  if (env.dryRun) return [];
3517
3518
  throw error;
3518
3519
  })).filter((file) => file.endsWith(".nupkg") && !file.endsWith(".symbols.nupkg"));
@@ -3526,6 +3527,14 @@ const dotnetPublish = defineStep({
3526
3527
  },
3527
3528
  reason: `would push the packages of ${nugetVersion(version)} in ${patterns.join(", ")} to ${options.source}, once packed`
3528
3529
  };
3530
+ if (files.length === 0 && options.allowNoMatch) return {
3531
+ output: {
3532
+ files: [],
3533
+ source: options.source,
3534
+ published: false
3535
+ },
3536
+ reason: `no packages of ${nugetVersion(version)} in ${patterns.join(", ")}; pushed nothing`
3537
+ };
3529
3538
  if (files.length === 0) throw new Error(`no packages of ${nugetVersion(version)} in ${patterns.join(", ")}; pack them first`);
3530
3539
  const shown = files.map((file) => relative(env.cwd, file).replaceAll("\\", "/"));
3531
3540
  const target = `${joinList(shown)} to ${options.source}`;
@@ -3828,6 +3837,7 @@ const fsWriteVersion = defineStep({
3828
3837
  options: {
3829
3838
  format: z.enum(FORMAT_NAMES).default("plain").describe("`plain` (the whole file), `npm`, `cargo`, `python`, `dart`, `ruby`, `dotnet`, `helm`, `gradle`, `maven`, or `pattern`."),
3830
3839
  path: z.union([z.string(), z.array(z.string()).min(1)]).optional().describe("Relative to each component's directory; globs, or a list, write several, e.g. `packages/*/package.json` for packages sharing a version. Defaults to the format's file."),
3840
+ allowNoMatch: z.boolean().default(false).describe("Skip globs that match no files instead of failing; with none matched, write nothing. Not for the `plain` format, which creates its file."),
3831
3841
  pattern: z.string().optional().describe("With the `pattern` format, where the version is, e.g. `__version__ = \"{version}\"`.")
3832
3842
  },
3833
3843
  needs: (options) => versionFormat(options.format, options.pattern ?? "{version}").needs ?? [],
@@ -3840,7 +3850,7 @@ const fsWriteVersion = defineStep({
3840
3850
  }
3841
3851
  const files = (await Promise.all(components.map(async ({ component, version }) => {
3842
3852
  const dir = inComponent(env, component, ".").file;
3843
- const found = options.format === "plain" ? patterns.map((pattern) => inComponent(env, component, pattern).file) : await resolveFiles(dir, patterns);
3853
+ const found = options.format === "plain" ? patterns.map((pattern) => inComponent(env, component, pattern).file) : await resolveFiles(dir, patterns, { allowNoMatch: options.allowNoMatch });
3844
3854
  return Promise.all(found.map(async (file) => ({
3845
3855
  file,
3846
3856
  version,
@@ -3872,6 +3882,11 @@ const fsWriteVersion = defineStep({
3872
3882
  dependencies: result.dependencies
3873
3883
  });
3874
3884
  }
3885
+ if (written.length === 0) return {
3886
+ output: { written: [] },
3887
+ files: [],
3888
+ reason: `no files match ${patterns.join(", ")}; wrote nothing`
3889
+ };
3875
3890
  const described = joinList(written.map(({ path, version, dependencies }) => `${version} to ${path}${dependencies.length > 0 ? ` (and ${joinList(dependencies)})` : ""}`));
3876
3891
  return {
3877
3892
  output: { written: env.dryRun ? [] : written },
@@ -4333,13 +4348,22 @@ const githubUploadArtifact = defineStep({
4333
4348
  description: "Uploads files as a workflow artifact. Only works in the GitHub Action.",
4334
4349
  options: {
4335
4350
  name: z.string().describe("The artifact's name, unique in the run; `{version}`, `{tag}` and the other placeholders are filled in."),
4336
- files: z.array(z.string()).min(1).describe("Paths, globs or directories, relative to the component's directory unless absolute; each must match."),
4351
+ files: z.array(z.string()).min(1).describe("Paths, globs or directories, relative to the component's directory unless absolute; each must match, unless `allowNoMatch`."),
4352
+ allowNoMatch: z.boolean().default(false).describe("Skip patterns that match no files instead of failing; with none matched, upload nothing."),
4337
4353
  dryRunArtifact: z.boolean().default(false).describe("Upload in dry runs too."),
4338
4354
  retentionDays: z.number().int().min(1).optional().describe("Defaults to the repository's setting.")
4339
4355
  },
4340
4356
  run: async ({ env, component, placeholders, options }) => {
4341
4357
  const name = fill(options.name, placeholders);
4342
- const files = await resolveFiles(inComponent(env, component, ".").file, options.files);
4358
+ const files = await resolveFiles(inComponent(env, component, ".").file, options.files, { allowNoMatch: options.allowNoMatch });
4359
+ if (files.length === 0) return {
4360
+ output: {
4361
+ name,
4362
+ id: null,
4363
+ files: []
4364
+ },
4365
+ reason: `no files match ${options.files.join(", ")}; uploaded nothing`
4366
+ };
4343
4367
  const listed = `${plural(files.length, "file")} as artifact ${name}`;
4344
4368
  if (env.dryRun && !(options.dryRunArtifact && canUploadArtifacts())) return {
4345
4369
  output: {
@@ -4372,7 +4396,8 @@ const githubUploadReleaseAssets = defineStep({
4372
4396
  name: "github/upload-release-assets",
4373
4397
  description: "Uploads files to the GitHub release, creating it (with the notes) if no other job has yet.",
4374
4398
  options: {
4375
- files: z.array(z.string()).min(1).describe("Paths or globs, relative to the component's directory unless absolute; each must match."),
4399
+ files: z.array(z.string()).min(1).describe("Paths or globs, relative to the component's directory unless absolute; each must match, unless `allowNoMatch`."),
4400
+ allowNoMatch: z.boolean().default(false).describe("Skip patterns that match no files instead of failing; with none matched, upload nothing, and leave the release to other steps."),
4376
4401
  clobber: z.boolean().default(true).describe("Replace assets of the same name."),
4377
4402
  dryRunArtifact: z.boolean().default(false).describe("In dry runs, keep the files as a workflow artifact instead; only in the GitHub Action."),
4378
4403
  artifactName: z.string().optional().describe("Unique in the run; `{version}`, `{tag}` and the other placeholders are filled in. Defaults to the asset's name, or for several, a name made from theirs."),
@@ -4381,7 +4406,16 @@ const githubUploadReleaseAssets = defineStep({
4381
4406
  run: async ({ env, component, tag, placeholders, notes, options }) => {
4382
4407
  const title = fill(options.title, placeholders);
4383
4408
  const repo = await releaseRepo(env.cwd, options.repo);
4384
- const files = await resolveFiles(inComponent(env, component, ".").file, options.files);
4409
+ const files = await resolveFiles(inComponent(env, component, ".").file, options.files, { allowNoMatch: options.allowNoMatch });
4410
+ if (files.length === 0) return {
4411
+ output: {
4412
+ repo,
4413
+ tag,
4414
+ url: null,
4415
+ assets: []
4416
+ },
4417
+ reason: `no files match ${options.files.join(", ")}; uploaded nothing`
4418
+ };
4385
4419
  const sizes = await Promise.all(files.map(async (file) => (await stat(file)).size));
4386
4420
  const listed = files.map((file, index) => `${assetName(basename(file))} (${formatSize(sizes[index] ?? 0)})`);
4387
4421
  if (env.dryRun) {
@@ -4951,6 +4985,7 @@ const pythonPublish = defineStep({
4951
4985
  description: "Uploads the component's built wheels and sdists of the release's version to PyPI, or another index, with `uv publish` or `twine upload`.",
4952
4986
  options: {
4953
4987
  files: z.union([z.string(), z.array(z.string()).min(1)]).default("dist/*").describe("Globs of the distributions, relative to the component's directory; those of other versions are left out."),
4988
+ allowNoMatch: z.boolean().default(false).describe("Publish nothing, instead of failing, when there are no distributions of the version, e.g. in a job that doesn't build them."),
4954
4989
  client: z.enum(["uv", "twine"]).default("uv"),
4955
4990
  registry: z.string().default(PYPI).describe("The index's upload URL."),
4956
4991
  token: z.string().optional().describe("Defaults to `PYPI_TOKEN`; without one, the client's own auth is used, e.g. `uv`'s trusted publishing.")
@@ -4958,7 +4993,7 @@ const pythonPublish = defineStep({
4958
4993
  run: async ({ env, component, version, options }) => {
4959
4994
  const dir = inComponent(env, component, ".").file;
4960
4995
  const patterns = [options.files].flat();
4961
- const all = await resolveFiles(dir, patterns).catch((error) => {
4996
+ const all = await resolveFiles(dir, patterns, { allowNoMatch: options.allowNoMatch }).catch((error) => {
4962
4997
  if (env.dryRun) return [];
4963
4998
  throw error;
4964
4999
  });
@@ -4978,6 +5013,16 @@ const pythonPublish = defineStep({
4978
5013
  },
4979
5014
  reason: `would ${options.client} upload the distributions of ${wanted} in ${patterns.join(", ")} to ${options.registry}, once built`
4980
5015
  };
5016
+ if (files.length === 0 && options.allowNoMatch) return {
5017
+ output: {
5018
+ version: wanted,
5019
+ files: [],
5020
+ client: options.client,
5021
+ registry: options.registry,
5022
+ published: false
5023
+ },
5024
+ reason: `no distributions of ${wanted} in ${patterns.join(", ")}; published nothing`
5025
+ };
4981
5026
  if (files.length === 0) {
4982
5027
  const others = all.map(distVersion).filter((found) => found);
4983
5028
  throw new Error(`no distributions of ${wanted} in ${patterns.join(", ")}${others.length > 0 ? `, only of ${joinList([...new Set(others)])}` : ""}; build them first`);
@@ -5710,4 +5755,4 @@ function cell(text) {
5710
5755
  //#endregion
5711
5756
  export { tryGit as A, KINDS as C, prettyReporter as D, formatDuration as E, joinPath as F, parseOptions as I, z as L, defineComponents as M, resolveComponents as N, detectRepo as O, OptionsError as P, sortSteps as S, defaultReporter as T, defineStep as _, presets_exports as a, errorMessage as b, defineScheme as c, histories_exports as d, defineHistory as f, defineRelease as g, definePreset as h, resolveWorkflowSteps as i, components_exports as j, git as k, formatChangeFile as l, expressionContext as m, markdownSummary as n, schemes_exports as o, compileExpression as p, resolveWorkflow as r, steps_exports as s, markdownProblems as t, slug as u, when as v, PHASES as w, runRelease as x, ReleaseError as y };
5712
5757
 
5713
- //# sourceMappingURL=src-BkALSGzm.mjs.map
5758
+ //# sourceMappingURL=src-dp4Eayux.mjs.map