Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ jobs:
}
const registry = "https://registry.npmjs.org";

const prereleaseId = version.match(
/^[^-]+-([0-9A-Za-z-]+)(?:[.+]|$)/,
)?.[1];
let npmTag = "latest";
if (prereleaseId === "alpha" || prereleaseId === "rc") {
npmTag = prereleaseId;
} else if (prereleaseId) {
npmTag = "next";
}

console.log(`Publishing ${version} with npm dist-tag ${npmTag}.`);

Comment on lines +63 to +74

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== release workflow relevant section =="
sed -n '1,90p' .github/workflows/release.yml
sed -n '190,225p' .github/workflows/release.yml

echo
echo "== changed lines via git diff, if available =="
git diff -- .github/workflows/release.yml | sed -n '1,180p' || true

echo
echo "== programmatic regex behavior =="
node - <<'JS'
const versions = [
  "1.0.0+build-alpha",
  "1.0.0-alpha.1",
  "1.0.0-rc.1",
  "1.0.0-alpha+build.1",
  "1.0.0-beta+build-alpha",
];
for (const version of versions) {
  const prereleaseId = version.match(/^[^-]+-([0-9A-Za-z-]+)(?:[.+]|$)/)?.[1];
  let npmTag = "latest";
  if (prereleaseId === "alpha" || prereleaseId === "rc") {
    npmTag = prereleaseId;
  } else if (prereleaseId) {
    npmTag = "next";
  }
  console.log(`${version} => prereleaseId=["${prereleaseId}"] npmTag=${npmTag}`);
}
console.log("fixed behavior:");
for (const version of versions) {
  const prereleaseId = version.match(/^[^-+]+-([0-9A-Za-z-]+)(?:[.+]|$)/)?.[1];
  let npmTag = "latest";
  if (prereleaseId === "alpha" || prereleaseId === "rc") {
    npmTag = prereleaseId;
  } else if (prereleaseId) {
    npmTag = "next";
  }
  console.log(`${version} => prereleaseId=["${prereleaseId}"] npmTag=${npmTag}`);
}
JS

Repository: afx-team/evjs

Length of output: 4722


Exclude build metadata when selecting the npm dist-tag.

1.0.0+build-alpha is a stable SemVer version, but the current regex matches alpha and publishes it with the alpha tag. Parse only the prerelease portion, not build metadata after +, and add a regression case for 1.0.0+build-alpha with expected tag latest.

Suggested fix
           const prereleaseId = version.match(
-            /^[^-]+-([0-9A-Za-z-]+)(?:[.+]|$)/,
+            /^[^-+]+-([0-9A-Za-z-]+)(?:[.+]|$)/,
           )?.[1];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release.yml around lines 63 - 74, Update the prereleaseId
extraction in the release workflow to inspect only the SemVer prerelease portion
before any build metadata, so 1.0.0+build-alpha selects latest. Add a regression
case covering this version and expected npm tag, while preserving alpha, rc, and
other prerelease tagging behavior.

Source: MCP tools

const wait = (ms) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
Expand Down Expand Up @@ -195,6 +207,8 @@ jobs:
workspacePackage.dir,
"--access",
"public",
"--tag",
npmTag,
Comment on lines +210 to +211

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve npm's stable-version downgrade guard

When a manual dispatch or GitHub release targets an unpublished stable version lower than one already in the registry, explicitly passing --tag latest makes npm publish it and repoint latest backward. I checked npm publish --help ([--tag <tag>]) and npm 11's publish implementation: the safeguard reporting Cannot implicitly apply the "latest" tag because previously published version ... is higher only runs when the tag is implicit, so this new argument bypasses it and can make ordinary installs downgrade. Pass an explicit tag only for prereleases, or independently reject stable versions older than the registry's current latest.

Useful? React with 👍 / 👎.

"--registry",
registry,
],
Expand Down