Update versioning setup

Versioning now happens before building Cog itself, and goes
into the Info.plist in the project directory. The original
file became a template file which is altered any time a
build occurs.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-26 22:08:42 -07:00
parent 9d8e278a57
commit 03b3b43cfe
4 changed files with 54 additions and 13 deletions

3
.gitignore vendored
View File

@ -8,6 +8,9 @@ xcuserdata
# User-specific xcconfig files # User-specific xcconfig files
Xcode-config/DEVELOPMENT_TEAM.xcconfig Xcode-config/DEVELOPMENT_TEAM.xcconfig
# Plist derived from template at build time
/Info.plist
# This indicates the libraries are up to date # This indicates the libraries are up to date
/ThirdParty/libraries.updated /ThirdParty/libraries.updated

View File

@ -2009,13 +2009,13 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Cog" */; buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Cog" */;
buildPhases = ( buildPhases = (
8384911C1807E9ED00E7332D /* Run version generator script */,
8D11072C0486CEB800E47090 /* Sources */, 8D11072C0486CEB800E47090 /* Sources */,
8D11072E0486CEB800E47090 /* Frameworks */, 8D11072E0486CEB800E47090 /* Frameworks */,
8D1107290486CEB800E47090 /* Resources */, 8D1107290486CEB800E47090 /* Resources */,
8E757AEC09F3265E0080F1EE /* CopyFiles */, 8E757AEC09F3265E0080F1EE /* CopyFiles */,
177FD1000B90CB570011C3B5 /* CopyFiles */, 177FD1000B90CB570011C3B5 /* CopyFiles */,
07DFC3930ECDF80100DA400D /* CopyFiles */, 07DFC3930ECDF80100DA400D /* CopyFiles */,
8384911C1807E9ED00E7332D /* Run version generator script */,
83978E27285C5A4C0076ED21 /* Run Crashlytics symbol upload */, 83978E27285C5A4C0076ED21 /* Run Crashlytics symbol upload */,
); );
buildRules = ( buildRules = (
@ -2563,10 +2563,14 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
); );
inputFileListPaths = (
);
inputPaths = ( inputPaths = (
"$(SRCROOT)/Info.plist.template",
); );
name = "Run version generator script"; name = "Run version generator script";
outputPaths = ( outputPaths = (
"$(SRCROOT)/Info.plist",
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;

View File

@ -1,18 +1,52 @@
#!/bin/sh #!/bin/sh
git_version=$(/usr/bin/git describe --tags | sed -e 's/k54-//') git=$(which git)
short_version=${git_version%-*}
build_time=$(date) sed=$(which sed)
echo "git_version=${git_version}" PlistBuddy="/usr/libexec/PlistBuddy"
echo "short_version=${short_version}"
echo "build_time=${build_time}"
info_plist="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}" REPO_ROOT_PATH=$("$git" rev-parse --show-toplevel)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion '${short_version}'" "${info_plist}"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString '${short_version}'" "${info_plist}"
/usr/libexec/PlistBuddy -c "Add :GitVersion string '${git_version}'" "${info_plist}"
/usr/libexec/PlistBuddy -c "Add :BuildTime date '${build_time}'" "${info_plist}"
exit 0 GIT_HASH=$("$git" -C "$REPO_ROOT_PATH" show -s --format=%H)
GIT_NUMBER_OF_COMMITS=$("$git" -C "$REPO_ROOT_PATH" rev-list HEAD --count)
GIT_RELEASE_VERSION=$("$git" -C "$REPO_ROOT_PATH" describe --tags --always | "$sed" -e 's/k54-//')
GIT_RELEASE_NUMBER=${GIT_RELEASE_VERSION%-*}
MACOS_PLIST_PATH="$REPO_ROOT_PATH/Info.plist"
BUILD_TIME=$(date)
echo "GIT: $git"
echo "NUMBER_OF_COMMITS: $GIT_NUMBER_OF_COMMITS"
echo "RELEASE_VERSION: $GIT_RELEASE_VERSION"
for plist in "$MACOS_PLIST_PATH"; do
plist_template=${plist}.template
if [ -f "$plist_template" ]; then
echo "COPY: $plist_template"
echo "TO: $plist"
cp -f "$plist_template" "$plist"
"$PlistBuddy" -c "Set :CFBundleVersion $GIT_RELEASE_NUMBER" "$plist"
"$PlistBuddy" -c "Set :CFBundleShortVersionString $GIT_RELEASE_NUMBER" "$plist"
"$PlistBuddy" -c "Add :GitHash string $GIT_HASH" "$plist"
"$PlistBuddy" -c "Add :GitVersion string $GIT_RELEASE_VERSION" "$plist"
"$PlistBuddy" -c "Add :BuildTime date $BUILD_TIME" "$plist"
fi
done