@@ -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
@@ -613,13 +622,43 @@ impl Context {
613
622
return Ok ( ( ) ) ;
614
623
} ;
615
624
616
- if let Some ( repo) = self . config . rustc_tag_repository . clone ( ) {
617
- self . tag_repository ( signer, & mut github, & repo, rustc_commit) ?;
625
+ if let Some ( rustc_repo) = self . config . rustc_tag_repository . clone ( ) {
626
+ let rustc_version = self . current_version . clone ( ) . expect ( "has current version" ) ;
627
+ self . tag_repository (
628
+ signer,
629
+ & mut github,
630
+ & rustc_repo,
631
+ rustc_commit,
632
+ & rustc_version,
633
+ ) ?;
618
634
619
635
// Once we've tagged rustc, kick off a thanks workflow run.
620
636
github
621
637
. token ( "rust-lang/thanks" ) ?
622
638
. workflow_dispatch ( "ci.yml" , "master" ) ?;
639
+
640
+ if let Some ( cargo_repo) = self . config . cargo_tag_repository . clone ( ) {
641
+ let cargo_version = self
642
+ . current_cargo_version
643
+ . clone ( )
644
+ . expect ( "has current cargo version" ) ;
645
+ let cargo_commit = match github
646
+ . token ( & rustc_repo) ?
647
+ . read_file ( Some ( rustc_commit) , "src/tools/cargo" ) ?
648
+ {
649
+ github:: GitFile :: Submodule { sha } => sha,
650
+ github:: GitFile :: File { .. } => {
651
+ anyhow:: bail!( "src/tools/cargo is expected to be a submodule" )
652
+ }
653
+ } ;
654
+ self . tag_repository (
655
+ signer,
656
+ & mut github,
657
+ & cargo_repo,
658
+ & cargo_commit,
659
+ & cargo_version,
660
+ ) ?;
661
+ }
623
662
}
624
663
625
664
Ok ( ( ) )
@@ -631,8 +670,8 @@ impl Context {
631
670
github : & mut Github ,
632
671
repository : & str ,
633
672
commit : & str ,
673
+ version : & str ,
634
674
) -> Result < ( ) , Error > {
635
- let version = self . current_version . as_ref ( ) . expect ( "has current version" ) ;
636
675
let tag_name = version. to_owned ( ) ;
637
676
let username = "rust-lang/promote-release" ;
638
677
let email = "release-team@rust-lang.org" ;
0 commit comments