Files
TwitchDropsMiner/.github/workflows/docker-release.yml
github-actions[bot] 08dab4ca6b 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>
2025-10-27 10:56:33 +11:00

100 lines
3.1 KiB
YAML

name: Docker Release
on:
push:
branches:
- 'release/**'
permissions:
contents: write
packages: write
jobs:
extract-version:
name: Extract Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
is_prerelease: ${{ steps.extract.outputs.is_prerelease }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Extract version from branch and version.py
id: extract
run: |
# Extract version from branch name and validate against version.py
.github/scripts/extract_version.sh "${{ github.ref }}"
- 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
runs-on: ubuntu-latest
needs: extract-version
environment: prod
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate Docker tags
id: docker-tags
run: |
VERSION="${{ needs.extract-version.outputs.version }}"
IMAGE="rangermix/twitch-drops-miner"
IS_PRERELEASE="${{ needs.extract-version.outputs.is_prerelease }}"
# Always include the full version tag
TAGS="$IMAGE:$VERSION"
# For stable releases, add major.minor, major, and latest tags
if [ "$IS_PRERELEASE" = "false" ]; then
# Extract major.minor.patch
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
TAGS="$TAGS,$IMAGE:$MAJOR.$MINOR"
TAGS="$TAGS,$IMAGE:$MAJOR"
TAGS="$TAGS,$IMAGE:latest"
fi
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
echo "Generated tags: $TAGS"
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker-tags.outputs.tags }}
labels: |
org.opencontainers.image.title=Twitch Drops Miner
org.opencontainers.image.description=Automatically mine Twitch drops
org.opencontainers.image.version=${{ needs.extract-version.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.repository.updated_at }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATE=${{ github.event.repository.updated_at }}
VCS_REF=${{ github.sha }}
VERSION=${{ needs.extract-version.outputs.version }}