From 7bad34056b0b8647f045bc180ce06d008d7e1c83 Mon Sep 17 00:00:00 2001 From: David Owens II Date: Mon, 6 Jul 2015 15:25:33 -0700 Subject: [PATCH] Basic support for auto-versioning - issue #6. --- apous.xcodeproj/project.pbxproj | 100 +++++++++++++++++++++++++++++++- src/VersionInfo.swift | 6 ++ src/main.swift | 8 +-- src/version.sh | 10 ++++ 4 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 src/VersionInfo.swift create mode 100644 src/version.sh diff --git a/apous.xcodeproj/project.pbxproj b/apous.xcodeproj/project.pbxproj index bd58a4b..060c0e4 100644 --- a/apous.xcodeproj/project.pbxproj +++ b/apous.xcodeproj/project.pbxproj @@ -14,8 +14,26 @@ 7D3AC3461B49F99B0068CC83 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3451B49F99B0068CC83 /* Utils.swift */; }; 7D3AC3481B49FE170068CC83 /* ErrorCodes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3471B49FE170068CC83 /* ErrorCodes.swift */; }; 7D3AC34A1B4A37BC0068CC83 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3491B4A37BC0068CC83 /* Tools.swift */; }; + 7DF997441B4B33A200E90F56 /* VersionInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DF997431B4B33A200E90F56 /* VersionInfo.swift */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 7DF9974B1B4B354000E90F56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7D03732D1B49021700E2711D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7DF997471B4B353600E90F56; + remoteInfo = GenerateVersionInfo; + }; + 7DF9974D1B4B354800E90F56 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7D03732D1B49021700E2711D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 7DF997471B4B353600E90F56; + remoteInfo = GenerateVersionInfo; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ 7D0373331B49021700E2711D /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; @@ -52,6 +70,8 @@ 7D3AC3451B49F99B0068CC83 /* Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; 7D3AC3471B49FE170068CC83 /* ErrorCodes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorCodes.swift; sourceTree = ""; }; 7D3AC3491B4A37BC0068CC83 /* Tools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tools.swift; sourceTree = ""; }; + 7DF997431B4B33A200E90F56 /* VersionInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VersionInfo.swift; sourceTree = ""; }; + 7DF9974F1B4B356700E90F56 /* version.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = version.sh; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -94,6 +114,7 @@ 7D0373371B49021700E2711D /* src */ = { isa = PBXGroup; children = ( + 7DF997501B4B37B100E90F56 /* Versioning */, 7D0373381B49021700E2711D /* main.swift */, 7D3AC3451B49F99B0068CC83 /* Utils.swift */, 7D3AC3471B49FE170068CC83 /* ErrorCodes.swift */, @@ -122,8 +143,34 @@ name = docs; sourceTree = ""; }; + 7DF997501B4B37B100E90F56 /* Versioning */ = { + isa = PBXGroup; + children = ( + 7DF997431B4B33A200E90F56 /* VersionInfo.swift */, + 7DF9974F1B4B356700E90F56 /* version.sh */, + ); + name = Versioning; + sourceTree = ""; + }; /* End PBXGroup section */ +/* Begin PBXLegacyTarget section */ + 7DF997471B4B353600E90F56 /* GenerateVersionInfo */ = { + isa = PBXLegacyTarget; + buildArgumentsString = version.sh; + buildConfigurationList = 7DF997481B4B353600E90F56 /* Build configuration list for PBXLegacyTarget "GenerateVersionInfo" */; + buildPhases = ( + ); + buildToolPath = /bin/sh; + buildWorkingDirectory = "$(SRCROOT)/src"; + dependencies = ( + ); + name = GenerateVersionInfo; + passBuildSettingsInEnvironment = 1; + productName = GenerateVersionInfo; + }; +/* End PBXLegacyTarget section */ + /* Begin PBXNativeTarget section */ 7D0373341B49021700E2711D /* apous */ = { isa = PBXNativeTarget; @@ -137,6 +184,7 @@ buildRules = ( ); dependencies = ( + 7DF9974C1B4B354000E90F56 /* PBXTargetDependency */, ); name = apous; productName = apous; @@ -154,6 +202,7 @@ buildRules = ( ); dependencies = ( + 7DF9974E1B4B354800E90F56 /* PBXTargetDependency */, ); name = apoustest; productName = apoustest; @@ -175,6 +224,9 @@ 7D0F00901B4AF32F003B6EF0 = { CreatedOnToolsVersion = 7.0; }; + 7DF997471B4B353600E90F56 = { + CreatedOnToolsVersion = 7.0; + }; }; }; buildConfigurationList = 7D0373301B49021700E2711D /* Build configuration list for PBXProject "apous" */; @@ -189,6 +241,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( + 7DF997471B4B353600E90F56 /* GenerateVersionInfo */, 7D0373341B49021700E2711D /* apous */, 7D0F00901B4AF32F003B6EF0 /* apoustest */, ); @@ -214,6 +267,7 @@ 7D3AC3481B49FE170068CC83 /* ErrorCodes.swift in Sources */, 7D0373391B49021700E2711D /* main.swift in Sources */, 7D0F00B11B4B18B6003B6EF0 /* Xcode.swift in Sources */, + 7DF997441B4B33A200E90F56 /* VersionInfo.swift in Sources */, 7D3AC34A1B4A37BC0068CC83 /* Tools.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -228,6 +282,19 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 7DF9974C1B4B354000E90F56 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 7DF997471B4B353600E90F56 /* GenerateVersionInfo */; + targetProxy = 7DF9974B1B4B354000E90F56 /* PBXContainerItemProxy */; + }; + 7DF9974E1B4B354800E90F56 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 7DF997471B4B353600E90F56 /* GenerateVersionInfo */; + targetProxy = 7DF9974D1B4B354800E90F56 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ 7D03733A1B49021700E2711D /* Debug */ = { isa = XCBuildConfiguration; @@ -247,7 +314,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.1.1; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -291,7 +357,6 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.1.1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -345,6 +410,29 @@ }; name = Release; }; + 7DF997491B4B353600E90F56 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUGGING_SYMBOLS = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 7DF9974A1B4B353600E90F56 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -375,6 +463,14 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 7DF997481B4B353600E90F56 /* Build configuration list for PBXLegacyTarget "GenerateVersionInfo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7DF997491B4B353600E90F56 /* Debug */, + 7DF9974A1B4B353600E90F56 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; /* End XCConfigurationList section */ }; rootObject = 7D03732D1B49021700E2711D /* Project object */; diff --git a/src/VersionInfo.swift b/src/VersionInfo.swift new file mode 100644 index 0000000..8253124 --- /dev/null +++ b/src/VersionInfo.swift @@ -0,0 +1,6 @@ +// THIS IS A GENERATED FILE + +enum VersionInfo : String { + case Version = "0.2.0" + case Branch = "v0.2.0-dev" +} diff --git a/src/main.swift b/src/main.swift index 6e62ad2..b0111c7 100644 --- a/src/main.swift +++ b/src/main.swift @@ -11,14 +11,8 @@ import Foundation let CartfileConfig = "Cartfile" let PodfileConfig = "Podfile" -let ApousScriptFile = ".apous.swift" - -// TODO(owensd): Pull this from a proper versioning tool. -let Version = "0.1.1" -let Branch = "master" - func printUsage() { - print("OVERVIEW: Apous Swift Script Runner (build: \(Version)-\(Branch))") + print("OVERVIEW: Apous Swift Script Runner (build: \(VersionInfo.Version.rawValue)-\(VersionInfo.Branch.rawValue))") print("") print("USAGE: apous [|]") } diff --git a/src/version.sh b/src/version.sh new file mode 100644 index 0000000..29a2efd --- /dev/null +++ b/src/version.sh @@ -0,0 +1,10 @@ + +VERSION=0.2.0 +BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) +VERSION_FILE=VersionInfo.swift + +echo "// THIS IS A GENERATED FILE\n" > $VERSION_FILE +echo "enum VersionInfo : String {" >> $VERSION_FILE +echo " case Version = \"$VERSION\"" >> $VERSION_FILE +echo " case Branch = \"$BRANCH_NAME\"" >> $VERSION_FILE +echo "}" >> $VERSION_FILE