From 8dcf5f2f349fe1f3040d77b3e8f2a1e902fa1265 Mon Sep 17 00:00:00 2001 From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com> Date: Fri, 31 Oct 2025 20:51:47 +0100 Subject: [PATCH] Extract major.minor.patch version from scripts/build.mjs Update extraction to capture a quoted semver with optional prerelease, strip to major.minor.patch and improve validation messaging --- .github/workflows/release.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2945ca2..404081b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,12 +43,15 @@ jobs: echo '--- scripts/build.mjs (snippet) ---' >&2 sed -n '1,200p' scripts/build.mjs >&2 || true - # Primary extraction: find the first quoted four-segment version - version=$(grep -E 'version[:=]' scripts/build.mjs | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true) + # Primary extraction: find the first quoted semver (may include prerelease suffix) + raw=$(grep -m1 -oE '"[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?"' scripts/build.mjs | tr -d '"' | head -n1 || true) - # Validate final result is exactly major.minor.patch.build - if ! printf '%s' "$version" | grep -xE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' >/dev/null; then - echo "Failed to extract a valid four-segment version from scripts/build.mjs" >&2 + # Strip any prerelease suffix, keep only major.minor.patch + version=$(printf '%s' "$raw" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/') + + # Validate final result is exactly major.minor.patch + if ! printf '%s' "$version" | grep -xE '^[0-9]+\.[0-9]+\.[0-9]+$' >/dev/null; then + echo "Failed to extract a valid base version from scripts/build.mjs" >&2 sed -n '1,200p' scripts/build.mjs >&2 || true exit 1 fi