Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 4 # for details. All rights reserved. Use of this source code is governed by a | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 # | |
| 7 # Script to push the barback package to pub. Barback is treated specially | |
| 8 # because it is tightly coupled to the SDK. Pub includes its own copy of | |
| 9 # barback but also includes code that is run against the user's copy of barback. | |
| 10 # To ensure that those are in sync, each version of the SDK has a single | |
| 11 # version of barback that it works with. | |
| 12 # | |
| 13 # We enforce this by placing a narrow SDK constraint in each version of barback. | |
| 14 # This ensures the only barback that will be selected is the one that works | |
| 15 # with the user's SDK. | |
|
nweiz
2013/11/07 00:55:55
Should we mention here that this process will chan
Bob Nystrom
2013/11/09 01:24:26
It's actually the barback public API, not the wire
| |
| 16 # | |
| 17 # Usage: publish_barback.py | |
| 18 # | |
| 19 # "pub" must be in PATH. | |
| 20 | |
| 21 import os | |
| 22 import os.path | |
| 23 import re | |
| 24 import shutil | |
| 25 import sys | |
| 26 import subprocess | |
| 27 import tempfile | |
| 28 | |
| 29 def ReadVersion(file, field): | |
| 30 for line in open(file).read().split('\n'): | |
| 31 [k, v] = re.split('\s+', line) | |
| 32 if field == k: | |
| 33 return int(v) | |
| 34 | |
| 35 def Main(argv): | |
| 36 HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | |
| 37 BARBACK = os.path.join(HOME, 'pkg', 'barback') | |
| 38 | |
| 39 versionFile = os.path.join(HOME, 'tools', 'VERSION') | |
| 40 major = ReadVersion(versionFile, 'MAJOR') | |
| 41 minor = ReadVersion(versionFile, 'MINOR') | |
| 42 build = ReadVersion(versionFile, 'BUILD') | |
| 43 patch = ReadVersion(versionFile, 'PATCH') | |
| 44 | |
| 45 # bleeding_edge has a fixed version number of 0.1.x.y . Don't allow users | |
| 46 # to publish packages from bleeding_edge. | |
| 47 if major == 0 and minor <= 1: | |
| 48 print 'Error: Do not run this script from a bleeding_edge checkout.' | |
| 49 return -1 | |
| 50 | |
| 51 # Convert the version to semver syntax. | |
| 52 # TODO(rnystrom): Change this when the SDK's version numbering scheme is | |
| 53 # decided. | |
|
nweiz
2013/11/07 00:55:55
Is there a bug number you can list here?
Bob Nystrom
2013/11/09 01:24:26
Nope. I don't know if it makes sense to file a bug
| |
| 54 if patch != 0: | |
| 55 version = '%d.%d.%d+%d' % (major, minor, build, patch) | |
| 56 else: | |
| 57 version = '%d.%d.%d' % (major, minor, build) | |
| 58 | |
| 59 # Copy the package to a temp directory so we can fill in the versions in its | |
| 60 # pubspec. | |
| 61 tmpDir = tempfile.mkdtemp() | |
| 62 shutil.copytree(os.path.join(HOME, BARBACK), os.path.join(tmpDir, 'barback')) | |
| 63 | |
| 64 pubspecPath = os.path.join(tmpDir, 'barback', 'pubspec.yaml') | |
| 65 with open(pubspecPath) as pubspecFile: | |
| 66 pubspec = pubspecFile.read() | |
| 67 | |
| 68 # Fill in the SDK version constraint. It pins barback to the current version | |
| 69 # of the SDK with a small amount of wiggle room for hotfixes. | |
| 70 if major < 1: | |
| 71 # No breaking changes until after 1.0. | |
| 72 # TODO(rnystrom): Remove this once 1.0 has shipped. | |
| 73 constraint = '>=%d.%d.%d <=1.0.0' % (major, minor, build) | |
|
nweiz
2013/11/07 00:55:55
I think this should be ">=%d.%d.%d <1.1.0", in cas
Bob Nystrom
2013/11/09 01:24:26
Done.
| |
| 74 else: | |
| 75 constraint = '>=%d.%d.%d <%d.%d.0' % (major, minor, build, major, minor + 1) | |
| 76 | |
| 77 # Fill in the SDK version constraint. | |
| 78 pubspec = pubspec.replace('$SDK_CONSTRAINT$', constraint) | |
| 79 | |
| 80 with open(pubspecPath, 'w') as pubspecFile: | |
| 81 pubspecFile.write(pubspec) | |
| 82 | |
| 83 print 'Publishing version %s of barback to pub with SDK constraint "%s".' % (v ersion, constraint) | |
|
nweiz
2013/11/07 00:55:55
Long line
Bob Nystrom
2013/11/09 01:24:26
Done.
| |
| 84 subprocess.call(['pub', 'lish'], cwd=os.path.join(tmpDir, 'barback')) | |
| 85 shutil.rmtree(tmpDir) | |
| 86 | |
| 87 if __name__ == '__main__': | |
| 88 sys.exit(Main(sys.argv)) | |
| OLD | NEW |