[flutter_conductor] ensure release branch point is always tagged (#93082)
This commit is contained in:
committed by
GitHub
parent
4dd56df426
commit
2107fef430
@@ -8,6 +8,8 @@ import 'proto/conductor_state.pb.dart' as pb;
|
||||
|
||||
const String gsutilBinary = 'gsutil.py';
|
||||
|
||||
const String kFrameworkDefaultBranch = 'master';
|
||||
|
||||
const List<String> kReleaseChannels = <String>[
|
||||
'stable',
|
||||
'beta',
|
||||
|
||||
@@ -362,26 +362,9 @@ class StartContext {
|
||||
framework.upstreamRemote.name, candidateBranch,
|
||||
exact: false,
|
||||
))..ensureValid(candidateBranch, incrementLetter);
|
||||
Version nextVersion;
|
||||
if (incrementLetter == 'm') {
|
||||
nextVersion = Version.fromCandidateBranch(candidateBranch);
|
||||
} else {
|
||||
if (incrementLetter == 'z') {
|
||||
if (lastVersion.type == VersionType.stable) {
|
||||
nextVersion = Version.increment(lastVersion, incrementLetter);
|
||||
} else {
|
||||
// This is the first stable release, so hardcode the z as 0
|
||||
nextVersion = Version(
|
||||
x: lastVersion.x,
|
||||
y: lastVersion.y,
|
||||
z: 0,
|
||||
type: VersionType.stable,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
nextVersion = Version.increment(lastVersion, incrementLetter);
|
||||
}
|
||||
}
|
||||
Version nextVersion = calculateNextVersion(lastVersion);
|
||||
nextVersion = await ensureBranchPointTagged(nextVersion, framework);
|
||||
|
||||
state.releaseVersion = nextVersion.toString();
|
||||
|
||||
final String frameworkHead = await framework.reverseParse('HEAD');
|
||||
@@ -417,6 +400,54 @@ class StartContext {
|
||||
state_import.writeStateToFile(stateFile, state, logs);
|
||||
}
|
||||
|
||||
/// Determine this release's version number from the [lastVersion] and the [incrementLetter].
|
||||
Version calculateNextVersion(Version lastVersion) {
|
||||
if (incrementLetter == 'm') {
|
||||
return Version.fromCandidateBranch(candidateBranch);
|
||||
}
|
||||
if (incrementLetter == 'z') {
|
||||
if (lastVersion.type == VersionType.stable) {
|
||||
return Version.increment(lastVersion, incrementLetter);
|
||||
}
|
||||
// This is the first stable release, so hardcode the z as 0
|
||||
return Version(
|
||||
x: lastVersion.x,
|
||||
y: lastVersion.y,
|
||||
z: 0,
|
||||
type: VersionType.stable,
|
||||
);
|
||||
}
|
||||
return Version.increment(lastVersion, incrementLetter);
|
||||
}
|
||||
|
||||
/// Ensures the branch point [candidateBranch] and `master` has a version tag.
|
||||
///
|
||||
/// This is necessary for version reporting for users on the `master` channel
|
||||
/// to be correct.
|
||||
Future<Version> ensureBranchPointTagged(
|
||||
Version requestedVersion,
|
||||
FrameworkRepository framework,
|
||||
) async {
|
||||
if (incrementLetter != 'm') {
|
||||
// in this case, there must have been a previous tagged release, so skip
|
||||
// tagging the branch point
|
||||
return requestedVersion;
|
||||
}
|
||||
final String branchPoint = await framework.branchPoint(
|
||||
candidateBranch,
|
||||
kFrameworkDefaultBranch,
|
||||
);
|
||||
stdio.printStatus('Applying the tag $requestedVersion at the branch point $branchPoint');
|
||||
await framework.tag(
|
||||
branchPoint,
|
||||
requestedVersion.toString(),
|
||||
frameworkUpstream,
|
||||
);
|
||||
final Version nextVersion = Version.increment(requestedVersion, 'n');
|
||||
stdio.printStatus('The actual release will be version $nextVersion.');
|
||||
return nextVersion;
|
||||
}
|
||||
|
||||
// To minimize merge conflicts, sort the commits by rev-list order.
|
||||
Future<List<String>> _sortCherrypicks({
|
||||
required Repository repository,
|
||||
|
||||
Reference in New Issue
Block a user