Skip to content

Commit

Permalink
Fixed versioning script.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgray committed Aug 12, 2017
1 parent 8b1ee42 commit ec35331
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contacts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/bin/sh -\n\n# build data file that is included in the source\n# so we can automatically report Git repo information\n# in the application\n\nif [[ ! -d \".git\" ]]; then\nlastRepoTag=`cat VERSION | grep version | awk '{print $2}'`\nlastCommitHash=`cat VERSION | grep commit | awk '{print $2}'`\nelse\necho \"Building file\"\n\n# cd ${PROJECT_DIR}/${PROJECT_NAME}\ngitDataFile=\"${CONFIGURATION_TEMP_DIR}/gitDataAutoGenerated.h\"\n\necho \"Get Information from system\"\n\n# Date and time that we are running this build\nbuildDate=`date \"+%F %H:%M:%S\"`\n\n# Current branch in use\ncurrentBranchTemp=`git rev-parse --abbrev-ref HEAD`\nif [ -n \"$currentBranchTemp\" ]\nthen\ncurrentBranch=$currentBranchTemp\nelse\ncurrentBranch=\"\"\nfi\n\n# Last hash from the current branch\nlastCommitHashTemp=`git rev-parse --short HEAD`\nif [ -n \"$lastCommitHashTemp\" ]\nthen\nlastCommitHash=$lastCommitHashTemp\nelse\nlastCommitHash=\"\"\nfi\n\n# Date and time of the last commit on this branch\nlastCommitDateTemp=`git log --pretty=format:\"%ad\" --date=short -1`\nif [ -n \"$\" ]\nthen\nlastCommitDate=$lastCommitDateTemp\nelse\nlastCommitDate=\"\"\nfi\n\n# Comment from the last commit on this branch\nlastCommitCommentTemp=`git log --pretty=format:\"%s\" -1`\nif [ -n \"$\" ]\nthen\nlastCommitComment=$lastCommitCommentTemp\nelse\nlastCommitComment=\"\"\nfi\n\n# Last tag applied to this branch\nlastRepoTagTemp=`git describe --abbrev=0 --tags`\nif [ -n \"$lastRepoTagTemp\" ]\nthen\nlastRepoTag=$lastRepoTagTemp\nelse\nlastRepoTag=\"0.0.0\"\nfi\n\n# Version number from VERSIONS file\nversionFileVersionTemp=`cat VERSION | grep version | awk '{print $2}'`\nif [ -n \"$versionFileVersionTemp\" ]\nthen\nversionFileVersion=$versionFileVersionTemp\nelse\nversionFileVersion=\"0.0.0\"\nfi\n\n# Test version numbers\nvertest=`perl -e '($a,$b)=@ARGV; for ($a,$b) {s/(\\d+)/sprintf \"%5d\", $1/ge}; print $a cmp $b;' $lastRepoTag $versionFileVersionTemp`\n\nif [[ \"$vertest\" -eq -1 ]]; then\nversionNumber=$versionFileVersionTemp\nelse\nversionNumber=$lastRepoTag\nfi\n\n# Build the file with all the information in it\necho \"Create header file\"\n\necho \"//-----------------------------------------\" > $gitDataFile\necho \"// Auto generated file\" >> $gitDataFile\necho \"// Created $buildDate\" >> $gitDataFile\necho \"//-----------------------------------------\" >> $gitDataFile\necho \"\" >> $gitDataFile\necho \"#define BUILD_DATE @ \\\"$buildDate\\\"\" >> $gitDataFile\necho \"#define GIT_CURRENT_BRANCH @ \\\"$currentBranch\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_COMMIT_HASH @ \\\"$lastCommitHash\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_COMMIT_DATE @ \\\"$lastCommitDate\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_COMMIT_COMMENT @ \\\"$lastCommitComment\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_REPO_TAG @ \\\"$lastRepoTag\\\"\" >> $gitDataFile\necho \"#define VERSION_FILE_VERSION @ \\\"$versionFileVersion\\\"\" >> $gitDataFile\necho \"#define AUTOVERSION $versionNumber\" >> $gitDataFile\nfi\n\n\necho \"Create temporary Info.plist\"\n# Make my own Info.plist file\nPLIST=\"${PROJECT_DIR}/${PROJECT_NAME}/Info\"\ncp \"${PROJECT_DIR}/${PROJECT_NAME}/Info-template.plist\" ${PLIST}.plist\n\n# defaults write \"${PLIST}\" CFBundleShortVersionString ${lastRepoTag}\n# defaults write \"${PLIST}\" CFBundleVersion ${lastCommitHash}\n/usr/libexec/PlistBuddy -c \"Set CFBundleShortVersionString ${versionNumber}\" \"${PLIST}.plist\"\n/usr/libexec/PlistBuddy -c \"Set CFBundleVersion ${lastCommitHash}\" \"${PLIST}.plist\"\n\ndefaults read \"${PLIST}\"\n";
shellScript = "#!/bin/sh -\n\n# build data file that is included in the source\n# so we can automatically report Git repo information\n# in the application\n\nif [[ ! -d \".git\" ]]; then\nversionNumber=`cat VERSION | grep version | awk '{print $2}'`\nlastCommitHash=`cat VERSION | grep commit | awk '{print $2}'`\nelse\necho \"Building file\"\n\n# cd ${PROJECT_DIR}/${PROJECT_NAME}\ngitDataFile=\"${CONFIGURATION_TEMP_DIR}/gitDataAutoGenerated.h\"\n\necho \"Get Information from system\"\n\n# Date and time that we are running this build\nbuildDate=`date \"+%F %H:%M:%S\"`\n\n# Current branch in use\ncurrentBranchTemp=`git rev-parse --abbrev-ref HEAD`\nif [ -n \"$currentBranchTemp\" ]\nthen\ncurrentBranch=$currentBranchTemp\nelse\ncurrentBranch=\"\"\nfi\n\n# Last hash from the current branch\nlastCommitHashTemp=`git rev-parse --short HEAD`\nif [ -n \"$lastCommitHashTemp\" ]\nthen\nlastCommitHash=$lastCommitHashTemp\nelse\nlastCommitHash=\"\"\nfi\n\n# Date and time of the last commit on this branch\nlastCommitDateTemp=`git log --pretty=format:\"%ad\" --date=short -1`\nif [ -n \"$\" ]\nthen\nlastCommitDate=$lastCommitDateTemp\nelse\nlastCommitDate=\"\"\nfi\n\n# Comment from the last commit on this branch\nlastCommitCommentTemp=`git log --pretty=format:\"%s\" -1`\nif [ -n \"$\" ]\nthen\nlastCommitComment=$lastCommitCommentTemp\nelse\nlastCommitComment=\"\"\nfi\n\n# Last tag applied to this branch\nlastRepoTagTemp=`git describe --abbrev=0 --tags`\nif [ -n \"$lastRepoTagTemp\" ]\nthen\nlastRepoTag=$lastRepoTagTemp\nelse\nlastRepoTag=\"0.0.0\"\nfi\n\n# Version number from VERSIONS file\nversionFileVersionTemp=`cat VERSION | grep version | awk '{print $2}'`\nif [ -n \"$versionFileVersionTemp\" ]\nthen\nversionFileVersion=$versionFileVersionTemp\nelse\nversionFileVersion=\"0.0.0\"\nfi\n\n# Test version numbers\nvertest=`perl -e '($a,$b)=@ARGV; for ($a,$b) {s/(\\d+)/sprintf \"%5d\", $1/ge}; print $a cmp $b;' $lastRepoTag $versionFileVersionTemp`\n\nif [[ \"$vertest\" -eq -1 ]]; then\nversionNumber=$versionFileVersionTemp\nelse\nversionNumber=$lastRepoTag\nfi\n\n# Build the file with all the information in it\necho \"Create header file\"\n\necho \"//-----------------------------------------\" > $gitDataFile\necho \"// Auto generated file\" >> $gitDataFile\necho \"// Created $buildDate\" >> $gitDataFile\necho \"//-----------------------------------------\" >> $gitDataFile\necho \"\" >> $gitDataFile\necho \"#define BUILD_DATE @ \\\"$buildDate\\\"\" >> $gitDataFile\necho \"#define GIT_CURRENT_BRANCH @ \\\"$currentBranch\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_COMMIT_HASH @ \\\"$lastCommitHash\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_COMMIT_DATE @ \\\"$lastCommitDate\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_COMMIT_COMMENT @ \\\"$lastCommitComment\\\"\" >> $gitDataFile\necho \"#define GIT_LAST_REPO_TAG @ \\\"$lastRepoTag\\\"\" >> $gitDataFile\necho \"#define VERSION_FILE_VERSION @ \\\"$versionFileVersion\\\"\" >> $gitDataFile\necho \"#define AUTOVERSION $versionNumber\" >> $gitDataFile\nfi\n\n\necho \"Create temporary Info.plist\"\n# Make my own Info.plist file\nPLIST=\"${PROJECT_DIR}/${PROJECT_NAME}/Info\"\ncp \"${PROJECT_DIR}/${PROJECT_NAME}/Info-template.plist\" ${PLIST}.plist\n\n# defaults write \"${PLIST}\" CFBundleShortVersionString ${lastRepoTag}\n# defaults write \"${PLIST}\" CFBundleVersion ${lastCommitHash}\n/usr/libexec/PlistBuddy -c \"Set CFBundleShortVersionString ${versionNumber}\" \"${PLIST}.plist\"\n/usr/libexec/PlistBuddy -c \"Set CFBundleVersion ${lastCommitHash}\" \"${PLIST}.plist\"\n\ndefaults read \"${PLIST}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down

0 comments on commit ec35331

Please sign in to comment.