Unverified Commit b2e37c65 authored by Casey Hillers's avatar Casey Hillers Committed by GitHub

[conductor] Tag engine versions (#120419)

* [conductor] Tag engine versions

* Move tag to repository
parent 25c2c22d
...@@ -264,21 +264,33 @@ class NextContext extends Context { ...@@ -264,21 +264,33 @@ class NextContext extends Context {
case pb.ReleasePhase.PUBLISH_VERSION: case pb.ReleasePhase.PUBLISH_VERSION:
stdio.printStatus('Please ensure that you have merged your framework PR and that'); stdio.printStatus('Please ensure that you have merged your framework PR and that');
stdio.printStatus('post-submit CI has finished successfully.\n'); stdio.printStatus('post-submit CI has finished successfully.\n');
final Remote upstream = Remote( final Remote frameworkUpstream = Remote(
name: RemoteName.upstream, name: RemoteName.upstream,
url: state.framework.upstream.url, url: state.framework.upstream.url,
); );
final FrameworkRepository framework = FrameworkRepository( final FrameworkRepository framework = FrameworkRepository(
checkouts, checkouts,
// We explicitly want to check out the merged version from upstream // We explicitly want to check out the merged version from upstream
initialRef: '${upstream.name}/${state.framework.candidateBranch}', initialRef: '${frameworkUpstream.name}/${state.framework.candidateBranch}',
upstreamRemote: upstream, upstreamRemote: frameworkUpstream,
previousCheckoutLocation: state.framework.checkoutPath, previousCheckoutLocation: state.framework.checkoutPath,
); );
final String headRevision = await framework.reverseParse('HEAD'); final String frameworkHead = await framework.reverseParse('HEAD');
final Remote engineUpstream = Remote(
name: RemoteName.upstream,
url: state.engine.upstream.url,
);
final EngineRepository engine = EngineRepository(
checkouts,
// We explicitly want to check out the merged version from upstream
initialRef: '${engineUpstream.name}/${state.engine.candidateBranch}',
upstreamRemote: engineUpstream,
previousCheckoutLocation: state.engine.checkoutPath,
);
final String engineHead = await engine.reverseParse('HEAD');
if (autoAccept == false) { if (autoAccept == false) {
final bool response = await prompt( final bool response = await prompt(
'Are you ready to tag commit $headRevision as ${state.releaseVersion}\n' 'Are you ready to tag commit $frameworkHead as ${state.releaseVersion}\n'
'and push to remote ${state.framework.upstream.url}?', 'and push to remote ${state.framework.upstream.url}?',
); );
if (!response) { if (!response) {
...@@ -287,7 +299,8 @@ class NextContext extends Context { ...@@ -287,7 +299,8 @@ class NextContext extends Context {
return; return;
} }
} }
await framework.tag(headRevision, state.releaseVersion, upstream.name); await framework.tag(frameworkHead, state.releaseVersion, frameworkUpstream.name);
await engine.tag(engineHead, state.releaseVersion, engineUpstream.name);
break; break;
case pb.ReleasePhase.PUBLISH_CHANNEL: case pb.ReleasePhase.PUBLISH_CHANNEL:
final Remote upstream = Remote( final Remote upstream = Remote(
......
...@@ -319,6 +319,27 @@ abstract class Repository { ...@@ -319,6 +319,27 @@ abstract class Repository {
); );
} }
/// Tag [commit] and push the tag to the remote.
Future<void> tag(String commit, String tagName, String remote) async {
assert(commit.isNotEmpty);
assert(tagName.isNotEmpty);
assert(remote.isNotEmpty);
stdio.printStatus('About to tag commit $commit as $tagName...');
await git.run(
<String>['tag', tagName, commit],
'tag the commit with the version label',
workingDirectory: (await checkoutDirectory).path,
);
stdio.printStatus('Tagging successful.');
stdio.printStatus('About to push $tagName to remote $remote...');
await git.run(
<String>['push', remote, tagName],
'publish the tag to the repo',
workingDirectory: (await checkoutDirectory).path,
);
stdio.printStatus('Tag push successful.');
}
/// List commits in reverse chronological order. /// List commits in reverse chronological order.
Future<List<String>> revList(List<String> args) async { Future<List<String>> revList(List<String> args) async {
return (await git.getOutput(<String>['rev-list', ...args], return (await git.getOutput(<String>['rev-list', ...args],
...@@ -592,27 +613,6 @@ class FrameworkRepository extends Repository { ...@@ -592,27 +613,6 @@ class FrameworkRepository extends Repository {
); );
} }
/// Tag [commit] and push the tag to the remote.
Future<void> tag(String commit, String tagName, String remote) async {
assert(commit.isNotEmpty);
assert(tagName.isNotEmpty);
assert(remote.isNotEmpty);
stdio.printStatus('About to tag commit $commit as $tagName...');
await git.run(
<String>['tag', tagName, commit],
'tag the commit with the version label',
workingDirectory: (await checkoutDirectory).path,
);
stdio.printStatus('Tagging successful.');
stdio.printStatus('About to push $tagName to remote $remote...');
await git.run(
<String>['push', remote, tagName],
'publish the tag to the repo',
workingDirectory: (await checkoutDirectory).path,
);
stdio.printStatus('Tag push successful.');
}
@override @override
Future<FrameworkRepository> cloneRepository(String? cloneName) async { Future<FrameworkRepository> cloneRepository(String? cloneName) async {
assert(localUpstream); assert(localUpstream);
......
...@@ -758,6 +758,10 @@ void main() { ...@@ -758,6 +758,10 @@ void main() {
candidateBranch: candidateBranch, candidateBranch: candidateBranch,
upstream: pb.Remote(url: FrameworkRepository.defaultUpstream), upstream: pb.Remote(url: FrameworkRepository.defaultUpstream),
), ),
engine: pb.Repository(
candidateBranch: candidateBranch,
upstream: pb.Remote(url: EngineRepository.defaultUpstream),
),
releaseVersion: releaseVersion, releaseVersion: releaseVersion,
); );
platform = FakePlatform( platform = FakePlatform(
...@@ -773,6 +777,18 @@ void main() { ...@@ -773,6 +777,18 @@ void main() {
stdio.stdin.add('n'); stdio.stdin.add('n');
final FakeProcessManager processManager = FakeProcessManager.list( final FakeProcessManager processManager = FakeProcessManager.list(
<FakeCommand>[ <FakeCommand>[
// Framework checkout
const FakeCommand(
command: <String>['git', 'fetch', 'upstream'],
),
const FakeCommand(
command: <String>['git', 'checkout', '$remoteName/$candidateBranch'],
),
const FakeCommand(
command: <String>['git', 'rev-parse', 'HEAD'],
stdout: revision1,
),
// Engine checkout
const FakeCommand( const FakeCommand(
command: <String>['git', 'fetch', 'upstream'], command: <String>['git', 'fetch', 'upstream'],
), ),
...@@ -818,6 +834,7 @@ void main() { ...@@ -818,6 +834,7 @@ void main() {
test('updates state.currentPhase if user responds yes', () async { test('updates state.currentPhase if user responds yes', () async {
stdio.stdin.add('y'); stdio.stdin.add('y');
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[ final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
// Framework checkout
const FakeCommand( const FakeCommand(
command: <String>['git', 'fetch', 'upstream'], command: <String>['git', 'fetch', 'upstream'],
), ),
...@@ -828,12 +845,31 @@ void main() { ...@@ -828,12 +845,31 @@ void main() {
command: <String>['git', 'rev-parse', 'HEAD'], command: <String>['git', 'rev-parse', 'HEAD'],
stdout: revision1, stdout: revision1,
), ),
// Engine checkout
const FakeCommand(
command: <String>['git', 'fetch', 'upstream'],
),
const FakeCommand(
command: <String>['git', 'checkout', '$remoteName/$candidateBranch'],
),
const FakeCommand(
command: <String>['git', 'rev-parse', 'HEAD'],
stdout: revision2,
),
// Framework tag
const FakeCommand( const FakeCommand(
command: <String>['git', 'tag', releaseVersion, revision1], command: <String>['git', 'tag', releaseVersion, revision1],
), ),
const FakeCommand( const FakeCommand(
command: <String>['git', 'push', remoteName, releaseVersion], command: <String>['git', 'push', remoteName, releaseVersion],
), ),
// Engine tag
const FakeCommand(
command: <String>['git', 'tag', releaseVersion, revision2],
),
const FakeCommand(
command: <String>['git', 'push', remoteName, releaseVersion],
),
]); ]);
final FakePlatform platform = FakePlatform( final FakePlatform platform = FakePlatform(
environment: <String, String>{ environment: <String, String>{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment