Skip to content

Commit 945325c

Browse files
committed
Backfill MAJOR.MINOR Rustup channel manifests
Now that rust-lang/rust#76107 has been merged, new releases will also write their manifests to channel-rust-1.x.toml as well as channel-rust-1.x.y.toml to enable `rustup install 1.48` to get the latest patch release in a minor release series. This commit adds an idempotent function to copy manifests for the last patch release in every minor release series to the corresponding minor manifest so that past minor versions will work with the rustup functionality too. This function should only need to be run once, but should be safe to run more than once.
1 parent 9ad4659 commit 945325c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

promote-release/src/main.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern crate tar;
88
extern crate toml;
99
extern crate xz2;
1010

11+
use std::collections::HashMap;
1112
use std::env;
1213
use std::fs::{self, File, OpenOptions};
1314
use std::io::{self, Read, Write};
@@ -53,6 +54,7 @@ fn main() {
5354
impl Context {
5455
fn run(&mut self) {
5556
let _lock = self.lock();
57+
self.backfill_major_minor_channels();
5658
self.update_repo();
5759

5860
let override_var = env::var("PROMOTE_RELEASE_OVERRIDE_BRANCH");
@@ -578,6 +580,53 @@ upload-addr = \"{}/{}\"
578580
assert_eq!(t!(self.handle.response_code()), 200);
579581
t!(t!(String::from_utf8(result)).parse())
580582
}
583+
584+
// This function can be removed after it has been run successfully at least once in the
585+
// production environment such that a manifest exists for every 1.x stable version. It is
586+
// idempontent and safe to run more than once.
587+
fn backfill_major_minor_channels(&mut self) {
588+
let bucket = self.secrets["dist"]["upload-bucket"].as_str().unwrap();
589+
let dir = self.secrets["dist"]["upload-dir"].as_str().unwrap();
590+
591+
// All the Rust versions that have had non-zero patch releases
592+
let minor_versions_with_patch_releases: HashMap<u8, u8> = vec![
593+
(12, 1),
594+
(15, 1),
595+
(22, 1),
596+
(24, 1),
597+
(26, 2),
598+
(27, 2),
599+
(29, 2),
600+
(30, 1),
601+
(31, 1),
602+
(34, 2),
603+
(41, 1),
604+
(43, 1),
605+
(44, 1),
606+
(45, 2),
607+
]
608+
.into_iter()
609+
.collect();
610+
611+
for minor in 0..=47 {
612+
let last_patch = minor_versions_with_patch_releases
613+
.get(&minor)
614+
.copied()
615+
.unwrap_or(0);
616+
let src = format!(
617+
"s3://{}/{}/channel-rust-1.{}.{}.toml",
618+
bucket, dir, minor, last_patch
619+
);
620+
let dst = format!("s3://{}/{}/channel-rust-1.{}.toml", bucket, dir, minor);
621+
622+
run(self
623+
.aws_s3()
624+
.arg("cp")
625+
.arg("--only-show-errors")
626+
.arg(&src)
627+
.arg(&dst));
628+
}
629+
}
581630
}
582631

583632
fn run(cmd: &mut Command) {

0 commit comments

Comments
 (0)