Skip to content

Commit

Permalink
Issue 3590 - Automate release build generation
Browse files Browse the repository at this point in the history
  • Loading branch information
fhd committed Jan 27, 2016
1 parent f108c2f commit b3dbc33
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 19 deletions.
18 changes: 14 additions & 4 deletions AdblockPlusSafari.xcodeproj/project.pbxproj
Expand Up @@ -631,6 +631,7 @@
E942B0781B76899D004B4692 /* Resources */,
326FCB1ED6ADD7F4F2862B4F /* Embed Pods Frameworks */,
15C6F5893FBF1AFB22469D1A /* Copy Pods Resources */,
E94626671C5A726800EF3119 /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -848,6 +849,19 @@
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
E94626671C5A726800EF3119 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/\"\nif [[ -d \"Frameworks\" ]]; then\nrm -fr Frameworks\nfi";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -1121,7 +1135,6 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -1166,7 +1179,6 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
Expand Down Expand Up @@ -1281,7 +1293,6 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
Expand Down Expand Up @@ -1357,7 +1368,6 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_RESOURCE_RULES_PATH = "$(SDKROOT)/ResourceRules.plist";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
63 changes: 48 additions & 15 deletions build.py
Expand Up @@ -4,39 +4,72 @@
import os
import shutil
import subprocess
import sys
import time

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
BUILD_DIR = os.path.join(BASE_DIR, "build")
BUILD_NUMBER = time.strftime("%Y%m%d%H%M", time.gmtime())
PACKAGE_NAME = "adblockplussafariios-%s.ipa" % BUILD_NUMBER
RELEASE_APP_PROVISIONING_PROFILE = "00d92821-2b0f-4036-9b2d-541ce10d0429"
RELEASE_EXTENSION_PROVISIONING_PROFILE = "a30dba35-c866-4331-8967-28b9cab60ca2"
DEVBUILD_APP_PROVISIONING_PROFILE = "2591efa4-c166-4956-a62a-e3a0cd41f5a3"
DEVBUILD_EXTENSION_PROVISIONING_PROFILE = "c4495b74-44a8-499e-ad28-4190912bad0b"

def print_usage():
print >>sys.stderr, "Usage: %s release|devbuild" % \
os.path.basename(sys.argv[0])

def build_dependencies():
subprocess.check_call(["pod", "install"])
subprocess.check_call(["xcodebuild",
"-workspace", "AdblockPlusSafari.xcworkspace",
"-scheme", "Pods-AdblockPlusSafariExtension",
"CONFIGURATION_BUILD_DIR=" + BUILD_DIR,
"build"])
"archive"])

def build_apps():
def build_app(build_type, build_name):
if build_type == "release":
build_configuration = "Release"
app_provisioning_profile = RELEASE_APP_PROVISIONING_PROFILE
extension_provisioning_profile = RELEASE_EXTENSION_PROVISIONING_PROFILE
else:
build_configuration = "Devbuild Release"
app_provisioning_profile = DEVBUILD_APP_PROVISIONING_PROFILE
extension_provisioning_profile = DEVBUILD_EXTENSION_PROVISIONING_PROFILE
archive_path = os.path.join(BUILD_DIR, build_name + ".xcarchive")
subprocess.check_call(["xcodebuild",
"-configuration", "Devbuild Release",
"-configuration", build_configuration,
"-scheme", "AdblockPlusSafari",
"CONFIGURATION_BUILD_DIR=" + BUILD_DIR,
"BUILD_NUMBER=" + BUILD_NUMBER,
"APP_PROVISIONING_PROFILE=2591efa4-c166-4956-a62a-e3a0cd41f5a3",
"EXTENSION_PROVISIONING_PROFILE=c4495b74-44a8-499e-ad28-4190912bad0b",
"build"])
"APP_PROVISIONING_PROFILE=" + app_provisioning_profile,
"EXTENSION_PROVISIONING_PROFILE=" + extension_provisioning_profile,
"ENABLE_BITCODE=NO",
"archive",
"-archivePath", archive_path])
return archive_path

def package():
subprocess.check_call(["xcrun", "-sdk", "iphoneos",
"PackageApplication", "-v",
os.path.join(BUILD_DIR, "AdblockPlusSafari.app"),
"-o", os.path.join(BUILD_DIR, PACKAGE_NAME),
"-s", "iPhone Distribution: Eyeo GmbH"])
def package_app(archive_path, build_type, build_name):
subprocess.check_call(["xcodebuild",
"-exportArchive",
"-archivePath", archive_path,
"-exportPath", BUILD_DIR,
"-exportOptionsPlist", build_type + "ExportOptions.plist"])
os.rename(os.path.join(BUILD_DIR, "AdblockPlusSafari.ipa"),
os.path.join(BUILD_DIR, build_name + ".ipa"))

if __name__ == "__main__":
if len(sys.argv) < 2:
print_usage()
sys.exit(1)

build_type = sys.argv[1]
if build_type not in ["devbuild", "release"]:
print_usage()
sys.exit(2)

shutil.rmtree(BUILD_DIR, ignore_errors=True)
build_dependencies()
build_apps()
package()
build_name = "adblockplussafariios-%s-%s" % (build_type, BUILD_NUMBER)
archive_path = build_app(build_type, build_name)
package_app(archive_path, build_type, build_name)
8 changes: 8 additions & 0 deletions devbuildExportOptions.plist
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>enterprise</string>
</dict>
</plist>
8 changes: 8 additions & 0 deletions releaseExportOptions.plist
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
</dict>
</plist>

0 comments on commit b3dbc33

Please sign in to comment.