Skip to content

Commit 59973b3

Browse files
Add version injection test script
- Create test script to simulate GitHub Actions version injection - Test plutil commands for updating Info.plist with version info - Verify version, build number, and git hash injection works - Ensure GitHub Actions workflow will work correctly - Test script shows proper version injection before CI/CD
1 parent 2c1ce60 commit 59973b3

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

test-version-injection.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)