summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-11-15 16:33:05 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-16 08:33:13 (GMT)
commit321754f6300e0d53b7c2a5cbc87865d5fe73b68a (patch)
treec6c40b6573222520a08e0315398c9026ed411a21
parent6a033c0efade676403c372f8afecf95b5f9afc79 (diff)
downloadswift-321754f6300e0d53b7c2a5cbc87865d5fe73b68a.zip
swift-321754f6300e0d53b7c2a5cbc87865d5fe73b68a.tar.bz2
Update GenerateAppCastFeeds.py according to recent discussions
The script will now take stable/testing releases from the …/downloads/releases path using per-release folders inside, and only dev builds from the …/downloads/development/mac path without per-release folder. Test-Information: Ran the script on macOS 10.12.1 on a mirror and verified that it generated the correct feeds. Change-Id: I9b2f5780cfcdafb64d0d75d1483643b522ea7bb2
-rwxr-xr-xBuildTools/GenerateAppCastFeeds.py46
1 files changed, 34 insertions, 12 deletions
diff --git a/BuildTools/GenerateAppCastFeeds.py b/BuildTools/GenerateAppCastFeeds.py
index fe39e3c..3b4bf42 100755
--- a/BuildTools/GenerateAppCastFeeds.py
+++ b/BuildTools/GenerateAppCastFeeds.py
@@ -31,14 +31,14 @@ class Release:
def __repr__(self):
return "Release(%s, %s, %s, %s)" % (self.version, self.url, self.sizeInBytes, self.date)
-def getReleaseFromAbsoluteFilePath(absolutePath, downloadsFolder, downloadsURL):
+def getReleaseFromAbsoluteFilePath(absolutePath, downloadsFolder, releasesURL):
version = os.path.splitext(absolutePath.split('/')[-1])[0]
sizeInBytes = os.path.getsize(absolutePath)
date = datetime.datetime.fromtimestamp(os.path.getmtime(absolutePath))
- absoluteURL = urlparse.urljoin(downloadsURL, os.path.relpath(absolutePath, downloadsFolder))
+ absoluteURL = urlparse.urljoin(releasesURL, os.path.relpath(absolutePath, downloadsFolder))
return Release(version, absoluteURL, sizeInBytes, date)
-def getReleaseFromReleaseFolder(releaseFolder, downloadsFolder, downloadsURL, extension):
+def getReleaseFromReleaseFolder(releaseFolder, downloadsFolder, releasesURL, extension):
release = None
regex = re.compile(fnmatch.translate(extension))
@@ -46,21 +46,36 @@ def getReleaseFromReleaseFolder(releaseFolder, downloadsFolder, downloadsURL, ex
for file in files:
fileFullPath = os.path.join(releaseFolder, file)
if regex.match(fileFullPath):
- release = getReleaseFromAbsoluteFilePath(fileFullPath, downloadsFolder, downloadsURL)
+ release = getReleaseFromAbsoluteFilePath(fileFullPath, downloadsFolder, releasesURL)
return release
-def getReleaseFilesInDownloadsFolder(downloadsFolder, downloadsURL, extension):
- releasesFolder = os.path.join(downloadsFolder, "releases")
+def getReleaseFilesInReleasesFolder(releasesFolder, releasesURL, extension):
releases = []
dirs = [d for d in os.listdir(releasesFolder) if os.path.isdir(os.path.join(releasesFolder, d))]
for d in dirs:
- release = getReleaseFromReleaseFolder(os.path.join(releasesFolder, d), downloadsFolder, downloadsURL, extension)
+ release = getReleaseFromReleaseFolder(os.path.join(releasesFolder, d), releasesFolder, releasesURL, extension)
if release:
releases.append(release)
return releases
+def getReleaseFilesInDevelopmentFolder(developmentMacFolder, developmentMacURL, extension):
+ extensionRegex = re.compile(fnmatch.translate(extension))
+ devPatternRegex = re.compile(".+-dev\d+")
+
+ releases = []
+
+ files = [f for f in os.listdir(developmentMacFolder) if os.path.isfile(os.path.join(developmentMacFolder, f))]
+ for f in files:
+ # Only use dev builds from the development folder.
+ if devPatternRegex.match(f):
+ fileFullPath = os.path.join(developmentMacFolder, f)
+ if extensionRegex.match(fileFullPath):
+ releases.append(getReleaseFromAbsoluteFilePath(fileFullPath, developmentMacFolder, developmentMacURL))
+
+ return releases
+
def writeAppcastFile(filename, title, description, regexPattern, appcastURL, releases):
template = jinja2.Template('''<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
@@ -104,25 +119,32 @@ parser.add_argument('downloadsURL', type=str, help="e.g. https://swift.im/downlo
args = parser.parse_args()
-releases = getReleaseFilesInDownloadsFolder(args.downloadsFolder, args.downloadsURL, "*.dmg")
+releasesPath = os.path.join(args.downloadsFolder, "releases")
+developmentMacPath = os.path.join(args.downloadsFolder, "development", "mac")
+
+manualReleases = getReleaseFilesInReleasesFolder(releasesPath, urlparse.urljoin(args.downloadsURL, "releases/"), "*.dmg")
+manualReleases.sort(key=lambda release: release.date, reverse=True)
+
+automaticReleases = manualReleases
+automaticReleases.extend(getReleaseFilesInDevelopmentFolder(developmentMacPath, urlparse.urljoin(args.downloadsURL, "development/mac/"), "*.dmg"))
+automaticReleases.sort(key=lambda release: release.date, reverse=True)
-releases.sort(key=lambda release: release.date, reverse=True)
writeAppcastFile(filename=os.path.join(args.downloadsFolder, "swift-stable-appcast-mac.xml"),
title="Swift Stable Releases",
description="",
regexPattern="^Swift\-\d+(\.\d+)?(\.\d+)?$",
appcastURL=urlparse.urljoin(args.downloadsURL, "swift-stable-appcast-mac.xml"),
- releases=releases)
+ releases=manualReleases)
writeAppcastFile(filename=os.path.join(args.downloadsFolder, "swift-testing-appcast-mac.xml"),
title="Swift Testing Releases",
description="",
regexPattern="^Swift\-\d+(\.\d+)?(\.\d+)?(beta\d+)?(rc\d+)?$",
appcastURL=urlparse.urljoin(args.downloadsURL, "swift-testing-appcast-mac.xml"),
- releases=releases)
+ releases=manualReleases)
writeAppcastFile(filename=os.path.join(args.downloadsFolder, "swift-development-appcast-mac.xml"),
title="Swift Development Releases",
description="",
regexPattern="^Swift\-\d+(\.\d+)?(\.\d+)?(alpha)?(beta\d+)?(rc\d+)?(-dev\d+)?$",
appcastURL=urlparse.urljoin(args.downloadsURL, "swift-development-appcast-mac.xml"),
- releases=releases)
+ releases=automaticReleases)