Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: build.py

Issue 29334710: Issue 3590 - Automate release build generation (Closed)
Patch Set: Address issues Created Jan. 28, 2016, 5:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 import os 4 import os
5 import shutil 5 import shutil
6 import subprocess 6 import subprocess
7 import sys
7 import time 8 import time
8 9
9 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 10 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
10 BUILD_DIR = os.path.join(BASE_DIR, "build") 11 BUILD_DIR = os.path.join(BASE_DIR, "build")
11 BUILD_NUMBER = time.strftime("%Y%m%d%H%M", time.gmtime()) 12 BUILD_NUMBER = time.strftime("%Y%m%d%H%M", time.gmtime())
12 PACKAGE_NAME = "adblockplussafariios-%s.ipa" % BUILD_NUMBER 13 RELEASE_APP_PROVISIONING_PROFILE = "00d92821-2b0f-4036-9b2d-541ce10d0429"
14 RELEASE_EXTENSION_PROVISIONING_PROFILE = "a30dba35-c866-4331-8967-28b9cab60ca2"
15 DEVBUILD_APP_PROVISIONING_PROFILE = "2591efa4-c166-4956-a62a-e3a0cd41f5a3"
16 DEVBUILD_EXTENSION_PROVISIONING_PROFILE = "c4495b74-44a8-499e-ad28-4190912bad0b"
17
18 def print_usage():
19 print >>sys.stderr, "Usage: %s release|devbuild" % \
20 os.path.basename(sys.argv[0])
13 21
14 def build_dependencies(): 22 def build_dependencies():
15 subprocess.check_call(["pod", "install"]) 23 subprocess.check_call(["pod", "install"])
16 subprocess.check_call(["xcodebuild", 24 subprocess.check_call(["xcodebuild",
17 "-workspace", "AdblockPlusSafari.xcworkspace", 25 "-workspace", "AdblockPlusSafari.xcworkspace",
18 "-scheme", "Pods-AdblockPlusSafariExtension", 26 "-scheme", "Pods-AdblockPlusSafariExtension",
19 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR, 27 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR,
20 "build"]) 28 "archive"])
21 29
22 def build_apps(): 30 def build_app(build_type, build_name):
31 if build_type == "release":
32 build_configuration = "Release"
33 app_provisioning_profile = RELEASE_APP_PROVISIONING_PROFILE
34 extension_provisioning_profile = RELEASE_EXTENSION_PROVISIONING_PROFILE
35 else:
36 build_configuration = "Devbuild Release"
37 app_provisioning_profile = DEVBUILD_APP_PROVISIONING_PROFILE
38 extension_provisioning_profile = DEVBUILD_EXTENSION_PROVISIONING_PROFILE
39 archive_path = os.path.join(BUILD_DIR, build_name + ".xcarchive")
23 subprocess.check_call(["xcodebuild", 40 subprocess.check_call(["xcodebuild",
24 "-configuration", "Devbuild Release", 41 "-configuration", build_configuration,
42 "-scheme", "AdblockPlusSafari",
25 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR, 43 "CONFIGURATION_BUILD_DIR=" + BUILD_DIR,
26 "BUILD_NUMBER=" + BUILD_NUMBER, 44 "BUILD_NUMBER=" + BUILD_NUMBER,
27 "APP_PROVISIONING_PROFILE=2591efa4-c166-4956-a62a-e3a0c d41f5a3", 45 "APP_PROVISIONING_PROFILE=" + app_provisioning_profile,
28 "EXTENSION_PROVISIONING_PROFILE=c4495b74-44a8-499e-ad28 -4190912bad0b", 46 "EXTENSION_PROVISIONING_PROFILE=" + extension_provision ing_profile,
29 "build"]) 47 "ENABLE_BITCODE=NO",
Felix Dahlke 2016/01/28 17:25:55 I couldn't make `-exportArchive` work without doin
48 "archive",
49 "-archivePath", archive_path])
50 return archive_path
30 51
31 def package(): 52 def package_app(archive_path, build_type, build_name):
32 subprocess.check_call(["xcrun", "-sdk", "iphoneos", 53 subprocess.check_call(["xcodebuild",
33 "PackageApplication", "-v", 54 "-exportArchive",
34 os.path.join(BUILD_DIR, "AdblockPlusSafari.app"), 55 "-archivePath", archive_path,
35 "-o", os.path.join(BUILD_DIR, PACKAGE_NAME), 56 "-exportPath", BUILD_DIR,
36 "-s", "iPhone Distribution: Eyeo GmbH"]) 57 "-exportOptionsPlist", build_type + "ExportOptions.plis t"])
pavel 2016/02/01 10:18:15 Oh wow. Seeing that -exportOptionsPlist doc was wo
58 os.rename(os.path.join(BUILD_DIR, "AdblockPlusSafari.ipa"),
59 os.path.join(BUILD_DIR, build_name + ".ipa"))
37 60
38 if __name__ == "__main__": 61 if __name__ == "__main__":
62 if len(sys.argv) < 2:
63 print_usage()
64 sys.exit(1)
65
66 build_type = sys.argv[1]
67 if build_type not in ["devbuild", "release"]:
68 print_usage()
69 sys.exit(2)
70
39 shutil.rmtree(BUILD_DIR, ignore_errors=True) 71 shutil.rmtree(BUILD_DIR, ignore_errors=True)
40 build_dependencies() 72 build_dependencies()
41 build_apps() 73 build_name = "adblockplussafariios-%s-%s" % (build_type, BUILD_NUMBER)
42 package() 74 archive_path = build_app(build_type, build_name)
75 package_app(archive_path, build_type, build_name)
OLDNEW

Powered by Google App Engine
This is Rietveld