From 3968dba9d26270d297ff7d1a8ad812acd2fa5f9f Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Thu, 25 Dec 2025 22:50:12 +0000 Subject: [PATCH] chore(release): enhance version parsing to support beta/prerelease suffix --- .github/workflows/auto-tag.yml | 6 +++--- .github/workflows/release.yml | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index 7b9e4a3..3722349 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -43,13 +43,13 @@ jobs: echo "✗ Tag v${{ steps.manifest.outputs.version }} does not exist yet" fi - - name: Validate version format + - name: Validate version format (stable or beta) if: steps.tag_check.outputs.exists == 'false' run: | VERSION="${{ steps.manifest.outputs.version }}" - if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then + if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(b[0-9]+)?$'; then echo "❌ Invalid version format: $VERSION" - echo "Expected format: X.Y.Z (e.g., 1.0.0)" + echo "Expected format: X.Y.Z or X.Y.ZbN (e.g., 1.0.0, 0.25.0b0)" exit 1 fi echo "✓ Version format valid: $VERSION" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e48fe5..1bf9166 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -135,10 +135,20 @@ jobs: FEAT=$(echo "$COMMITS" | grep -cE "^feat(\(.+\))?:" || true) FIX=$(echo "$COMMITS" | grep -cE "^fix(\(.+\))?:" || true) - # Parse versions + parse_version() { + local version="$1" + if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(b[0-9]+)?$ ]]; then + echo "${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]} ${BASH_REMATCH[4]}" + else + echo "Invalid version format: $version" >&2 + exit 1 + fi + } + + # Parse versions (support beta/prerelease suffix like 0.25.0b0) PREV_VERSION="${PREV_TAG#v}" - IFS='.' read -r PREV_MAJOR PREV_MINOR PREV_PATCH <<< "$PREV_VERSION" - IFS='.' read -r MAJOR MINOR PATCH <<< "$TAG_VERSION" + read -r PREV_MAJOR PREV_MINOR PREV_PATCH PREV_PRERELEASE <<< "$(parse_version "$PREV_VERSION")" + read -r MAJOR MINOR PATCH PRERELEASE <<< "$(parse_version "$TAG_VERSION")" WARNING="" SUGGESTION="" @@ -245,7 +255,7 @@ jobs: name: ${{ steps.release_notes.outputs.title }} body: ${{ steps.release_notes.outputs.notes }} draft: false - prerelease: false + prerelease: ${{ contains(github.ref, 'b') }} generate_release_notes: false # We provide our own env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}