New release process (#14061)

Generate the "version" file from git tags.
Remove the old VERSION file and mentions of versions in pubspec.yaml files.
Replace the old update_versions.dart script with a new roll_dev.dart script.
Update "flutter channel".
Update "flutter upgrade", including making it transition from alpha to dev.
Update "flutter --version" and "flutter doctor".
This commit is contained in:
Ian Hickson
2018-01-18 07:59:06 -08:00
committed by GitHub
parent 4353297079
commit 9e42e4b88f
20 changed files with 340 additions and 279 deletions

View File

@@ -1,5 +1,4 @@
name: flutter_devicelab
version: 0.0.1
author: Flutter Authors <flutter-dev@googlegroups.com>
description: Flutter continuous integration performance and correctness tests.
homepage: https://github.com/flutter/flutter

View File

@@ -8,7 +8,6 @@ import 'dart:io';
import 'package:intl/intl.dart';
import 'package:path/path.dart' as path;
import 'update_versions.dart';
/// Whether to report all error messages (true) or attempt to filter out some
/// known false positives (false).
@@ -36,15 +35,18 @@ Future<Null> main(List<String> args) async {
if (path.basename(Directory.current.path) == 'tools')
Directory.current = Directory.current.parent.parent;
final RawVersion version = new RawVersion('VERSION');
final ProcessResult flutter = Process.runSync('flutter', <String>[]);
final File versionFile = new File('version');
if (flutter.exitCode != 0 || !versionFile.existsSync())
throw new Exception('Failed to determine Flutter version.');
final String version = versionFile.readAsStringSync();
// Create the pubspec.yaml file.
final StringBuffer buf = new StringBuffer('''
name: Flutter
homepage: https://flutter.io
version: $version
dependencies:
''');
final StringBuffer buf = new StringBuffer();
buf.writeln('name: Flutter');
buf.writeln('homepage: https://flutter.io');
buf.writeln('version: $version');
buf.writeln('dependencies:');
for (String package in findPackageNames()) {
buf.writeln(' $package:');
buf.writeln(' sdk: flutter');
@@ -100,7 +102,7 @@ dependencies:
workingDirectory: 'dev/docs',
environment: pubEnvironment,
);
print('\n${result.stdout}');
print('\n${result.stdout}flutter version: $version\n');
// Generate the documentation.
final List<String> args = <String>[
@@ -159,7 +161,10 @@ void createFooter(String footerPath) {
const int kGitRevisionLength = 10;
final ProcessResult gitResult = Process.runSync('git', <String>['rev-parse', 'HEAD']);
String gitRevision = (gitResult.exitCode == 0) ? gitResult.stdout.trim() : 'unknown';
if (gitResult.exitCode != 0)
throw 'git exit with non-zero exit code: ${gitResult.exitCode}';
String gitRevision = gitResult.stdout.trim();
gitRevision = gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision;
final String timestamp = new DateFormat('yyyy-MM-dd HH:mm').format(new DateTime.now());

158
dev/tools/lib/roll_dev.dart Normal file
View File

@@ -0,0 +1,158 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Rolls the dev channel.
// Only tested on Linux.
//
// See: https://github.com/flutter/flutter/wiki/Release-process
import 'dart:io';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
const String kIncrement = 'increment';
const String kX = 'x';
const String kY = 'y';
const String kZ = 'z';
const String kHelp = 'help';
void main(List<String> args) {
// If we're run from the `tools` dir, set the cwd to the repo root.
if (path.basename(Directory.current.path) == 'tools')
Directory.current = Directory.current.parent.parent;
final ArgParser argParser = new ArgParser(allowTrailingOptions: false);
argParser.addOption(
kIncrement,
help: 'Specifies which part of the x.y.z version number to increment. Required.',
valueHelp: 'level',
allowed: <String>[kX, kY, kZ],
allowedHelp: <String, String>{
kX: 'Indicates a major development, e.g. typically changed after a big press event.',
kY: 'Indicates a minor development, e.g. typically changed after a beta release.',
kZ: 'Indicates the least notable level of change. You normally want this.',
},
);
argParser.addFlag(kHelp, negatable: false, help: 'Show this help message.', hide: true);
ArgResults argResults;
try {
argResults = argParser.parse(args);
} on ArgParserException catch (error) {
print(error.message);
print(argParser.usage);
exit(1);
}
final String level = argResults[kIncrement];
final bool help = argResults[kHelp];
if (help || level == null) {
print('roll_dev.dart --increment=x • update the version tags and roll a new dev build.\n');
print(argParser.usage);
exit(0);
}
runGit('checkout master', 'switch to master branch');
if (getGitOutput('status --porcelain', 'check status of your local checkout') != '') {
print('Your git repository is not clean. Try running "git clean -fd". Warning, this ');
print('will delete files! Run with -n to find out which ones.');
exit(1);
}
String version = getFullTag();
final Match match = parseFullTag(version);
if (match == null) {
print('Could not determine the version for this build.');
if (version.isNotEmpty)
print('Git reported the latest version as "$version", which does not fit the expected pattern.');
exit(1);
}
final List<int> parts = match.groups(<int>[1, 2, 3]).map(int.parse).toList();
if (match.group(4) == '0') {
print('This commit has already been released, as version ${parts.join(".")}.');
exit(0);
}
switch (level) {
case kX:
parts[0] += 1;
parts[1] = 0;
parts[2] = 0;
break;
case kY:
parts[1] += 1;
parts[2] = 0;
break;
case kZ:
parts[2] += 1;
break;
default:
print('Unknown increment level. The valid values are "$kX", "$kY", and "$kZ".');
exit(1);
}
version = parts.join('.');
runGit('fetch upstream', 'fetch upstream');
runGit('reset upstream/master --hard', 'check out master branch');
runGit('tag $version', 'tag the commit with the version label');
print('Your tree is ready to publish Flutter $version to the "dev" channel.');
stdout.write('Are you? [yes/no] ');
if (stdin.readLineSync() != 'yes') {
runGit('tag -d $version', 'remove the tag you did not want to publish');
print('The dev roll has been aborted.');
exit(0);
}
runGit('push upstream $version', 'publish the version');
runGit('push upstream HEAD:dev', 'land the new version on the "dev" branch');
print('Flutter version $version has been rolled to the "dev" channel!');
}
String getFullTag() {
return getGitOutput(
'describe --match v*.*.* --exclude *-* --first-parent --long --tags',
'obtain last released version number',
);
}
Match parseFullTag(String version) {
final RegExp versionPattern = new RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$');
return versionPattern.matchAsPrefix(version);
}
String getGitOutput(String command, String explanation) {
final ProcessResult result = _runGit(command);
if (result.stderr.isEmpty && result.exitCode == 0)
return result.stdout.trim();
_reportGitFailureAndExit(result, explanation);
return null; // for the analyzer's sake
}
void runGit(String command, String explanation) {
final ProcessResult result = _runGit(command);
if (result.exitCode != 0)
_reportGitFailureAndExit(result, explanation);
}
ProcessResult _runGit(String command) {
return Process.runSync('git', command.split(' '));
}
void _reportGitFailureAndExit(ProcessResult result, String explanation) {
if (result.exitCode != 0) {
print('Failed to $explanation. Git exitted with error code ${result.exitCode}.');
} else {
print('Failed to $explanation.');
}
if (result.stdout.isNotEmpty)
print('stdout from git:\n${result.stdout}\n');
if (result.stderr.isNotEmpty)
print('stderr from git:\n${result.stderr}\n');
exit(1);
}

View File

@@ -1,205 +0,0 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Updates the version numbers of the Flutter repo.
// Only tested on Linux.
//
// See: https://github.com/flutter/flutter/wiki/Release-process
import 'dart:io';
import 'package:args/args.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
const String kIncrement = 'increment';
const String kBrokeSdk = 'broke-sdk';
const String kBrokeFramework = 'broke-framework';
const String kBrokeTest = 'broke-test';
const String kBrokeDriver = 'broke-driver';
const String kMarkRelease = 'release';
const String kHelp = 'help';
const String kYamlVersionPrefix = 'version: ';
const String kDev = '-dev';
enum VersionKind { dev, release }
void main(List<String> args) {
// If we're run from the `tools` dir, set the cwd to the repo root.
if (path.basename(Directory.current.path) == 'tools')
Directory.current = Directory.current.parent.parent;
final ArgParser argParser = new ArgParser();
argParser.addFlag(kIncrement, defaultsTo: false, help: 'Increment all the version numbers. Cannot be specified with --$kMarkRelease or with any --broke-* commands.');
argParser.addFlag(kBrokeSdk, defaultsTo: false, negatable: false, help: 'Increment the Flutter SDK version number to indicate that there has been a breaking change to the SDK (for example, to the command line options).');
argParser.addFlag(kBrokeFramework, defaultsTo: false, negatable: false, help: 'Increment the "flutter" package version number to indicate that there has been a breaking change to the Flutter framework.');
argParser.addFlag(kBrokeTest, defaultsTo: false, negatable: false, help: 'Increment the "flutter_test" package version number to indicate that there has been a breaking change to the test API framework.');
argParser.addFlag(kBrokeDriver, defaultsTo: false, negatable: false, help: 'Increment the "flutter_driver" package version number to indicate that there has been a breaking change to the driver API framework.');
argParser.addFlag(kMarkRelease, defaultsTo: false, help: 'Remove "-dev" from each version number. This is used when releasing. When not present, "-dev" is added to each version number. Cannot be specified with --$kIncrement or with any --broke-* commands.');
argParser.addFlag(kHelp, negatable: false, help: 'Show this help message.');
final ArgResults argResults = argParser.parse(args);
final bool increment = argResults[kIncrement];
final bool brokeSdk = argResults[kBrokeSdk];
final bool brokeFramework = argResults[kBrokeFramework];
final bool brokeTest = argResults[kBrokeTest];
final bool brokeDriver = argResults[kBrokeDriver];
final bool brokeAnything = brokeSdk || brokeFramework || brokeTest || brokeDriver;
final VersionKind level = argResults[kMarkRelease] ? VersionKind.release : VersionKind.dev;
final bool help = argResults[kHelp];
if (help) {
print('update_versions.dart - update version numbers of Flutter packages and SDK');
print(argParser.usage);
exit(0);
}
final bool release = level == VersionKind.release;
if ((brokeAnything && release) || (brokeAnything && increment) || (release && increment)) {
print('You can either increment all the version numbers (--$kIncrement), indicate that some packages have had breaking changes (--broke-*), or switch to release mode (--$kMarkRelease).');
print('You cannot combine these, however.');
exit(1);
}
final RawVersion sdk = new RawVersion('VERSION');
final PubSpecVersion framework = new PubSpecVersion('packages/flutter/pubspec.yaml');
final PubSpecVersion test = new PubSpecVersion('packages/flutter_test/pubspec.yaml');
final PubSpecVersion driver = new PubSpecVersion('packages/flutter_driver/pubspec.yaml');
if (increment || brokeAnything)
sdk.increment(brokeAnything);
sdk.setMode(level);
if (increment || brokeFramework)
framework.increment(brokeFramework);
framework.setMode(level);
if (increment || brokeTest)
test.increment(brokeTest);
test.setMode(level);
if (increment || brokeDriver)
driver.increment(brokeDriver);
driver.setMode(level);
sdk.write();
framework.write();
test.write();
driver.write();
print('Flutter SDK is now at version: $sdk');
print('flutter package is now at version: $framework');
print('flutter_test package is now at version: $test');
print('flutter_driver package is now at version: $driver');
if (release) {
print('\nDuring the tagging step in the instructions, the commands will be:');
print('git tag $sdk');
print('git push upstream $sdk');
}
}
abstract class Version {
Version() {
read();
}
@protected
final List<int> version = <int>[];
@protected
VersionKind level;
@protected
bool dirty = false;
@protected
void read();
void interpret(String value) {
level = value.endsWith(kDev) ? VersionKind.dev : VersionKind.release;
if (level == VersionKind.dev)
value = value.substring(0, value.length - kDev.length);
version.addAll(value.split('.').map<int>(int.parse));
}
void increment(bool breaking) {
assert(version.length == 3);
if (breaking) {
version[1] += 1;
version[2] = 0;
} else {
version[2] += 1;
}
dirty = true;
}
void setMode(VersionKind value) {
if (value != level) {
level = value;
dirty = true;
}
}
void write();
@override
String toString() => version.join('.') + (level == VersionKind.dev ? kDev : '');
}
class PubSpecVersion extends Version {
PubSpecVersion(this.path);
final String path;
@override
void read() {
final List<String> lines = new File(path).readAsLinesSync();
final String versionLine = lines.where((String line) => line.startsWith(kYamlVersionPrefix)).single;
interpret(versionLine.substring(kYamlVersionPrefix.length));
}
@override
void write() {
if (!dirty)
return;
final List<String> lines = new File(path).readAsLinesSync();
for (int index = 0; index < lines.length; index += 1) {
final String line = lines[index];
if (line.startsWith(kYamlVersionPrefix)) {
lines[index] = '$kYamlVersionPrefix$this';
break;
}
}
new File(path).writeAsStringSync(lines.join('\n') + '\n');
}
}
class RawVersion extends Version {
RawVersion(this.path);
final String path;
@override
void read() {
final List<String> lines = new File(path).readAsLinesSync();
interpret(lines.where((String line) => line.isNotEmpty && !line.startsWith('#')).single);
}
@override
void write() {
if (!dirty)
return;
final List<String> lines = new File(path).readAsLinesSync();
for (int index = 0; index < lines.length; index += 1) {
final String line = lines[index];
if (line.isNotEmpty && !line.startsWith('#')) {
lines[index] = '$this';
break;
}
}
new File(path).writeAsStringSync(lines.join('\n') + '\n');
}
}