diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 80cb234..4948e33 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,13 +33,32 @@ jobs: - name: Extract base version id: extract run: | - # Extract base (non-prerelease) version like 1.1.4 from src/modules.d.ts - # Use a strict regex to capture exactly three numeric components (major.minor.patch) - version=$(sed -nE 's/.*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' src/modules.d.ts | head -n1) - if [ -z "$version" ]; then - echo "Failed to extract version" >&2 + # Extract base version (major.minor.patch) from src/modules.d.ts using pure shell (grep/sed) + # Capture the first three-part version and ignore any prerelease suffix (e.g. "-1") + if [ ! -f src/modules.d.ts ]; then + echo "src/modules.d.ts not found" >&2 exit 1 fi + # Print the file for debugging in workflow logs + echo '--- src/modules.d.ts ---' >&2 + sed -n '1,200p' src/modules.d.ts >&2 || true + + # Primary extraction: match "X.Y.Z" (three numeric components) within quotes + version=$(grep -m1 -oE '"[0-9]+\.[0-9]+\.[0-9]+' src/modules.d.ts | tr -d '"' | head -n1 || true) + + # Fallback: capture quoted version possibly with prerelease suffix and strip suffix + if [ -z "$version" ]; then + raw=$(grep -m1 -oE '"[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?"' src/modules.d.ts | tr -d '"' | head -n1 || true) + version=$(printf '%s' "$raw" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/') + fi + + # 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 src/modules.d.ts" >&2 + sed -n '1,200p' src/modules.d.ts >&2 || true + exit 1 + fi + echo "version=$version" >> $GITHUB_OUTPUT shell: bash