mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-05-26 23:19:39 +00:00
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:
30
.github/workflows/docker-release.yml
vendored
30
.github/workflows/docker-release.yml
vendored
@@ -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
|
||||
|
||||
31
.github/workflows/github-release.yml
vendored
31
.github/workflows/github-release.yml
vendored
@@ -29,32 +29,11 @@ jobs:
|
||||
|
||||
- name: Extract version from branch
|
||||
id: extract
|
||||
run: |
|
||||
# Extract version from branch name (release/1.2.3 -> 1.2.3)
|
||||
BRANCH_NAME="${{ github.event.workflow_run.head_branch }}"
|
||||
VERSION="${BRANCH_NAME#release/}"
|
||||
echo "Branch version: $VERSION"
|
||||
run: .github/scripts/extract_version.sh "${{ github.event.workflow_run.head_branch }}"
|
||||
|
||||
# Read version from version.py
|
||||
FILE_VERSION=$(grep -oP '__version__ = "\K[^"]+' src/version.py)
|
||||
echo "File version: $FILE_VERSION"
|
||||
|
||||
# Verify they match
|
||||
if [ "$VERSION" != "$FILE_VERSION" ]; then
|
||||
echo "Error: Branch version ($VERSION) does not match version.py ($FILE_VERSION)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
id: validate
|
||||
run: .github/scripts/validate_semver.sh "${{ steps.extract.outputs.version }}"
|
||||
|
||||
- name: Extract release notes
|
||||
id: release-notes
|
||||
@@ -66,5 +45,5 @@ jobs:
|
||||
tag_name: v${{ steps.extract.outputs.version }}
|
||||
name: Release ${{ steps.extract.outputs.version }}
|
||||
body_path: release_notes.md
|
||||
prerelease: ${{ steps.extract.outputs.is_prerelease }}
|
||||
prerelease: ${{ steps.validate.outputs.is_prerelease }}
|
||||
draft: false
|
||||
|
||||
18
.github/workflows/version-release.yml
vendored
18
.github/workflows/version-release.yml
vendored
@@ -26,10 +26,18 @@ jobs:
|
||||
with:
|
||||
token: ${{ secrets.PUBLISHER_TOKEN }}
|
||||
|
||||
- name: Configure Git
|
||||
- name: Validate version format
|
||||
id: validate
|
||||
run: .github/scripts/validate_semver.sh "${{ github.event.inputs.version }}"
|
||||
|
||||
- name: Check if input version
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
CURRENT_VERSION=$(grep -oP '(?<=__version__ = ")[^"]+' src/version.py)
|
||||
INPUT_VERSION="${{ github.event.inputs.version }}"
|
||||
if [ "$CURRENT_VERSION" = "$INPUT_VERSION" ]; then
|
||||
echo "Error: Input version '$INPUT_VERSION' is the same as the current version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check if branch exists
|
||||
run: |
|
||||
@@ -45,7 +53,11 @@ jobs:
|
||||
- name: Create release branch and update version
|
||||
run: |
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
VERSION="${{ steps.validate.outputs.version }}"
|
||||
|
||||
# Update version.py
|
||||
mv -f src/version.py src/last_version.py
|
||||
echo "__version__ = \"$VERSION\"" > src/version.py
|
||||
|
||||
Reference in New Issue
Block a user