versionary 0.18.0 → 0.19.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.
@@ -36,6 +36,20 @@ function hasOriginRemote(cwd) {
36
36
  return false;
37
37
  }
38
38
  }
39
+ function getRemoteRefSha(cwd, ref) {
40
+ try {
41
+ const output = runGit(cwd, ["ls-remote", "origin", ref]);
42
+ const line = output.split("\n")[0]?.trim() ?? "";
43
+ if (!line) {
44
+ return null;
45
+ }
46
+ const sha = line.split(/\s+/u)[0]?.trim() ?? "";
47
+ return sha.length > 0 ? sha : null;
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
39
53
  function setOutput(name, value) {
40
54
  const outputPath = process.env.GITHUB_OUTPUT;
41
55
  if (!outputPath) {
@@ -77,6 +91,35 @@ function main() {
77
91
  `https://x-access-token:${encodedToken}@${base}/${repository}.git`,
78
92
  ]);
79
93
  }
94
+ const eventName = process.env.GITHUB_EVENT_NAME ?? "";
95
+ const ref = process.env.GITHUB_REF ?? "";
96
+ const sha = process.env.GITHUB_SHA?.trim() ?? "";
97
+ if (eventName === "push" &&
98
+ ref.startsWith("refs/heads/") &&
99
+ sha.length > 0 &&
100
+ hasOriginRemote(cwd)) {
101
+ const remoteSha = getRemoteRefSha(cwd, ref);
102
+ if (remoteSha && remoteSha !== sha) {
103
+ const staleMessage = `Skipping stale push run for ${sha.slice(0, 7)}; ` +
104
+ `${ref} now points to ${remoteSha.slice(0, 7)}.`;
105
+ const stalePayload = {
106
+ action: "stale-run-skipped",
107
+ message: staleMessage,
108
+ releaseCreated: false,
109
+ tagNames: [],
110
+ };
111
+ process.stdout.write(`${JSON.stringify(stalePayload)}\n`);
112
+ setOutput("action", stalePayload.action);
113
+ setOutput("message", stalePayload.message);
114
+ setOutput("release_created", "false");
115
+ setOutput("tag_name", "");
116
+ setOutput("tag_names", "[]");
117
+ setOutput("review_url", "");
118
+ setOutput("branch", "");
119
+ setOutput("title", "");
120
+ return;
121
+ }
122
+ }
80
123
  const raw = (0, node_child_process_1.execFileSync)("npx", ["--yes", `versionary@${versionaryVersion}`, "run", "--json"], {
81
124
  cwd,
82
125
  encoding: "utf8",
@@ -8,6 +8,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const BUILD_LUA_VERSION_PATTERN = /^(\s*version\s*=\s*")([^"]+)(")/mu;
10
10
  const PROVIDES_PACKAGE_PATTERN = /\\ProvidesPackage\{([^}]+)\}\[\d{4}-\d{2}-\d{2} v([0-9]+\.[0-9]+\.[0-9]+) ([^\]]+)\]/gu;
11
+ const PROVIDES_EXPL_PACKAGE_PATTERN = /\\ProvidesExplPackage\{([^}]+)\}\{\d{4}-\d{2}-\d{2}\}\{[^}]+\}\{([^}]*)\}/gu;
11
12
  function normalizeRelative(base, target) {
12
13
  return node_path_1.default.relative(base, target).replaceAll("\\", "/");
13
14
  }
@@ -37,9 +38,16 @@ function replaceBuildLuaVersion(content, version, versionFile) {
37
38
  return content.replace(BUILD_LUA_VERSION_PATTERN, `$1${version}$3`);
38
39
  }
39
40
  function replaceProvidesPackageMetadata(content, version, releaseDate, relativePath) {
40
- const matches = [...content.matchAll(PROVIDES_PACKAGE_PATTERN)];
41
+ const packageMatches = [...content.matchAll(PROVIDES_PACKAGE_PATTERN)];
42
+ const explPackageMatches = [
43
+ ...content.matchAll(PROVIDES_EXPL_PACKAGE_PATTERN),
44
+ ];
45
+ const matches = [...packageMatches, ...explPackageMatches];
41
46
  if (matches.length !== 1) {
42
- throw new Error(`${relativePath} must contain exactly one \\ProvidesPackage metadata entry; matched ${matches.length}.`);
47
+ throw new Error(`${relativePath} must contain exactly one \\ProvidesPackage or \\ProvidesExplPackage metadata entry; matched ${matches.length}.`);
48
+ }
49
+ if (explPackageMatches.length === 1) {
50
+ return content.replace(PROVIDES_EXPL_PACKAGE_PATTERN, (_full, pkg, desc) => `\\ProvidesExplPackage{${pkg}}{${releaseDate}}{${version}}{${desc}}`);
43
51
  }
44
52
  return content.replace(PROVIDES_PACKAGE_PATTERN, (_full, pkg, _prevVersion, desc) => `\\ProvidesPackage{${pkg}}[${releaseDate} v${version} ${desc}]`);
45
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "versionary",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Automatic release framework based on conventional commits and semantic versioning",
5
5
  "keywords": [
6
6
  "releasing",