refactor: consolidate version extraction logic and update workflow validation

Extracted version extraction logic from workflows into a centralized script for better reusability and consistency. Updated validation output naming for clarity.

Changes:
- Add extract_version.sh for centralized version extraction
- Remove update_version.sh (functionality integrated into workflows)
- Update validate_semver.sh output: release_type → is_prerelease
- Refactor docker-release.yml to use extract_version.sh
- Refactor github-release.yml to use centralized scripts
- Add version duplication check in version-release.yml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
github-actions[bot]
2025-10-27 10:56:33 +11:00
parent f972a9507e
commit 08dab4ca6b
6 changed files with 87 additions and 229 deletions

View File

@@ -24,31 +24,13 @@ jobs:
- name: Extract version from branch and version.py
id: extract
run: |
# Extract version from branch name (release/1.2.3 -> 1.2.3)
BRANCH_VERSION="${GITHUB_REF#refs/heads/release/}"
echo "Branch version: $BRANCH_VERSION"
# Extract version from branch name and validate against version.py
.github/scripts/extract_version.sh "${{ github.ref }}"
# Read version from version.py
FILE_VERSION=$(grep -oP '__version__ = "\K[^"]+' src/version.py)
echo "File version: $FILE_VERSION"
# Verify they match
if [ "$BRANCH_VERSION" != "$FILE_VERSION" ]; then
echo "Error: Branch version ($BRANCH_VERSION) does not match version.py ($FILE_VERSION)"
exit 1
fi
VERSION="$BRANCH_VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Check if pre-release (contains hyphen)
if echo "$VERSION" | grep -q '-'; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
echo "Detected pre-release version: $VERSION"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
echo "Detected stable release version: $VERSION"
fi
- name: Validate version format
run: |
# Validate version is proper SemVer and set prerelease flag
.github/scripts/validate_semver.sh "${{ steps.extract.outputs.version }}"
docker-build:
name: Build & Push Docker Images