Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 # | 6 # |
| 7 # Script to push the barback package to pub. Barback is treated specially | 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 | 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. | 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 | 10 # To ensure that those are in sync, each version of the SDK has a single |
| 11 # version of barback that it works with. | 11 # version of barback that it works with. |
| 12 # | 12 # |
| 13 # We enforce this by placing a narrow SDK constraint in each version of barback. | 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 | 14 # This ensures the only barback that will be selected is the one that works |
| 15 # with the user's SDK. Once barback is more stable, we can loosen this. | 15 # with the user's SDK. Once barback is more stable, we can loosen this. |
| 16 # | 16 # |
| 17 # Usage: publish_barback.py | 17 # Usage: publish_barback.py |
| 18 # | 18 # |
| 19 # "pub" must be in PATH. | 19 # "pub" must be in PATH. |
| 20 | 20 |
| 21 import os | 21 import os |
| 22 import os.path | 22 import os.path |
| 23 import re | |
| 24 import shutil | 23 import shutil |
| 25 import sys | 24 import sys |
| 26 import subprocess | 25 import subprocess |
| 27 import tempfile | 26 import tempfile |
| 28 | 27 |
| 29 def ReadVersion(file, field): | 28 import utils |
| 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 | 29 |
| 35 def Main(argv): | 30 def Main(argv): |
| 36 HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | 31 HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
| 37 BARBACK = os.path.join(HOME, 'pkg', 'barback') | 32 BARBACK = os.path.join(HOME, 'pkg', 'barback') |
| 38 | 33 |
| 39 versionFile = os.path.join(HOME, 'tools', 'VERSION') | 34 (channel, major, minor, build, patch) = utils.ReadVersionFile() |
| 40 major = ReadVersion(versionFile, 'MAJOR') | |
| 41 minor = ReadVersion(versionFile, 'MINOR') | |
| 42 build = ReadVersion(versionFile, 'BUILD') | |
| 43 patch = ReadVersion(versionFile, 'PATCH') | |
| 44 | 35 |
| 45 # The bleeding_edge branch has a fixed version number of 0.1.x.y. Don't allow | 36 # The bleeding_edge branch has a fixed version number of 0.1.x.y. Don't allow |
| 46 # users to publish packages from there. | 37 # users to publish packages from there. |
| 47 if major == 0 and minor <= 1: | 38 if (major == 0 and minor <= 1) or channel == 'be': |
|
Bob Nystrom
2013/11/25 17:41:59
If channel will reliably be set, you can just remo
kustermann
2013/11/26 14:17:32
I thought about removing it, but it doesn't hurt i
| |
| 48 print 'Error: Do not run this script from a bleeding_edge checkout.' | 39 print 'Error: Do not run this script from a bleeding_edge checkout.' |
| 49 return -1 | 40 return -1 |
| 50 | 41 |
| 51 # Convert the version to semver syntax. | 42 # Convert the version to semver syntax. |
| 52 # TODO(rnystrom): Change this when the SDK's version numbering scheme is | 43 # TODO(rnystrom): Change this when the SDK's version numbering scheme is |
| 53 # decided. | 44 # decided. |
| 54 if patch != 0: | 45 if patch != 0: |
| 55 version = '%d.%d.%d+%d' % (major, minor, build, patch) | 46 version = '%d.%d.%d+%d' % (major, minor, build, patch) |
| 56 else: | 47 else: |
| 57 version = '%d.%d.%d' % (major, minor, build) | 48 version = '%d.%d.%d' % (major, minor, build) |
| 58 | 49 |
| 59 # Copy the package to a temp directory so we can fill in the versions in its | 50 # Copy the package to a temp directory so we can fill in the versions in its |
| 60 # pubspec. | 51 # pubspec. |
| 61 tmpDir = tempfile.mkdtemp() | 52 tmpDir = tempfile.mkdtemp() |
| 62 shutil.copytree(os.path.join(HOME, BARBACK), os.path.join(tmpDir, 'barback')) | 53 shutil.copytree(os.path.join(HOME, BARBACK), os.path.join(tmpDir, 'barback')) |
| 63 | 54 |
| 64 pubspecPath = os.path.join(tmpDir, 'barback', 'pubspec.yaml') | 55 pubspecPath = os.path.join(tmpDir, 'barback', 'pubspec.yaml') |
| 65 with open(pubspecPath) as pubspecFile: | 56 with open(pubspecPath) as pubspecFile: |
| 66 pubspec = pubspecFile.read() | 57 pubspec = pubspecFile.read() |
| 67 | 58 |
| 68 # Fill in the SDK version constraint. It pins barback to the current version | 59 # 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. | 60 # of the SDK with a small amount of wiggle room for hotfixes. |
| 70 if major < 1: | 61 if major < 1: |
| 71 # No breaking changes until after 1.0. | 62 # No breaking changes until after 1.0. |
| 72 # TODO(rnystrom): Remove this once 1.0 has shipped. | 63 # TODO(rnystrom): Remove this once 1.0 has shipped. |
| 73 constraint = '>=%d.%d.%d <1.1.0' % (major, minor, build) | 64 constraint = '>=%d.%d.%d <1.1.0' % (major, minor, build) |
| 74 else: | 65 else: |
| 75 constraint = '>=%d.%d.%d <%d.%d.0' % (major, minor, build, major, minor + 1) | 66 constraint = '>=%d.%d.%d <%d.%d.0' % (major, minor, build, major, minor + 1) |
|
Bob Nystrom
2013/11/25 17:41:59
Hey Rico and Martin: until I know what actual numb
kustermann
2013/11/26 14:17:32
I think we all agree that having semantic versions
| |
| 76 | 67 |
| 77 # Fill in the SDK version constraint. | 68 # Fill in the SDK version constraint. |
| 78 pubspec = pubspec.replace('$SDK_CONSTRAINT$', constraint) | 69 pubspec = pubspec.replace('$SDK_CONSTRAINT$', constraint) |
| 79 | 70 |
| 80 with open(pubspecPath, 'w') as pubspecFile: | 71 with open(pubspecPath, 'w') as pubspecFile: |
| 81 pubspecFile.write(pubspec) | 72 pubspecFile.write(pubspec) |
| 82 | 73 |
| 83 print ('Publishing barback %s with SDK constraint "%s".' % | 74 print ('Publishing barback %s with SDK constraint "%s".' % |
| 84 (version, constraint)) | 75 (version, constraint)) |
| 85 subprocess.call(['pub', 'lish'], cwd=os.path.join(tmpDir, 'barback')) | 76 subprocess.call(['pub', 'lish'], cwd=os.path.join(tmpDir, 'barback')) |
| 86 shutil.rmtree(tmpDir) | 77 shutil.rmtree(tmpDir) |
| 87 | 78 |
| 88 if __name__ == '__main__': | 79 if __name__ == '__main__': |
| 89 sys.exit(Main(sys.argv)) | 80 sys.exit(Main(sys.argv)) |
| OLD | NEW |