versionary 1.7.0 → 1.8.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.
package/README.md CHANGED
@@ -68,6 +68,7 @@ The full documentation lives at <https://versionary.dev/>:
68
68
  - [GitHub Actions setup](https://versionary.dev/guide/github-actions)
69
69
  (including tokens and permissions)
70
70
  - [Release workflows](https://versionary.dev/guide/workflows)
71
+ - [Julia registration with Registrator and TagBot](https://versionary.dev/guide/julia)
71
72
  - [Monorepos](https://versionary.dev/guide/monorepos)
72
73
  - [Conventional Commits](https://versionary.dev/guide/conventional-commits)
73
74
  and [Versioning](https://versionary.dev/guide/versioning)
@@ -83,8 +84,9 @@ PR automation, and tags + SCM release metadata (e.g. GitHub Releases).
83
84
 
84
85
  Out of scope (intentional): publishing artifacts to language registries,
85
86
  replacing package-specific publish tooling, and external/user-provided plugin
86
- loading. Use your CI/CD platform for registry publishing, triggered from a
87
- created release/tag.
87
+ loading. Use your CI/CD platform for registry publishing, triggered from release
88
+ outputs or a created release/tag. External release mode supports registration
89
+ before tagging, including [Julia's Registrator and TagBot workflow](https://versionary.dev/guide/julia).
88
90
 
89
91
  ## Contributing
90
92
 
@@ -1,6 +1,7 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { appendFileSync, readFileSync } from "node:fs";
4
+ import { isReleaseCommitMessage } from "../release/commit.js";
4
5
  function getInput(name) {
5
6
  const canonical = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
6
7
  const underscoreAlias = canonical.replace(/-/g, "_");
@@ -48,10 +49,10 @@ function getRemoteRefSha(cwd, ref) {
48
49
  return null;
49
50
  }
50
51
  }
51
- function hasVersionaryReleaseMarker(cwd, sha) {
52
+ function isReleaseCommit(cwd, sha) {
52
53
  try {
53
54
  const message = runGit(cwd, ["show", "-s", "--format=%B", sha]);
54
- return /^Versionary-Release:\s*true$/imu.test(message);
55
+ return isReleaseCommitMessage(message);
55
56
  }
56
57
  catch {
57
58
  return false;
@@ -94,6 +95,7 @@ function skipRun(action, message) {
94
95
  setOutput("action", action);
95
96
  setOutput("message", message);
96
97
  setOutput("release_created", "false");
98
+ setOutput("release_ready", "false");
97
99
  setOutput("tag_name", "");
98
100
  setOutput("tag_names", "[]");
99
101
  setOutput("release_targets", "[]");
@@ -150,7 +152,7 @@ function main() {
150
152
  if (remoteSha && remoteSha !== sha) {
151
153
  // Descendant pushes must not turn an otherwise valid release into a
152
154
  // recovery cycle.
153
- const releaseCanPublish = hasVersionaryReleaseMarker(cwd, sha) && isAncestor(cwd, sha, remoteSha);
155
+ const releaseCanPublish = isReleaseCommit(cwd, sha) && isAncestor(cwd, sha, remoteSha);
154
156
  if (!releaseCanPublish) {
155
157
  skipRun("stale-run-skipped", `Skipping stale push run for ${sha.slice(0, 7)}; ` +
156
158
  `${ref} now points to ${remoteSha.slice(0, 7)}.`);
@@ -182,10 +184,11 @@ function main() {
182
184
  ? payload.tagNames.filter((value) => typeof value === "string")
183
185
  : [];
184
186
  const firstTag = tagNames[0] ?? "";
185
- const releaseCreated = payload.releaseCreated === true || tagNames.length > 0 ? "true" : "false";
187
+ const releaseCreated = (payload.releaseCreated ?? tagNames.length > 0) ? "true" : "false";
186
188
  setOutput("action", payload.action ?? "");
187
189
  setOutput("message", payload.message ?? "");
188
190
  setOutput("release_created", releaseCreated);
191
+ setOutput("release_ready", payload.action === "release-ready" ? "true" : "false");
189
192
  setOutput("tag_name", firstTag);
190
193
  setOutput("tag_names", JSON.stringify(tagNames));
191
194
  setOutput("release_targets", JSON.stringify(Array.isArray(payload.releaseTargets) ? payload.releaseTargets : []));
package/dist/cli/index.js CHANGED
@@ -9,7 +9,7 @@ import { prependChangelog, renderReleasePlanChangelog, } from "../release/change
9
9
  import { runDirectRelease } from "../release/direct.js";
10
10
  import { createReleasePlan } from "../release/plan.js";
11
11
  import { closeStaleReviewRequestIfExists, isReleaseCommitMessage, openOrUpdateReviewRequest, preparePendingReleasePr, preparePendingSeparateReleasePrs, prepareReleasePr, prepareSeparateReleasePrs, pushReleaseBranch, reconcileSeparateReviewRequests, resolveReleaseHighlights, } from "../release/pr.js";
12
- import { runRelease, runReleaseDetailed } from "../release/release.js";
12
+ import { runRelease, runReleaseDetailed, } from "../release/release.js";
13
13
  import { hasFullyUntaggedPendingRelease, hasReleaseStateChangeAtHead, readPendingReleaseTargets, } from "../release/state.js";
14
14
  import { verifyProject } from "../release/verify-project.js";
15
15
  function recordCommitOverride(command, args) {
@@ -97,6 +97,20 @@ function parseFlags(args) {
97
97
  function emitJson(payload) {
98
98
  process.stdout.write(`${JSON.stringify(payload)}\n`);
99
99
  }
100
+ function printExternalRelease(result, flags) {
101
+ if (flags.json) {
102
+ emitJson({
103
+ action: result.action,
104
+ message: result.message,
105
+ releaseCreated: false,
106
+ tagNames: [],
107
+ releaseTargets: result.releaseTargets,
108
+ });
109
+ }
110
+ else {
111
+ console.log(result.message);
112
+ }
113
+ }
100
114
  function reviewResultPayload(action, message, reviewRequests) {
101
115
  const primary = reviewRequests[0];
102
116
  return {
@@ -140,11 +154,39 @@ async function prepareCurrentSeparateReviewRequests(flags, logger) {
140
154
  }
141
155
  async function recoverPendingReleaseIfNeeded(flags, logger) {
142
156
  const cwd = process.cwd();
157
+ const loaded = loadConfig(cwd);
158
+ if (loaded.config["release-mode"] === "external") {
159
+ const result = await runReleaseDetailed(cwd, {
160
+ logger,
161
+ "dry-run": flags["dry-run"],
162
+ });
163
+ if (result.action === "release-ready" ||
164
+ result.action === "release-waiting") {
165
+ printExternalRelease(result, flags);
166
+ return true;
167
+ }
168
+ if (result.action === "release-dry-run") {
169
+ if (flags.json) {
170
+ emitJson({
171
+ action: result.action,
172
+ message: result.message,
173
+ releaseCreated: false,
174
+ tagNames: result.targets.map((target) => target.tag),
175
+ releaseTargets: result.releaseTargets,
176
+ targets: result.targets,
177
+ });
178
+ }
179
+ else {
180
+ console.log(result.message);
181
+ }
182
+ return true;
183
+ }
184
+ return false;
185
+ }
143
186
  if (!hasFullyUntaggedPendingRelease(cwd)) {
144
187
  return false;
145
188
  }
146
189
  const pendingTargets = readPendingReleaseTargets(cwd);
147
- const loaded = loadConfig(cwd);
148
190
  const releaseBranch = loaded.config["release-branch"] ?? "versionary/release";
149
191
  if (loaded.config["separate-release-prs"]) {
150
192
  const prepared = preparePendingSeparateReleasePrs(cwd, {
@@ -276,6 +318,11 @@ async function main() {
276
318
  logger,
277
319
  "dry-run": flags["dry-run"],
278
320
  });
321
+ if (release.action === "release-ready" ||
322
+ release.action === "release-waiting") {
323
+ printExternalRelease(release, flags);
324
+ return 0;
325
+ }
279
326
  if (release.action === "release-skipped") {
280
327
  if (flags.json) {
281
328
  emitJson({
@@ -6,6 +6,10 @@ export declare const configSchema: z.ZodObject<{
6
6
  direct: "direct";
7
7
  pr: "pr";
8
8
  }>>;
9
+ "release-mode": z.ZodOptional<z.ZodEnum<{
10
+ external: "external";
11
+ versionary: "versionary";
12
+ }>>;
9
13
  "version-file": z.ZodOptional<z.ZodString>;
10
14
  "changelog-file": z.ZodOptional<z.ZodString>;
11
15
  "changelog-format": z.ZodOptional<z.ZodEnum<{
@@ -109,6 +109,7 @@ export const configSchema = z
109
109
  $schema: z.string().optional(),
110
110
  version: z.literal(1),
111
111
  "review-mode": z.enum(["direct", "pr"]).optional(),
112
+ "release-mode": z.enum(["versionary", "external"]).optional(),
112
113
  "version-file": z.string().optional(),
113
114
  "changelog-file": z.string().optional(),
114
115
  "changelog-format": z.enum(["markdown-changelog", "r-news"]).optional(),
@@ -0,0 +1 @@
1
+ export declare function isReleaseCommitMessage(commitMessage: string): boolean;
@@ -0,0 +1,7 @@
1
+ export function isReleaseCommitMessage(commitMessage) {
2
+ if (/^Versionary-Release:\s*true$/imu.test(commitMessage)) {
3
+ return true;
4
+ }
5
+ const subject = commitMessage.split("\n")[0]?.trim() ?? "";
6
+ return /^chore\(release\):\s+(?:(?:v\d+\.\d+\.\d+|\S+-v\d+\.\d+\.\d+)(?:,\s+(?:v\d+\.\d+\.\d+|\S+-v\d+\.\d+\.\d+))*|(?:v\d+\.\d+\.\d+|\S+-v\d+\.\d+\.\d+)\s+\(\+\d+\s+more\))(?:\s+\(#\d+\))?$/u.test(subject);
7
+ }
@@ -3,7 +3,7 @@ import { loadConfig } from "../config/load-config.js";
3
3
  import { createReleasePlan } from "./plan.js";
4
4
  import { buildReleaseTargets, isReleaseCommitMessage, preparePendingReleasePr, prepareReleasePr, } from "./pr.js";
5
5
  import { runReleaseDetailed, } from "./release.js";
6
- import { hasFullyUntaggedPendingRelease, hasReleaseStateChangeAtHead, readPendingReleaseTargets, } from "./state.js";
6
+ import { hasFullyUntaggedPendingRelease, hasReleaseStateChangeAtHead, readExternalReleaseTargets, readPendingReleaseTargets, } from "./state.js";
7
7
  import { releaseTargetHandoff } from "./targets.js";
8
8
  function git(cwd, ...args) {
9
9
  return execFileSync("git", args, {
@@ -44,7 +44,13 @@ export async function runDirectRelease(cwd = process.cwd(), options = {}) {
44
44
  const releaseContext = isReleaseCommitMessage(git(cwd, "log", "-1", "--pretty=%B")) ||
45
45
  hasReleaseStateChangeAtHead(cwd);
46
46
  if (!releaseContext) {
47
- const pending = hasFullyUntaggedPendingRelease(cwd);
47
+ const external = loadConfig(cwd).config["release-mode"] === "external";
48
+ const pending = external
49
+ ? readExternalReleaseTargets(cwd).length > 0
50
+ : hasFullyUntaggedPendingRelease(cwd);
51
+ if (pending && external) {
52
+ return runReleaseDetailed(cwd, options);
53
+ }
48
54
  const plan = pending ? undefined : createReleasePlan(cwd);
49
55
  if (plan && !plan.nextVersion) {
50
56
  return {
@@ -58,7 +64,7 @@ export async function runDirectRelease(cwd = process.cwd(), options = {}) {
58
64
  : readPendingReleaseTargets(cwd);
59
65
  return {
60
66
  action: "release-dry-run",
61
- message: `Dry run: would ${pending ? "recover and publish" : "prepare and publish"} releases ${targets.map((target) => target.tag).join(", ")}`,
67
+ message: `Dry run: would ${external ? "prepare external" : pending ? "recover and publish" : "prepare and publish"} releases ${targets.map((target) => target.tag).join(", ")}`,
62
68
  targets: targets.map(({ tag, version }) => ({ tag, version })),
63
69
  releaseTargets: releaseTargetHandoff(targets, options.logger),
64
70
  };
@@ -118,4 +118,4 @@ export declare function closeStaleReviewRequestIfExists(cwd?: string, options?:
118
118
  number?: number;
119
119
  }>;
120
120
  export declare function pushReleaseBranch(cwd: string, branch: string): void;
121
- export declare function isReleaseCommitMessage(commitMessage: string): boolean;
121
+ export { isReleaseCommitMessage } from "./commit.js";
@@ -1010,10 +1010,4 @@ export function pushReleaseBranch(cwd, branch) {
1010
1010
  throw new Error(redactCredentials(message));
1011
1011
  }
1012
1012
  }
1013
- export function isReleaseCommitMessage(commitMessage) {
1014
- if (/^Versionary-Release:\s*true$/imu.test(commitMessage)) {
1015
- return true;
1016
- }
1017
- const subject = commitMessage.split("\n")[0]?.trim() ?? "";
1018
- return /^chore\(release\):\s+(?:(?:v\d+\.\d+\.\d+|\S+-v\d+\.\d+\.\d+)(?:,\s+(?:v\d+\.\d+\.\d+|\S+-v\d+\.\d+\.\d+))*|(?:v\d+\.\d+\.\d+|\S+-v\d+\.\d+\.\d+)\s+\(\+\d+\s+more\))(?:\s+\(#\d+\))?$/u.test(subject);
1019
- }
1013
+ export { isReleaseCommitMessage } from "./commit.js";
@@ -10,7 +10,7 @@ export declare function runRelease(cwd?: string): Promise<string>;
10
10
  export type RunReleaseResult = {
11
11
  action: "release-skipped";
12
12
  reason: string;
13
- } | {
13
+ } | ExternalReleaseResult | {
14
14
  action: "release-dry-run";
15
15
  message: string;
16
16
  targets: {
@@ -39,6 +39,21 @@ export type RunReleaseResult = {
39
39
  dependencies: string[];
40
40
  }[];
41
41
  };
42
+ export type ExternalReleaseResult = {
43
+ message: string;
44
+ releaseTargets: {
45
+ path: string;
46
+ tag: string;
47
+ version: string;
48
+ dependencies: string[];
49
+ sha: string;
50
+ notes: string;
51
+ }[];
52
+ } & ({
53
+ action: "release-ready";
54
+ } | {
55
+ action: "release-waiting";
56
+ });
42
57
  export interface RunReleaseOptions {
43
58
  logger?: VersionaryPluginContext["logger"];
44
59
  "dry-run"?: boolean;
@@ -8,7 +8,7 @@ import { resolveVersionStrategy } from "../strategy/resolve.js";
8
8
  import { getChangelogDefaults } from "./plan.js";
9
9
  import { isReleaseCommitMessage } from "./pr.js";
10
10
  import { executeIdempotentReleaseTarget } from "./recovery.js";
11
- import { hasReleaseStateChangeAtHead, readPendingReleaseTargets, readRecordedPendingReleaseTargets, } from "./state.js";
11
+ import { hasReleaseStateChangeAtHead, readExternalReleaseTargets, readPendingReleaseTargets, readRecordedPendingReleaseTargets, } from "./state.js";
12
12
  import { releaseTargetHandoff } from "./targets.js";
13
13
  function escapeRegExp(input) {
14
14
  return input.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
@@ -41,7 +41,7 @@ export function extractReleaseNotes(content, version, changelogFormat) {
41
41
  const shortMatch = new RegExp(`^#\\s+.+\\s+${escapeRegExp(shortVersion)}\\s*$`, "u");
42
42
  return fullMatch.test(line) || shortMatch.test(line);
43
43
  })
44
- : lines.findIndex((line) => line.startsWith(`## ${version} -`) ||
44
+ : lines.findIndex((line) => new RegExp(`^##\\s+${escapeRegExp(version)}(?:\\s|$)`, "u").test(line) ||
45
45
  line.startsWith(`## [${version}](`) ||
46
46
  line.startsWith(`# ${shortVersion} -`) ||
47
47
  line.startsWith(`# [${shortVersion}](`) ||
@@ -141,7 +141,56 @@ export async function runRelease(cwd = process.cwd()) {
141
141
  }
142
142
  return result.message;
143
143
  }
144
+ function describeExternalRelease(cwd, config, options) {
145
+ const targets = readExternalReleaseTargets(cwd);
146
+ if (targets.length === 0) {
147
+ return {
148
+ action: "release-skipped",
149
+ reason: "No untagged external release targets found.",
150
+ };
151
+ }
152
+ const head = execFileSync("git", ["rev-parse", "HEAD"], {
153
+ cwd,
154
+ encoding: "utf8",
155
+ }).trim();
156
+ const strategy = resolveVersionStrategy(config);
157
+ const { changelogFile } = getChangelogDefaults({
158
+ ...config,
159
+ defaultChangelogFormat: strategy.getDefaultChangelogFormat?.(),
160
+ });
161
+ const releaseTargets = releaseTargetHandoff(targets, options.logger).map((target) => {
162
+ const file = resolveTargetChangelogFile(config, changelogFile, target.path);
163
+ const content = execFileSync("git", ["show", `${target.sha}:${file}`], {
164
+ cwd,
165
+ encoding: "utf8",
166
+ stdio: ["ignore", "pipe", "pipe"],
167
+ });
168
+ const notes = extractReleaseNotes(content, target.version, resolveTargetChangelogFormat(config, target.path));
169
+ if (!notes) {
170
+ throw new Error(`No release notes for ${target.tag} in ${file} at ${target.sha}. Correct the release PR before handing it to external tooling.`);
171
+ }
172
+ return { ...target, notes };
173
+ });
174
+ const ready = targets.some((target) => target.sha === head);
175
+ if (options["dry-run"]) {
176
+ return {
177
+ action: "release-dry-run",
178
+ message: `Dry run: would hand off external releases ${targets.map((target) => target.tag).join(", ")}`,
179
+ targets: targets.map(({ tag, version }) => ({ tag, version })),
180
+ releaseTargets,
181
+ };
182
+ }
183
+ return {
184
+ action: ready ? "release-ready" : "release-waiting",
185
+ message: `${ready ? "Ready for external release" : "Waiting for external release"}: ${targets.map((target) => target.tag).join(", ")}`,
186
+ releaseTargets,
187
+ };
188
+ }
144
189
  export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
190
+ const loaded = loadConfig(cwd);
191
+ if (loaded.config["release-mode"] === "external") {
192
+ return describeExternalRelease(cwd, loaded.config, options);
193
+ }
145
194
  const commitMessage = getHeadCommitMessage(cwd);
146
195
  if (!isReleaseCommitMessage(commitMessage) &&
147
196
  !hasReleaseStateChangeAtHead(cwd)) {
@@ -150,7 +199,6 @@ export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
150
199
  reason: "No release commit context detected; skipping release stage.",
151
200
  };
152
201
  }
153
- const loaded = loadConfig(cwd);
154
202
  const strategy = resolveVersionStrategy(loaded.config);
155
203
  const { changelogFile } = getChangelogDefaults({
156
204
  ...loaded.config,
@@ -13,6 +13,9 @@ export declare function getPackageStateDirectory(cwd: string): string;
13
13
  export declare function readBaselineSha(cwd?: string): string | null;
14
14
  export declare function readReleaseTargets(cwd?: string): ReleaseTargetState[];
15
15
  export declare function readPendingReleaseTargets(cwd?: string): ReleaseTargetState[];
16
+ export declare function readExternalReleaseTargets(cwd?: string): (ReleaseTargetState & {
17
+ sha: string;
18
+ })[];
16
19
  export declare function readRecordedPendingReleaseTargets(cwd?: string): ReleaseTargetState[];
17
20
  export declare function readPendingReleaseCohorts(cwd?: string): PendingReleaseCohort[];
18
21
  /**
@@ -140,6 +140,61 @@ export function readPendingReleaseTargets(cwd = process.cwd()) {
140
140
  allowPartiallyTagged: true,
141
141
  }).flatMap((cohort) => cohort.targets);
142
142
  }
143
+ export function readExternalReleaseTargets(cwd = process.cwd()) {
144
+ return readPendingReleaseTargets(cwd)
145
+ .filter((target) => !hasLocalTag(cwd, target.tag))
146
+ .map((target) => {
147
+ const sidecar = path.join(getPackageStateDirectory(cwd), packageStateFileName(target.path));
148
+ const statePath = fs.existsSync(sidecar)
149
+ ? sidecar
150
+ : getBaselineStatePath(cwd);
151
+ const relativePath = path.relative(cwd, statePath);
152
+ const identity = (raw) => {
153
+ const state = fs.existsSync(sidecar)
154
+ ? parsePackageStateFile(raw, statePath)
155
+ : parseStateFile(raw, statePath);
156
+ const recorded = "release-target" in state
157
+ ? state["release-target"]
158
+ : state[PENDING_RELEASE_TARGETS_KEY]?.find((entry) => entry.path === target.path);
159
+ return recorded
160
+ ? JSON.stringify([
161
+ state[BASELINE_SHA_KEY],
162
+ recorded.path,
163
+ recorded.version,
164
+ recorded.tag,
165
+ ])
166
+ : null;
167
+ };
168
+ const expected = identity(fs.readFileSync(statePath, "utf8"));
169
+ // Walk the current intent back to its introduction on trunk. Formatting
170
+ // release state after merging must not move an in-flight registration.
171
+ const commits = execFileSync("git", ["log", "--first-parent", "--format=%H", "--", relativePath], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] })
172
+ .trim()
173
+ .split("\n")
174
+ .filter(Boolean);
175
+ let sha = "";
176
+ for (const commit of commits) {
177
+ let raw;
178
+ try {
179
+ raw = execFileSync("git", ["show", `${commit}:${relativePath}`], {
180
+ cwd,
181
+ encoding: "utf8",
182
+ stdio: ["ignore", "pipe", "pipe"],
183
+ });
184
+ }
185
+ catch {
186
+ break;
187
+ }
188
+ if (identity(raw) !== expected)
189
+ break;
190
+ sha = commit;
191
+ }
192
+ if (!sha) {
193
+ throw new Error(`External release ${target.tag} requires committed release state. Merge the release PR before requesting registration.`);
194
+ }
195
+ return { ...target, sha };
196
+ });
197
+ }
143
198
  // Every target the release state records, including cohorts whose tags already
144
199
  // exist. `release` needs these to tell "this repo never recorded a release"
145
200
  // apart from "this release was already published"; only the former may fall
@@ -157,38 +212,58 @@ function collectPendingReleaseCohorts(cwd, options) {
157
212
  const filePath = getBaselineStatePath(cwd);
158
213
  const packageStates = readPackageStates(cwd);
159
214
  const sidecarPaths = new Set(packageStates.map((state) => state.path));
215
+ // A branch can be reused after only part of its original package set changes.
216
+ // The baseline separates completed releases from the next release on it.
160
217
  const byBranch = new Map();
218
+ const addTargets = (branch, baselineSha, targets) => {
219
+ const byBaseline = byBranch.get(branch) ??
220
+ new Map();
221
+ byBaseline.set(baselineSha, [
222
+ ...(byBaseline.get(baselineSha) ?? []),
223
+ ...targets,
224
+ ]);
225
+ byBranch.set(branch, byBaseline);
226
+ };
161
227
  for (const state of packageStates) {
162
- const targets = byBranch.get(state["release-branch"]) ?? [];
163
- targets.push(state["release-target"]);
164
- byBranch.set(state["release-branch"], targets);
228
+ addTargets(state["release-branch"], state[BASELINE_SHA_KEY], [
229
+ state["release-target"],
230
+ ]);
165
231
  }
166
232
  if (fs.existsSync(filePath)) {
167
233
  const parsed = parseStateFile(fs.readFileSync(filePath, "utf8"), filePath);
168
234
  const legacyPending = (parsed[PENDING_RELEASE_TARGETS_KEY] ?? []).filter((target) => !sidecarPaths.has(target.path));
169
235
  if (legacyPending.length > 0) {
170
236
  const branch = loadConfig(cwd).config["release-branch"] ?? "versionary/release";
171
- byBranch.set(branch, [...(byBranch.get(branch) ?? []), ...legacyPending]);
237
+ addTargets(branch, parsed[BASELINE_SHA_KEY], legacyPending);
172
238
  }
173
239
  }
174
240
  const pending = [];
175
- for (const [branch, unsortedTargets] of byBranch) {
176
- const targets = [...unsortedTargets].sort((a, b) => a.path.localeCompare(b.path));
177
- const tagged = targets.filter((target) => hasLocalTag(cwd, target.tag));
178
- if (tagged.length === targets.length && !options.includeFullyTagged) {
179
- continue;
241
+ for (const [branch, byBaseline] of byBranch) {
242
+ const targets = [];
243
+ for (const cohortTargets of byBaseline.values()) {
244
+ const tagged = cohortTargets.filter((target) => hasLocalTag(cwd, target.tag));
245
+ if (tagged.length === cohortTargets.length &&
246
+ !options.includeFullyTagged) {
247
+ continue;
248
+ }
249
+ if (tagged.length > 0 &&
250
+ tagged.length < cohortTargets.length &&
251
+ !options.allowPartiallyTagged) {
252
+ const existingTags = tagged.map((target) => target.tag).join(", ");
253
+ const missingTags = cohortTargets
254
+ .filter((target) => !tagged.includes(target))
255
+ .map((target) => target.tag)
256
+ .join(", ");
257
+ throw new Error(`Pending release cohort on ${branch} is partially tagged and cannot move safely. Existing tags: ${existingTags}. Missing tags: ${missingTags}. Rerun the original release workflow to complete it.`);
258
+ }
259
+ targets.push(...cohortTargets);
180
260
  }
181
- if (tagged.length > 0 &&
182
- tagged.length < targets.length &&
183
- !options.allowPartiallyTagged) {
184
- const existingTags = tagged.map((target) => target.tag).join(", ");
185
- const missingTags = targets
186
- .filter((target) => !tagged.includes(target))
187
- .map((target) => target.tag)
188
- .join(", ");
189
- throw new Error(`Pending release cohort on ${branch} is partially tagged and cannot move safely. Existing tags: ${existingTags}. Missing tags: ${missingTags}. Rerun the original release workflow to complete it.`);
261
+ if (targets.length > 0) {
262
+ pending.push({
263
+ branch,
264
+ targets: targets.sort((a, b) => a.path.localeCompare(b.path)),
265
+ });
190
266
  }
191
- pending.push({ branch, targets });
192
267
  }
193
268
  return pending.sort((a, b) => a.branch.localeCompare(b.branch));
194
269
  }
@@ -1,6 +1,6 @@
1
1
  import type { ReleaseTargetState } from "./state.js";
2
- export interface ReleaseTargetOrder {
3
- ordered: ReleaseTargetState[];
2
+ export interface ReleaseTargetOrder<T extends ReleaseTargetState = ReleaseTargetState> {
3
+ ordered: T[];
4
4
  cyclicPaths: string[];
5
5
  }
6
6
  /**
@@ -13,9 +13,9 @@ export interface ReleaseTargetOrder {
13
13
  * degrading it must not block tagging; callers surface `cyclicPaths` so the
14
14
  * cycle still gets reported.
15
15
  */
16
- export declare function orderReleaseTargets(targets: readonly ReleaseTargetState[]): ReleaseTargetOrder;
17
- export declare function releaseTargetHandoff(targets: readonly ReleaseTargetState[], logger?: {
16
+ export declare function orderReleaseTargets<T extends ReleaseTargetState>(targets: readonly T[]): ReleaseTargetOrder<T>;
17
+ export declare function releaseTargetHandoff<T extends ReleaseTargetState>(targets: readonly T[], logger?: {
18
18
  warn: (message: string) => void;
19
- }): Array<ReleaseTargetState & {
19
+ }): Array<T & {
20
20
  dependencies: string[];
21
21
  }>;
@@ -200,15 +200,16 @@ function packageNameFromParsed(parsed) {
200
200
  function normalizeModuleName(name) {
201
201
  return name.replace(/[-.]+/gu, "_");
202
202
  }
203
- function findAuxiliaryInitPy(cwd, parsed) {
203
+ function findAuxiliaryInitPy(cwd, parsed, versionFile) {
204
204
  const packageName = packageNameFromParsed(parsed);
205
205
  if (!packageName) {
206
206
  return null;
207
207
  }
208
208
  const moduleName = normalizeModuleName(packageName);
209
+ const packageDirectory = path.dirname(versionFile);
209
210
  const candidates = [
210
- path.join("src", moduleName, "__init__.py"),
211
- path.join(moduleName, "__init__.py"),
211
+ path.join(packageDirectory, "src", moduleName, "__init__.py"),
212
+ path.join(packageDirectory, moduleName, "__init__.py"),
212
213
  ];
213
214
  for (const candidate of candidates) {
214
215
  const absolute = path.join(cwd, candidate);
@@ -305,7 +306,7 @@ export const pythonVersionStrategy = {
305
306
  fs.writeFileSync(versionPath, updated, "utf8");
306
307
  written.push(versionFile);
307
308
  const parsed = parsePyProject(updated, versionFile);
308
- const initPy = findAuxiliaryInitPy(cwd, parsed);
309
+ const initPy = findAuxiliaryInitPy(cwd, parsed, versionFile);
309
310
  if (initPy && tryUpdateInitPyVersion(cwd, initPy, version)) {
310
311
  written.push(initPy);
311
312
  }
@@ -124,14 +124,15 @@ function ensureCargoLockUpToDate(cwd) {
124
124
  const lockfilePath = path.join(cwd, lockfile);
125
125
  const before = fs.readFileSync(lockfilePath, "utf8");
126
126
  try {
127
- execFileSync("cargo", ["generate-lockfile"], {
127
+ // Preserve locked external dependencies while updating local package versions.
128
+ execFileSync("cargo", ["update", "--workspace"], {
128
129
  cwd: path.dirname(lockfilePath),
129
130
  stdio: ["ignore", "pipe", "pipe"],
130
131
  });
131
132
  }
132
133
  catch (error) {
133
134
  const message = error instanceof Error ? error.message : String(error);
134
- throw new Error(`Failed to refresh ${lockfile} via "cargo generate-lockfile". Ensure cargo is installed and available in PATH. Details: ${message}`);
135
+ throw new Error(`Failed to refresh ${lockfile} via "cargo update --workspace". Ensure cargo is installed and available in PATH. Details: ${message}`);
135
136
  }
136
137
  const after = fs.readFileSync(lockfilePath, "utf8");
137
138
  if (after !== before) {
@@ -35,6 +35,7 @@ export interface VersionaryPackage {
35
35
  export interface VersionaryConfig {
36
36
  version: 1;
37
37
  "review-mode"?: "direct" | "pr";
38
+ "release-mode"?: "versionary" | "external";
38
39
  "version-file"?: string;
39
40
  "changelog-file"?: string;
40
41
  "changelog-format"?: VersionaryChangelogFormat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "versionary",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Automatic release framework based on conventional commits and semantic versioning",
5
5
  "keywords": [
6
6
  "releasing",