blob: ae88b5c2a0099c303d372d224c84836e98b98b0d [file] [log] [blame]
Brian O'Connor0fed5752015-05-04 18:15:29 -07001#!/usr/bin/env python
2# -----------------------------------------------------------------------------
3# Uploads ONOS distributable bits.
4# -----------------------------------------------------------------------------
5
6#FIXME need to export s3Creds
7
8import re
9from os import listdir
10from os.path import isfile, join
11
12from uploadToS3 import uploadFile
13
14nightlyTag = 'NIGHTLY'
15bitsPath = '/tmp'
16
Thomas Vachuskabe1a1962016-10-25 16:59:29 -070017prefix = 'onos-(?:test-)?(\d+\.\d+\.\d+)'
Brian O'Connor0fed5752015-05-04 18:15:29 -070018buildNum = '\.?([\w-]*)'
Brian O'Connor71e147e2015-09-18 15:18:14 -070019ext = '\.(?:tar\.gz|zip|deb|noarch\.rpm)'
Brian O'Connor0fed5752015-05-04 18:15:29 -070020
Thomas Vachuskabe1a1962016-10-25 16:59:29 -070021def findBits( path, target_version=None ):
Brian O'Connor0fed5752015-05-04 18:15:29 -070022 for file in listdir( path ):
23 filePath = join( path, file )
24 if not isfile( filePath ):
25 continue
26
27 regex = prefix + buildNum + ext
28 match = re.match( regex, file )
29 if match:
30 version = match.group(1)
Thomas Vachuskabe1a1962016-10-25 16:59:29 -070031 if target_version is not None and version != target_version:
32 print 'Skipping %s...' % filePath
33 continue
Brian O'Connor0fed5752015-05-04 18:15:29 -070034 build = match.group(2)
35 if build:
Brian O'Connor30a412d2015-05-21 18:04:26 -070036 if 'NIGHTLY' in build or 'rc' in build:
Brian O'Connor0fed5752015-05-04 18:15:29 -070037 uploadFile(filePath, dest='nightly/')
38 else:
39 #no build; this is a release
40 uploadFile(filePath, dest='release/')
41
42if __name__ == '__main__':
Thomas Vachuskabe1a1962016-10-25 16:59:29 -070043 import sys
44
45 version = sys.argv[1] if len(sys.argv) >= 2 else None
46 findBits( '/tmp', version )