From 6d882998fac3ac487784505d1ee26cabbb008bdd Mon Sep 17 00:00:00 2001 From: rzen Date: Sat, 20 Jun 2026 14:17:21 -0400 Subject: [PATCH] Auto-set the build number from git; bump to 2.1 Add Scripts/update_build_number.sh (the shared indie build script) and wire it into both targets as a postBuildScripts phase. On each build it sets CFBundleVersion to the git commit count, writes a BuildDate key (surfaced by IndieAbout), and tags the marketing version. Run as a post-build phase rather than post-compile so it lands after the Info.plist/dSYM exist, which also avoids an Xcode 26 build cycle. Bumps MARKETING_VERSION to 2.1. Claude-Session: https://claude.ai/code/session_01A9CfUa4E9Zd5swfoNsYPs7 --- Scripts/update_build_number.sh | 35 ++++++++++++++++++++++++++++++++++ project.yml | 18 ++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 Scripts/update_build_number.sh diff --git a/Scripts/update_build_number.sh b/Scripts/update_build_number.sh new file mode 100755 index 0000000..00c4b12 --- /dev/null +++ b/Scripts/update_build_number.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +## IMPORTANT ## +# Add the following files to Input Files configuraiton of the build phase +# $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH) +# $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Info.plist + +git=$(sh /etc/profile; which git) +number_of_commits=$("$git" rev-list HEAD --count) +git_release_version=$("$git" describe --tags --always --abbrev=0) + +target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH" +dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist" + +git_commit=`"$git" rev-parse --short HEAD` +bundle_version=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$target_plist"` +build_date=`date +%F` + +build="v$bundle_version-$git_commit b$number_of_commits $build_date" + +#echo "version=$bundle_version-$git_commit build $number_of_commits" + +"$git" tag "$bundle_version" + +for plist in "$target_plist" "$dsym_plist"; do + if [ -f "$plist" ]; then + /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $number_of_commits" "$plist" +# /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${version}" "$plist" +# /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${git_release_version#*v}" "$plist" + + # Add build date for AppInfoKit + /usr/libexec/PlistBuddy -c "Set :BuildDate $build_date" "$plist" 2>/dev/null || \ + /usr/libexec/PlistBuddy -c "Add :BuildDate string $build_date" "$plist" + fi +done diff --git a/project.yml b/project.yml index 6e46ac5..6086e2b 100644 --- a/project.yml +++ b/project.yml @@ -11,7 +11,7 @@ settings: base: SWIFT_VERSION: "6.0" DEVELOPMENT_TEAM: ${APPLE_TEAM_ID} - MARKETING_VERSION: "2.0" + MARKETING_VERSION: "2.1" CURRENT_PROJECT_VERSION: "1" ENABLE_USER_SCRIPT_SANDBOXING: "NO" @@ -47,6 +47,14 @@ targets: - package: IndieAbout - package: Yams - target: Workouts Watch App + postBuildScripts: + - script: '"${SRCROOT}/Scripts/update_build_number.sh"' + name: Update Build Number + shell: /bin/sh + basedOnDependencyAnalysis: false + inputFiles: + - $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH) + - $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Info.plist settings: base: PRODUCT_BUNDLE_IDENTIFIER: dev.rzen.indie.Workouts @@ -70,6 +78,14 @@ targets: excludes: - "Resources/Info-*.plist" - "Resources/*.entitlements" + postBuildScripts: + - script: '"${SRCROOT}/Scripts/update_build_number.sh"' + name: Update Build Number + shell: /bin/sh + basedOnDependencyAnalysis: false + inputFiles: + - $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH) + - $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME)/Contents/Info.plist settings: base: PRODUCT_BUNDLE_IDENTIFIER: dev.rzen.indie.Workouts.watchkitapp