mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-04 19:25:40 +00:00
fix: correct Docker workflow trigger logic for tag-based releases
BREAKING CHANGE: Fixed Docker workflow that was incorrectly skipping builds for tagged releases - Fix logic to detect tag pushes using git refs instead of branch names - Properly identify tag pushes vs branch pushes using git show-ref - Support both v-prefixed and bare version formats - Ensure Docker images are built for all tagged releases including prereleases
This commit is contained in:
@@ -114,32 +114,51 @@ jobs:
|
|||||||
# Use Git to generate consistent short SHA (ensures uniqueness like build.yml)
|
# Use Git to generate consistent short SHA (ensures uniqueness like build.yml)
|
||||||
short_sha=$(git rev-parse --short "${{ github.event.workflow_run.head_sha }}")
|
short_sha=$(git rev-parse --short "${{ github.event.workflow_run.head_sha }}")
|
||||||
|
|
||||||
# Determine build type based on branch and commit
|
# Determine build type based on event type and git refs
|
||||||
if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then
|
# Check if this is a tag push (release build)
|
||||||
build_type="development"
|
if [[ "${{ github.event.workflow_run.event }}" == "push" ]]; then
|
||||||
version="dev-${short_sha}"
|
# Get git refs to determine if this is a tag or branch push
|
||||||
# Skip Docker build for development builds
|
git_ref="${{ github.event.workflow_run.head_branch }}"
|
||||||
should_build=false
|
|
||||||
echo "⏭️ Skipping Docker build for development version (main branch)"
|
# Check if this is a tag push by looking at the git ref
|
||||||
elif [[ "${{ github.event.workflow_run.event }}" == "push" ]] && [[ "${{ github.event.workflow_run.head_branch }}" =~ ^refs/tags/ ]]; then
|
if git show-ref --tags | grep -q "${{ github.event.workflow_run.head_sha }}"; then
|
||||||
# Tag push - only build for releases and prereleases
|
# This commit has tags, extract the tag name
|
||||||
tag_name="${{ github.event.workflow_run.head_branch }}"
|
tag_name=$(git tag --points-at "${{ github.event.workflow_run.head_sha }}" | head -n1)
|
||||||
version="${tag_name#refs/tags/}"
|
if [[ -n "$tag_name" ]]; then
|
||||||
if [[ "$version" == *"alpha"* ]] || [[ "$version" == *"beta"* ]] || [[ "$version" == *"rc"* ]]; then
|
version="$tag_name"
|
||||||
build_type="prerelease"
|
# Remove 'v' prefix if present for consistent version format
|
||||||
is_prerelease=true
|
if [[ "$version" == v* ]]; then
|
||||||
echo "🧪 Building Docker image for prerelease: $version"
|
version="${version#v}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$version" == *"alpha"* ]] || [[ "$version" == *"beta"* ]] || [[ "$version" == *"rc"* ]]; then
|
||||||
|
build_type="prerelease"
|
||||||
|
is_prerelease=true
|
||||||
|
echo "🧪 Building Docker image for prerelease: $version"
|
||||||
|
else
|
||||||
|
build_type="release"
|
||||||
|
create_latest=true
|
||||||
|
echo "🚀 Building Docker image for release: $version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Regular branch push
|
||||||
|
build_type="development"
|
||||||
|
version="dev-${short_sha}"
|
||||||
|
should_build=false
|
||||||
|
echo "⏭️ Skipping Docker build for development version (branch push)"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
build_type="release"
|
# Regular branch push
|
||||||
create_latest=true
|
build_type="development"
|
||||||
echo "🚀 Building Docker image for release: $version"
|
version="dev-${short_sha}"
|
||||||
|
should_build=false
|
||||||
|
echo "⏭️ Skipping Docker build for development version (branch push)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
build_type="development"
|
build_type="development"
|
||||||
version="dev-${short_sha}"
|
version="dev-${short_sha}"
|
||||||
# Skip Docker build for development builds
|
|
||||||
should_build=false
|
should_build=false
|
||||||
echo "⏭️ Skipping Docker build for development version"
|
echo "⏭️ Skipping Docker build for development version (non-push event)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "🔄 Build triggered by workflow_run:"
|
echo "🔄 Build triggered by workflow_run:"
|
||||||
|
|||||||
Reference in New Issue
Block a user