2018-09-01 00:11:29 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import shutil
|
|
|
|
import re
|
2018-08-29 07:18:24 +02:00
|
|
|
|
2018-09-01 00:11:29 +02:00
|
|
|
buildProductName = "NetNewsWire"
|
|
|
|
buildProductBundleName = "%s.app" % (buildProductName,)
|
2018-08-29 07:18:24 +02:00
|
|
|
|
2018-09-01 00:11:29 +02:00
|
|
|
# WARNING: This will be deleted and replaced during build. It must
|
|
|
|
# correspond to a directory you are willing to see deleted often.
|
2018-09-01 23:12:52 +02:00
|
|
|
buildDir = os.path.expanduser("~/.build")
|
2018-08-29 07:18:24 +02:00
|
|
|
|
2018-09-01 00:11:29 +02:00
|
|
|
# Remove previous build folder and re-create it
|
|
|
|
print("Removing existing build dir: %s" % buildDir)
|
|
|
|
if os.path.exists(buildDir):
|
|
|
|
shutil.rmtree(buildDir)
|
|
|
|
os.mkdir(buildDir)
|
2018-08-29 07:18:24 +02:00
|
|
|
|
2018-09-01 00:11:29 +02:00
|
|
|
# Perform the build
|
|
|
|
print("Building...")
|
|
|
|
subprocess.call(["xcodebuild", "-workspace", "NetNewsWire.xcworkspace", "-scheme", "NetNewsWire", "-derivedDataPath", buildDir, "-configuration", "Release"])
|
2018-08-29 07:18:24 +02:00
|
|
|
|
2018-09-01 00:11:29 +02:00
|
|
|
# Obtain the version from the built product
|
|
|
|
currentVersionBuiltAppPath = os.path.join(buildDir, "Build", "Products", "Release", buildProductBundleName)
|
|
|
|
infoPlistPath = os.path.join(currentVersionBuiltAppPath, "Contents/Info.plist")
|
|
|
|
infoPlistFile = open(infoPlistPath, "r")
|
|
|
|
infoPlistContent = infoPlistFile.read()
|
|
|
|
infoPlistFile.close()
|
|
|
|
bundleVersionPattern = "(?s)[\t ]*<key>CFBundleShortVersionString<\/key>[\n\t ]*<string>(.*?)<\/string>"
|
|
|
|
matches = re.search(bundleVersionPattern, infoPlistContent)
|
|
|
|
appVersion = matches.group(1)
|
2018-08-29 07:18:24 +02:00
|
|
|
|
2018-09-01 00:11:29 +02:00
|
|
|
# Remove previous build artifacts
|
|
|
|
outputDir = os.path.expanduser("~")
|
|
|
|
currentVersionStagedAppPath = os.path.join(outputDir, buildProductBundleName)
|
|
|
|
currentVersionZipName = "NetNewsWire%s.zip" % appVersion
|
|
|
|
currentVersionZipPath = os.path.join(outputDir, currentVersionZipName)
|
|
|
|
if os.path.exists(currentVersionZipPath):
|
|
|
|
print("Removing previous app at %s" % currentVersionZipPath)
|
|
|
|
os.remove(currentVersionZipPath)
|
2018-08-29 07:18:24 +02:00
|
|
|
|
2018-09-01 00:11:29 +02:00
|
|
|
# Package new build artifacts
|
|
|
|
print("Copying build product from \"%s\" to \"%s\"" % (currentVersionBuiltAppPath, currentVersionStagedAppPath))
|
|
|
|
subprocess.call(["ditto", currentVersionBuiltAppPath, currentVersionStagedAppPath])
|
|
|
|
print("Zipping to \"%s\"" % currentVersionZipName)
|
2018-09-01 23:12:52 +02:00
|
|
|
|
|
|
|
# Documented in "man ditto" as creating an archive "similarly to the Finder's Compress functionality"
|
|
|
|
subprocess.call(["ditto", "-c", "-k", "--sequesterRsrc", "--keepParent", currentVersionBuiltAppPath, currentVersionZipPath])
|
2018-09-01 00:11:29 +02:00
|
|
|
|
|
|
|
# Archive a permanent copy
|
|
|
|
archiveDir = os.path.expanduser("~/Archive/Releases")
|
|
|
|
currentVersionArchivePath = os.path.join(archiveDir, currentVersionZipName)
|
|
|
|
print("Copying archive to to \"%s\"" % currentVersionArchivePath)
|
|
|
|
subprocess.call(["ditto", currentVersionZipPath, currentVersionArchivePath])
|
|
|
|
|
|
|
|
latestVersionZipName = "NetNewsWire-latest.zip"
|
|
|
|
latestVersionZipPath = os.path.join(outputDir, latestVersionZipName)
|
|
|
|
print("Copying archive to to \"%s\"" % latestVersionZipPath)
|
|
|
|
subprocess.call(["cp", currentVersionZipPath, latestVersionZipPath])
|
|
|
|
|
|
|
|
# Reveal the built archive
|
|
|
|
print("Revealing in Finder: \"%s\"" % latestVersionZipPath)
|
|
|
|
subprocess.call(["open", "-R", latestVersionZipPath])
|