|
| 1 | +# Dockerfile for testing GitHub Actions workflow locally |
| 2 | +FROM macos:latest |
| 3 | + |
| 4 | +# Install required tools |
| 5 | +RUN apt-get update && apt-get install -y \ |
| 6 | + curl \ |
| 7 | + jq \ |
| 8 | + git \ |
| 9 | + xcodebuild \ |
| 10 | + hdiutil \ |
| 11 | + plutil \ |
| 12 | + && rm -rf /var/lib/apt/lists/* |
| 13 | + |
| 14 | +# Set working directory |
| 15 | +WORKDIR /workspace |
| 16 | + |
| 17 | +# Copy project files |
| 18 | +COPY . . |
| 19 | + |
| 20 | +# Set up environment variables for testing |
| 21 | +ENV GITHUB_REF=refs/tags/v1.0.50 |
| 22 | +ENV GITHUB_RUN_NUMBER=42 |
| 23 | +ENV GITHUB_EVENT_NAME=push |
| 24 | + |
| 25 | +# Run the workflow steps |
| 26 | +RUN echo "🔧 Testing GitHub Actions workflow locally..." |
| 27 | + |
| 28 | +# Step 1: Get version and hash info |
| 29 | +RUN echo "📝 Getting version and hash info..." && \ |
| 30 | + if [[ $GITHUB_REF == refs/tags/* ]]; then \ |
| 31 | + VERSION=${GITHUB_REF#refs/tags/}; \ |
| 32 | + else \ |
| 33 | + VERSION=dev-$(date +%Y%m%d-%H%M%S); \ |
| 34 | + fi && \ |
| 35 | + GIT_HASH=$(git rev-parse HEAD) && \ |
| 36 | + GIT_HASH_SHORT=$(git rev-parse --short HEAD) && \ |
| 37 | + echo "VERSION=$VERSION" && \ |
| 38 | + echo "GIT_HASH=$GIT_HASH" && \ |
| 39 | + echo "GIT_HASH_SHORT=$GIT_HASH_SHORT" |
| 40 | + |
| 41 | +# Step 2: Update Info.plist |
| 42 | +RUN echo "📝 Updating Info.plist..." && \ |
| 43 | + INFO_PLIST="A6Cutter/Info.plist" && \ |
| 44 | + echo "📄 Current Info.plist content:" && \ |
| 45 | + plutil -p "$INFO_PLIST" | grep -E "(CFBundleShortVersionString|CFBundleVersion|GitHash)" || echo "No version info found" && \ |
| 46 | + echo "🔧 Updating CFBundleShortVersionString to: v1.0.50" && \ |
| 47 | + plutil -replace CFBundleShortVersionString -string "v1.0.50" "$INFO_PLIST" && \ |
| 48 | + echo "🔧 Updating CFBundleVersion to: 42" && \ |
| 49 | + plutil -replace CFBundleVersion -string "42" "$INFO_PLIST" && \ |
| 50 | + echo "🔧 Updating GitHash to: a1b2c3d4e5f6789012345678901234567890abcd" && \ |
| 51 | + plutil -replace GitHash -string "a1b2c3d4e5f6789012345678901234567890abcd" "$INFO_PLIST" && \ |
| 52 | + echo "📄 Updated Info.plist content:" && \ |
| 53 | + plutil -p "$INFO_PLIST" | grep -E "(CFBundleShortVersionString|CFBundleVersion|GitHash)" |
| 54 | + |
| 55 | +# Step 3: Test appcast generation (simulate) |
| 56 | +RUN echo "📡 Testing appcast generation..." && \ |
| 57 | + mkdir -p releases && \ |
| 58 | + echo "Test DMG content" > releases/A6Cutter-v1.0.50.dmg && \ |
| 59 | + echo "Test appcast content" > releases/releases.atom && \ |
| 60 | + echo "📁 Available files in releases/:" && \ |
| 61 | + ls -la releases/ && \ |
| 62 | + if [ -f "releases/releases.atom" ]; then \ |
| 63 | + mv releases/releases.atom appcast.xml && \ |
| 64 | + echo "✅ appcast.xml generated successfully (from releases/releases.atom)!"; \ |
| 65 | + else \ |
| 66 | + echo "❌ Failed to generate appcast.xml"; \ |
| 67 | + exit 1; \ |
| 68 | + fi |
| 69 | + |
| 70 | +# Step 4: Verify final result |
| 71 | +RUN echo "📋 Final verification:" && \ |
| 72 | + echo "📄 Info.plist content:" && \ |
| 73 | + plutil -p A6Cutter/Info.plist | grep -E "(CFBundleShortVersionString|CFBundleVersion|GitHash)" && \ |
| 74 | + echo "📄 appcast.xml exists:" && \ |
| 75 | + ls -la appcast.xml && \ |
| 76 | + echo "✅ All tests passed!" |
| 77 | + |
| 78 | +CMD ["echo", "Docker test completed successfully!"] |
| 79 | + |
0 commit comments