|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Test script to simulate GitHub Actions version injection |
| 4 | +echo "🧪 Testing version injection locally..." |
| 5 | + |
| 6 | +# Simulate GitHub Actions environment variables |
| 7 | +export GITHUB_REF="refs/tags/v1.0.5" |
| 8 | +export GITHUB_RUN_NUMBER="123" |
| 9 | +export GITHUB_OUTPUT="/tmp/github_output" |
| 10 | + |
| 11 | +# Get version and hash info (simulating the workflow step) |
| 12 | +if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 13 | + VERSION=${GITHUB_REF#refs/tags/} |
| 14 | +elif [[ -n "$GITHUB_EVENT_INPUTS_VERSION" ]]; then |
| 15 | + VERSION=$GITHUB_EVENT_INPUTS_VERSION |
| 16 | +else |
| 17 | + VERSION=dev-$(date +%Y%m%d-%H%M%S) |
| 18 | +fi |
| 19 | + |
| 20 | +# Get git hash |
| 21 | +GIT_HASH=$(git rev-parse HEAD) |
| 22 | +GIT_HASH_SHORT=$(git rev-parse --short HEAD) |
| 23 | + |
| 24 | +echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 25 | +echo "GIT_HASH=$GIT_HASH" >> $GITHUB_OUTPUT |
| 26 | +echo "GIT_HASH_SHORT=$GIT_HASH_SHORT" >> $GITHUB_OUTPUT |
| 27 | + |
| 28 | +echo "Version: $VERSION" |
| 29 | +echo "Git Hash: $GIT_HASH_SHORT" |
| 30 | + |
| 31 | +# Test the version injection |
| 32 | +echo "🔧 Testing version injection..." |
| 33 | +INFO_PLIST="A6Cutter/Info.plist" |
| 34 | + |
| 35 | +# Update version and build number |
| 36 | +plutil -replace CFBundleShortVersionString -string "$VERSION" "$INFO_PLIST" |
| 37 | +plutil -replace CFBundleVersion -string "$GITHUB_RUN_NUMBER" "$INFO_PLIST" |
| 38 | + |
| 39 | +# Add git hash to Info.plist |
| 40 | +plutil -replace GitHash -string "$GIT_HASH" "$INFO_PLIST" |
| 41 | + |
| 42 | +echo "✅ Updated Info.plist with version $VERSION and hash $GIT_HASH_SHORT" |
| 43 | + |
| 44 | +# Verify the changes |
| 45 | +echo "📋 Verifying changes:" |
| 46 | +echo "Version: $(plutil -extract CFBundleShortVersionString raw "$INFO_PLIST")" |
| 47 | +echo "Build: $(plutil -extract CFBundleVersion raw "$INFO_PLIST")" |
| 48 | +echo "Git Hash: $(plutil -extract GitHash raw "$INFO_PLIST")" |
0 commit comments