From 2e9792577fd55cfa61745bf477dff22d356797b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Sat, 12 Jul 2025 18:46:37 +0800 Subject: [PATCH] fix: correct SHA length matching in GitHub Actions workflow (#188) * feat: enhance Docker build system with advanced version selection ## New Features - Add force_rebuild parameter for Docker workflow manual triggers - Improve version pattern matching with better regex validation - Add comprehensive Docker Build Guide documentation - Enhanced logging and error reporting for build process - Support for prerelease version detection (alpha, beta, rc) ## Improvements - Better version pattern validation for releases and dev builds - More detailed build logs with context and warnings - Clear documentation for all Docker image variants and use cases - Updated README with Docker version examples and guide reference ## Documentation - New comprehensive Docker Build Guide (docs/DOCKER_BUILD_GUIDE.md) - Updated README with version-specific Docker examples - Workflow dependency diagram and troubleshooting guide - Complete reference for all supported version patterns This enhancement provides a robust, well-documented Docker build system that supports flexible version selection while maintaining deterministic build behavior without fallback mechanisms. * fix: simplify dev version regex pattern in docker workflow * fix: simplify version number regex pattern in docker workflow * feat: remove docs directory * fix: correct SHA length matching in main-latest filename generation * refactor: use bash string operations instead of sed for main-latest filename generation * refactor: simplify filename generation by removing redundant intermediate variables * feat: add dev-latest version generation for all development builds * feat: add dev-latest support to Docker workflow --- .github/workflows/build.yml | 55 ++++++++++++++++++++++-------------- .github/workflows/docker.yml | 7 ++++- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33dfb0771..231fbe633 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -370,8 +370,7 @@ jobs: # Create latest version filename # Convert from rustfs-linux-x86_64-v1.0.0 to rustfs-linux-x86_64-latest - LATEST_NAME=$(echo "$PACKAGE_NAME" | sed 's/-v[0-9].*$/-latest/') - LATEST_FILE="${LATEST_NAME}.zip" + LATEST_FILE="${PACKAGE_NAME%-v*}-latest.zip" # Copy the original file to latest version cp "${{ steps.package.outputs.package_file }}" "$LATEST_FILE" @@ -383,33 +382,47 @@ jobs: echo "✅ Latest version uploaded: $LATEST_FILE" fi - # For development builds on main branch, also create a main-latest version - if [[ "$BUILD_TYPE" == "development" ]] && [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + # For development builds, create dev-latest version + if [[ "$BUILD_TYPE" == "development" ]]; then # Extract platform and arch from package name PACKAGE_NAME="${{ steps.package.outputs.package_name }}" - # Create main-latest version filename - # Convert from rustfs-linux-x86_64-dev-abc123 to rustfs-linux-x86_64-main-latest - MAIN_LATEST_NAME=$(echo "$PACKAGE_NAME" | sed 's/-dev-[a-f0-9]\+$/-main-latest/') - MAIN_LATEST_FILE="${MAIN_LATEST_NAME}.zip" + # Create dev-latest version filename + # Convert from rustfs-linux-x86_64-dev-abc123 to rustfs-linux-x86_64-dev-latest + DEV_LATEST_FILE="${PACKAGE_NAME%-*}-latest.zip" - # Copy the original file to main-latest version - cp "${{ steps.package.outputs.package_file }}" "$MAIN_LATEST_FILE" + # Copy the original file to dev-latest version + cp "${{ steps.package.outputs.package_file }}" "$DEV_LATEST_FILE" - # Upload the main-latest version - echo "Uploading main-latest version: $MAIN_LATEST_FILE to $OSS_PATH..." - $OSSUTIL_BIN cp "$MAIN_LATEST_FILE" "$OSS_PATH" --force + # Upload the dev-latest version + echo "Uploading dev-latest version: $DEV_LATEST_FILE to $OSS_PATH..." + $OSSUTIL_BIN cp "$DEV_LATEST_FILE" "$OSS_PATH" --force - echo "✅ Main-latest version uploaded: $MAIN_LATEST_FILE" + echo "✅ Dev-latest version uploaded: $DEV_LATEST_FILE" - # Also create a generic main-latest for Docker builds - if [[ "${{ matrix.platform }}" == "linux" ]]; then - DOCKER_MAIN_LATEST_NAME="rustfs-linux-${{ matrix.target == 'x86_64-unknown-linux-musl' && 'x86_64' || 'aarch64' }}-main-latest" - DOCKER_MAIN_LATEST_FILE="${DOCKER_MAIN_LATEST_NAME}.zip" + # For main branch builds, also create a main-latest version + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + # Create main-latest version filename + # Convert from rustfs-linux-x86_64-dev-abc123 to rustfs-linux-x86_64-main-latest + MAIN_LATEST_FILE="${PACKAGE_NAME%-dev-*}-main-latest.zip" - cp "${{ steps.package.outputs.package_file }}" "$DOCKER_MAIN_LATEST_FILE" - $OSSUTIL_BIN cp "$DOCKER_MAIN_LATEST_FILE" "$OSS_PATH" --force - echo "✅ Docker main-latest version uploaded: $DOCKER_MAIN_LATEST_FILE" + # Copy the original file to main-latest version + cp "${{ steps.package.outputs.package_file }}" "$MAIN_LATEST_FILE" + + # Upload the main-latest version + echo "Uploading main-latest version: $MAIN_LATEST_FILE to $OSS_PATH..." + $OSSUTIL_BIN cp "$MAIN_LATEST_FILE" "$OSS_PATH" --force + + echo "✅ Main-latest version uploaded: $MAIN_LATEST_FILE" + + # Also create a generic main-latest for Docker builds + if [[ "${{ matrix.platform }}" == "linux" ]]; then + DOCKER_MAIN_LATEST_FILE="rustfs-linux-${{ matrix.target == 'x86_64-unknown-linux-musl' && 'x86_64' || 'aarch64' }}-main-latest.zip" + + cp "${{ steps.package.outputs.package_file }}" "$DOCKER_MAIN_LATEST_FILE" + $OSSUTIL_BIN cp "$DOCKER_MAIN_LATEST_FILE" "$OSS_PATH" --force + echo "✅ Docker main-latest version uploaded: $DOCKER_MAIN_LATEST_FILE" + fi fi fi diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 42981b2ed..0c01b9236 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -56,7 +56,7 @@ on: default: true type: boolean version: - description: "Version to build (latest, main-latest, or specific version like v1.0.0 or dev-abc123)" + description: "Version to build (latest, main-latest, dev-latest, or specific version like v1.0.0 or dev-abc123)" required: false default: "main-latest" type: string @@ -133,6 +133,11 @@ jobs: version="main-latest" echo "🛠️ Building with main branch latest development version" ;; + "dev-latest") + build_type="development" + version="dev-latest" + echo "🛠️ Building with development latest version" + ;; v[0-9]*) build_type="release" create_latest=true