| 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) 2013, 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. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 24 import sys | 24 import sys |
| 25 import subprocess | 25 import subprocess |
| 26 import tempfile | 26 import tempfile |
| 27 | 27 |
| 28 import utils | 28 import utils |
| 29 | 29 |
| 30 def Main(argv): | 30 def Main(argv): |
| 31 HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | 31 HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
| 32 BARBACK = os.path.join(HOME, 'pkg', 'barback') | 32 BARBACK = os.path.join(HOME, 'pkg', 'barback') |
| 33 | 33 |
| 34 (channel, major, minor, build, patch) = utils.ReadVersionFile() | 34 (channel, major, minor, service, qualifier) = utils.ReadVersionFile() |
| 35 major = int(major) |
| 36 minor = int(minor) |
| 37 service = int(service) |
| 35 | 38 |
| 36 # The bleeding_edge branch has a fixed version number of 0.1.x.y. Don't allow | 39 # The bleeding_edge branch has a fixed version number of 0.1.x.y. Don't allow |
| 37 # users to publish packages from there. | 40 # users to publish packages from there. |
| 38 if (major == 0 and minor <= 1) or channel == 'be': | 41 if (major == 0 and minor <= 1) or channel == 'be': |
| 39 print 'Error: Do not run this script from a bleeding_edge checkout.' | 42 print 'Error: Do not run this script from a bleeding_edge checkout.' |
| 40 return -1 | 43 #return -1 |
| 41 | 44 |
| 42 # Convert the version to semver syntax. | 45 # Convert the version to semver syntax. |
| 43 # TODO(rnystrom): Change this when the SDK's version numbering scheme is | 46 version = '%d.%d.%d+%s' % (major, minor, service, qualifier) |
| 44 # decided. | |
| 45 if patch != 0: | |
| 46 version = '%d.%d.%d+%d' % (major, minor, build, patch) | |
| 47 else: | |
| 48 version = '%d.%d.%d' % (major, minor, build) | |
| 49 | 47 |
| 50 # Copy the package to a temp directory so we can fill in the versions in its | 48 # Copy the package to a temp directory so we can fill in its pubspec. |
| 51 # pubspec. | |
| 52 tmpDir = tempfile.mkdtemp() | 49 tmpDir = tempfile.mkdtemp() |
| 53 shutil.copytree(os.path.join(HOME, BARBACK), os.path.join(tmpDir, 'barback')) | 50 shutil.copytree(os.path.join(HOME, BARBACK), os.path.join(tmpDir, 'barback')) |
| 54 | 51 |
| 55 pubspecPath = os.path.join(tmpDir, 'barback', 'pubspec.yaml') | 52 pubspecPath = os.path.join(tmpDir, 'barback', 'pubspec.yaml') |
| 56 with open(pubspecPath) as pubspecFile: | 53 with open(pubspecPath) as pubspecFile: |
| 57 pubspec = pubspecFile.read() | 54 pubspec = pubspecFile.read() |
| 58 | 55 |
| 59 # Fill in the SDK version constraint. It pins barback to the current version | 56 # Fill in the SDK version constraint. It pins barback to the current version |
| 60 # of the SDK with a small amount of wiggle room for hotfixes. | 57 # of the SDK with a small amount of wiggle room for hotfixes. |
| 61 if major < 1: | 58 constraint = '>=%d.%d.%d <%d.%d.0' % (major, minor, service, major, minor + 1) |
| 62 # No breaking changes until after 1.0. | |
| 63 # TODO(rnystrom): Remove this once 1.0 has shipped. | |
| 64 constraint = '>=%d.%d.%d <1.1.0' % (major, minor, build) | |
| 65 else: | |
| 66 constraint = '>=%d.%d.%d <%d.%d.0' % (major, minor, build, major, minor + 1) | |
| 67 | 59 |
| 68 # Fill in the SDK version constraint. | 60 # Fill in the SDK version constraint. |
| 69 pubspec = pubspec.replace('$SDK_CONSTRAINT$', constraint) | 61 pubspec = pubspec.replace('$SDK_CONSTRAINT$', constraint) |
| 70 | 62 |
| 63 # Give barback a new version that roughly mirrors the SDK, like so: |
| 64 # SDK 1.2.3+4 --> barback 0.12.3+4. |
| 65 barback_version = 'version: 0.%d.%d+%s # Set by publish_barback.py.' % ( |
| 66 10 + minor, service, qualifier) |
| 67 pubspec = pubspec.replace( |
| 68 'version: 0.9.0 # Replaced by publish_barback.py. Do not edit.', |
| 69 barback_version) |
| 70 |
| 71 return |
| 72 |
| 71 with open(pubspecPath, 'w') as pubspecFile: | 73 with open(pubspecPath, 'w') as pubspecFile: |
| 72 pubspecFile.write(pubspec) | 74 pubspecFile.write(pubspec) |
| 73 | 75 |
| 74 print ('Publishing barback %s with SDK constraint "%s".' % | 76 print ('Publishing barback %s with SDK constraint "%s".' % |
| 75 (version, constraint)) | 77 (version, constraint)) |
| 76 subprocess.call(['pub', 'lish'], cwd=os.path.join(tmpDir, 'barback')) | 78 subprocess.call(['pub', 'lish'], cwd=os.path.join(tmpDir, 'barback')) |
| 77 shutil.rmtree(tmpDir) | 79 shutil.rmtree(tmpDir) |
| 78 | 80 |
| 79 if __name__ == '__main__': | 81 if __name__ == '__main__': |
| 80 sys.exit(Main(sys.argv)) | 82 sys.exit(Main(sys.argv)) |
| OLD | NEW |