Repository navigation
Expand file tree
/
Copy pathtasks.py
More file actions
86 lines (60 loc) · 2.13 KB
/
Copy pathtasks.py
File metadata and controls
86 lines (60 loc) · 2.13 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import datetime
from invoke.tasks import task
from invoke.runner import run
VERSION = open('version.txt').read().strip()
BASE_S3_ARGS = ['--acl-public']
JS_S3_ARGS = ['--guess-mime-type', '--add-header "Content-Encoding: gzip"']
SHORT_FUTURE = datetime.timedelta(hours=1)
MEDIUM_FUTURE = datetime.timedelta(days=1)
FAR_FUTURE = datetime.timedelta(days=365)
@task
def test():
run('node_modules/.bin/jshint .')
run('node_modules/.bin/mocha-phantomjs -R dot test/index.html')
@task
def build():
"Publish a nightly build"
test.body()
make(get_rev())
@task
def release():
"Publish a tagged version"
test.body()
make(VERSION)
def make(version):
run('VERSION=%s make raven' % version)
for raven in ('raven.js', 'raven.min.js'):
gzip(raven)
publish(raven, version, BASE_S3_ARGS + JS_S3_ARGS)
publish('raven.min.map', version, BASE_S3_ARGS)
def gzip(path):
run('gzip -6 dist/%s' % path)
run('mv dist/%s.gz dist/%s' % (path, path))
def publish(path, version, args):
if '.' in version:
package = 'dist'
cache = get_cache_headers(FAR_FUTURE)
branch = version
else:
package = 'build'
cache = get_cache_headers(SHORT_FUTURE)
branch = get_branch()
upload(path, args + cache, package, branch)
if package == 'dist':
version = version.split('.')
version.pop()
cache = get_cache_headers(MEDIUM_FUTURE)
while version:
upload(path, args + cache, package, '.'.join(version))
version.pop()
def upload(path, args, package, build):
run('s3cmd put %s dist/%s s3://getsentry-cdn/%s/%s/%s' %
(' '.join(args), path, package, build, path))
def get_cache_headers(delta):
expires = datetime.datetime.utcnow() + delta
return ['--add-header "Cache-Control: public, max-age=%d"' % delta.total_seconds(),
'--add-header "Expires: %s GMT"' % expires.strftime('%a, %d %h %Y %T')]
def get_branch():
return run('git rev-parse --short --abbrev-ref HEAD', hide='both').stdout.strip()
def get_rev():
return run('git rev-parse --short HEAD', hide='both').stdout.strip()