-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_latest_build.py
More file actions
38 lines (31 loc) · 1.28 KB
/
copy_latest_build.py
File metadata and controls
38 lines (31 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Utility script for Jenkins.
# Takes two arguments:
# * source root directory
# * destination directory.
# Identifies the newest subdirectory under the source root directory and copies its
# contenst into the destination directory.
# This is used in assembling the latest version of our app for codesigning/notarization.
import os
import sys
from distutils.dir_util import copy_tree
if len(sys.argv) != 3:
print "CopyLatestBuild.py: need source path and dest path."
exit(-1)
sourceRootDirectory = sys.argv[1]
destDirectory = sys.argv[2]
# find the subdirectory of sourceRootDirectory with the newest timestamp
newestSubdirectoryPath = None
newestSubdirectoryModifyTime = 0
for subdirectory in os.listdir(sourceRootDirectory):
if subdirectory.startswith("."):
continue;
subdirectoryPath = os.path.join(sourceRootDirectory, subdirectory)
subdirectoryModifyTime = os.path.getmtime(subdirectoryPath)
if subdirectoryModifyTime > newestSubdirectoryModifyTime:
newestSubdirectoryModifyTime = subdirectoryModifyTime
newestSubdirectoryPath = subdirectoryPath
if newestSubdirectoryPath == None:
print "CopyLatestBuild.py: Could not find newest subdirectory."
exit(-2)
print "Copying latest build ", newestSubdirectoryPath, " to ", destDirectory
copy_tree(newestSubdirectoryPath, destDirectory)