diff --git a/.gitignore b/.gitignore index df8cddd94..11500c3bb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ xcuserdata # User-specific xcconfig files Xcode-config/DEVELOPMENT_TEAM.xcconfig +# Plist derived from template at build time +/Info.plist + # This indicates the libraries are up to date /ThirdParty/libraries.updated diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index 3c08bc7d5..a3d3ad9cd 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -2003,13 +2003,13 @@ isa = PBXNativeTarget; buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Cog" */; buildPhases = ( + 8384911C1807E9ED00E7332D /* Run version generator script */, 8D11072C0486CEB800E47090 /* Sources */, 8D11072E0486CEB800E47090 /* Frameworks */, 8D1107290486CEB800E47090 /* Resources */, 8E757AEC09F3265E0080F1EE /* CopyFiles */, 177FD1000B90CB570011C3B5 /* CopyFiles */, 07DFC3930ECDF80100DA400D /* CopyFiles */, - 8384911C1807E9ED00E7332D /* Run version generator script */, 83978E27285C5A4C0076ED21 /* Run Crashlytics symbol upload */, ); buildRules = ( @@ -2557,10 +2557,14 @@ buildActionMask = 2147483647; files = ( ); + inputFileListPaths = ( + ); inputPaths = ( + "$(SRCROOT)/Info.plist.template", ); name = "Run version generator script"; outputPaths = ( + "$(SRCROOT)/Info.plist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/Info.plist b/Info.plist.template similarity index 100% rename from Info.plist rename to Info.plist.template diff --git a/Scripts/genversion.sh b/Scripts/genversion.sh index 6895f42db..b39f83ad1 100755 --- a/Scripts/genversion.sh +++ b/Scripts/genversion.sh @@ -1,18 +1,52 @@ #!/bin/sh -git_version=$(/usr/bin/git describe --tags | sed -e 's/k54-//') -short_version=${git_version%-*} +git=$(which git) -build_time=$(date) +sed=$(which sed) -echo "git_version=${git_version}" -echo "short_version=${short_version}" -echo "build_time=${build_time}" +PlistBuddy="/usr/libexec/PlistBuddy" -info_plist="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}" -/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}" +REPO_ROOT_PATH=$("$git" rev-parse --show-toplevel) -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