@@ -38,6 +38,7 @@ struct Context {
38
38
config : Config ,
39
39
date : String ,
40
40
current_version : Option < String > ,
41
+ current_cargo_version : Option < String > ,
41
42
}
42
43
43
44
// Called as:
@@ -66,6 +67,7 @@ impl Context {
66
67
date,
67
68
handle : Easy :: new ( ) ,
68
69
current_version : None ,
70
+ current_cargo_version : None ,
69
71
} )
70
72
}
71
73
@@ -262,18 +264,12 @@ impl Context {
262
264
Ok ( ( ) )
263
265
}
264
266
265
- fn current_version_same ( & mut self , prev : & str ) -> Result < bool , Error > {
266
- // nightly's always changing
267
- if self . config . channel == Channel :: Nightly {
268
- return Ok ( false ) ;
269
- }
270
- let prev_version = prev. split ( ' ' ) . next ( ) . unwrap ( ) ;
271
-
267
+ fn load_version ( & mut self , mut filter : impl FnMut ( & str ) -> bool ) -> Result < String , Error > {
272
268
let mut current = None ;
273
269
for e in self . dl_dir ( ) . read_dir ( ) ? {
274
270
let e = e?;
275
271
let filename = e. file_name ( ) . into_string ( ) . unwrap ( ) ;
276
- if !filename . starts_with ( "rustc-" ) || ! filename. ends_with ( ".tar.xz" ) {
272
+ if !filter ( & filename ) && filename. ends_with ( ".tar.xz" ) {
277
273
continue ;
278
274
}
279
275
println ! ( "looking inside {} for a version" , filename) ;
@@ -301,13 +297,26 @@ impl Context {
301
297
break ;
302
298
}
303
299
}
304
- let current = current. ok_or_else ( || anyhow:: anyhow!( "no archives with a version" ) ) ?;
300
+ current. ok_or_else ( || anyhow:: anyhow!( "no archives with a version" ) )
301
+ }
305
302
306
- println ! ( "current version: {}" , current) ;
303
+ fn current_version_same ( & mut self , prev : & str ) -> Result < bool , Error > {
304
+ // nightly's always changing
305
+ if self . config . channel == Channel :: Nightly {
306
+ return Ok ( false ) ;
307
+ }
308
+ let prev_version = prev. split ( ' ' ) . next ( ) . unwrap ( ) ;
307
309
310
+ let current = self . load_version ( |filename| filename. starts_with ( "rustc-" ) ) ?;
311
+ println ! ( "current version: {}" , current) ;
308
312
let current_version = current. split ( ' ' ) . next ( ) . unwrap ( ) ;
309
313
self . current_version = Some ( current_version. to_string ( ) ) ;
310
314
315
+ let current_cargo = self . load_version ( |filename| filename. starts_with ( "cargo-" ) ) ?;
316
+ println ! ( "current cargo version: {}" , current_cargo) ;
317
+ let current_version = current_cargo. split ( ' ' ) . next ( ) . unwrap ( ) ;
318
+ self . current_cargo_version = Some ( current_cargo. to_string ( ) ) ;
319
+
311
320
// The release process for beta looks like so:
312
321
//
313
322
// * Force push master branch to beta branch
@@ -644,13 +653,43 @@ impl Context {
644
653
return Ok ( ( ) ) ;
645
654
} ;
646
655
647
- if let Some ( repo) = self . config . rustc_tag_repository . clone ( ) {
648
- self . tag_repository ( signer, & mut github, & repo, rustc_commit) ?;
656
+ if let Some ( rustc_repo) = self . config . rustc_tag_repository . clone ( ) {
657
+ let rustc_version = self . current_version . clone ( ) . expect ( "has current version" ) ;
658
+ self . tag_repository (
659
+ signer,
660
+ & mut github,
661
+ & rustc_repo,
662
+ rustc_commit,
663
+ & rustc_version,
664
+ ) ?;
649
665
650
666
// Once we've tagged rustc, kick off a thanks workflow run.
651
667
github
652
668
. token ( "rust-lang/thanks" ) ?
653
669
. workflow_dispatch ( "ci.yml" , "master" ) ?;
670
+
671
+ if let Some ( cargo_repo) = self . config . cargo_tag_repository . clone ( ) {
672
+ let cargo_version = self
673
+ . current_cargo_version
674
+ . clone ( )
675
+ . expect ( "has current cargo version" ) ;
676
+ let cargo_commit = match github
677
+ . token ( & rustc_repo) ?
678
+ . read_file ( Some ( rustc_commit) , "src/tools/cargo" ) ?
679
+ {
680
+ github:: GitFile :: Submodule { sha } => sha,
681
+ github:: GitFile :: File { .. } => {
682
+ anyhow:: bail!( "src/tools/cargo is expected to be a submodule" )
683
+ }
684
+ } ;
685
+ self . tag_repository (
686
+ signer,
687
+ & mut github,
688
+ & cargo_repo,
689
+ & cargo_commit,
690
+ & cargo_version,
691
+ ) ?;
692
+ }
654
693
}
655
694
656
695
Ok ( ( ) )
@@ -662,8 +701,8 @@ impl Context {
662
701
github : & mut Github ,
663
702
repository : & str ,
664
703
commit : & str ,
704
+ version : & str ,
665
705
) -> Result < ( ) , Error > {
666
- let version = self . current_version . as_ref ( ) . expect ( "has current version" ) ;
667
706
let tag_name = version. to_owned ( ) ;
668
707
let username = "rust-lang/promote-release" ;
669
708
let email = "release-team@rust-lang.org" ;
0 commit comments