versionary 1.1.0 → 1.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.
@@ -48,6 +48,24 @@ function getRemoteRefSha(cwd, ref) {
48
48
  return null;
49
49
  }
50
50
  }
51
+ function hasVersionaryReleaseMarker(cwd, sha) {
52
+ try {
53
+ const message = runGit(cwd, ["show", "-s", "--format=%B", sha]);
54
+ return /^Versionary-Release:\s*true$/imu.test(message);
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ }
60
+ function isAncestor(cwd, ancestor, descendant) {
61
+ try {
62
+ runGit(cwd, ["merge-base", "--is-ancestor", ancestor, descendant]);
63
+ return true;
64
+ }
65
+ catch {
66
+ return false;
67
+ }
68
+ }
51
69
  function setOutput(name, value) {
52
70
  const outputPath = process.env.GITHUB_OUTPUT;
53
71
  if (!outputPath) {
@@ -98,26 +116,31 @@ function main() {
98
116
  hasOriginRemote(cwd)) {
99
117
  const remoteSha = getRemoteRefSha(cwd, ref);
100
118
  if (remoteSha && remoteSha !== sha) {
101
- const staleMessage = `Skipping stale push run for ${sha.slice(0, 7)}; ` +
102
- `${ref} now points to ${remoteSha.slice(0, 7)}.`;
103
- const stalePayload = {
104
- action: "stale-run-skipped",
105
- message: staleMessage,
106
- releaseCreated: false,
107
- tagNames: [],
108
- };
109
- process.stdout.write(`${JSON.stringify(stalePayload)}\n`);
110
- setOutput("action", stalePayload.action);
111
- setOutput("message", stalePayload.message);
112
- setOutput("release_created", "false");
113
- setOutput("tag_name", "");
114
- setOutput("tag_names", "[]");
115
- setOutput("release_targets", "[]");
116
- setOutput("review_url", "");
117
- setOutput("review_requests", "[]");
118
- setOutput("branch", "");
119
- setOutput("title", "");
120
- return;
119
+ // Descendant pushes must not turn an otherwise valid release into a
120
+ // recovery cycle.
121
+ const releaseCanPublish = hasVersionaryReleaseMarker(cwd, sha) && isAncestor(cwd, sha, remoteSha);
122
+ if (!releaseCanPublish) {
123
+ const staleMessage = `Skipping stale push run for ${sha.slice(0, 7)}; ` +
124
+ `${ref} now points to ${remoteSha.slice(0, 7)}.`;
125
+ const stalePayload = {
126
+ action: "stale-run-skipped",
127
+ message: staleMessage,
128
+ releaseCreated: false,
129
+ tagNames: [],
130
+ };
131
+ process.stdout.write(`${JSON.stringify(stalePayload)}\n`);
132
+ setOutput("action", stalePayload.action);
133
+ setOutput("message", stalePayload.message);
134
+ setOutput("release_created", "false");
135
+ setOutput("tag_name", "");
136
+ setOutput("tag_names", "[]");
137
+ setOutput("release_targets", "[]");
138
+ setOutput("review_url", "");
139
+ setOutput("review_requests", "[]");
140
+ setOutput("branch", "");
141
+ setOutput("title", "");
142
+ return;
143
+ }
121
144
  }
122
145
  }
123
146
  const raw = execFileSync("npx", ["--yes", `versionary@${versionaryVersion}`, "run", "--json"], {
@@ -291,7 +291,6 @@ export function prependChangelog(cwd, changelogFile, section, format = "markdown
291
291
  export function renderRNewsReleaseNotes(input) {
292
292
  const repoUrl = resolveRepositoryWebBaseUrl(input.cwd ?? process.cwd());
293
293
  const grouped = groupCommitLines(input.commits, repoUrl);
294
- const normalizedVersion = input.nextVersion.replace(/\.\d+$/u, "");
295
294
  const sections = [];
296
295
  const trimmedHighlights = input.highlights?.trim() ?? "";
297
296
  if (trimmedHighlights.length > 0) {
@@ -315,7 +314,7 @@ export function renderRNewsReleaseNotes(input) {
315
314
  if (needsOtherChangesFallback(grouped, trimmedHighlights.length > 0, 0)) {
316
315
  sections.push("## Other changes", "", ...grouped.other, "");
317
316
  }
318
- return [`# ${input.packageName} ${normalizedVersion}`, "", ...sections]
317
+ return [`# ${input.packageName} ${input.nextVersion}`, "", ...sections]
319
318
  .join("\n")
320
319
  .trimEnd();
321
320
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "versionary",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Automatic release framework based on conventional commits and semantic versioning",
5
5
  "keywords": [
6
6
  "releasing",