Skip to content

Commit eee50b6

Browse files
bors[bot]matklad
andauthored
Merge #8666
8666: fix: correct version string on windows and mac r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 691c96e + 4f9640f commit eee50b6

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,7 @@ jobs:
109109
node-version: 12.x
110110

111111
- name: Dist
112-
if: github.ref == 'refs/heads/release'
113-
run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER
114-
115-
- name: Dist
116-
if: github.ref != 'refs/heads/release'
117-
run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly
112+
run: cargo xtask dist --client-patch-version $GITHUB_RUN_NUMBER
118113

119114
- name: Run analysis-stats on rust-analyzer
120115
run: target/${{ env.RA_TARGET }}/release/rust-analyzer analysis-stats .

crates/rust-analyzer/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn commit_hash() -> Option<String> {
5555
}
5656

5757
fn build_date() -> Option<String> {
58-
output_to_string("date --iso --utc")
58+
output_to_string("date --utc +%Y-%m-%d")
5959
}
6060

6161
fn output_to_string(command: &str) -> Option<String> {

xtask/src/dist.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,28 @@ use anyhow::Result;
99
use flate2::{write::GzEncoder, Compression};
1010
use xshell::{cmd, cp, mkdir_p, pushd, pushenv, read_file, rm_rf, write_file};
1111

12-
use crate::{date_iso, project_root};
12+
use crate::{date_iso, flags, project_root};
1313

14-
pub(crate) struct DistCmd {
15-
pub(crate) nightly: bool,
16-
pub(crate) client_version: Option<String>,
17-
}
18-
19-
impl DistCmd {
14+
impl flags::Dist {
2015
pub(crate) fn run(self) -> Result<()> {
16+
let stable =
17+
std::env::var("GITHUB_REF").unwrap_or_default().as_str() == "refs/heads/release";
18+
2119
let dist = project_root().join("dist");
2220
rm_rf(&dist)?;
2321
mkdir_p(&dist)?;
2422

25-
if let Some(version) = self.client_version {
26-
let release_tag = if self.nightly { "nightly".to_string() } else { date_iso()? };
23+
if let Some(patch_version) = self.client_patch_version {
24+
let version = if stable {
25+
format!("0.2.{}", patch_version)
26+
} else {
27+
// A hack to make VS Code prefer nightly over stable.
28+
format!("0.3.{}", patch_version)
29+
};
30+
let release_tag = if stable { date_iso()? } else { "nightly".to_string() };
2731
dist_client(&version, &release_tag)?;
2832
}
29-
let release_channel = if self.nightly { "nightly" } else { "stable" };
33+
let release_channel = if stable { "stable" } else { "nightly" };
3034
dist_server(release_channel)?;
3135
Ok(())
3236
}

xtask/src/flags.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ xflags::xflags! {
3737
optional --dry-run
3838
}
3939
cmd dist {
40-
optional --nightly
41-
optional --client version: String
40+
optional --client-patch-version version: String
4241
}
4342
cmd metrics {
4443
optional --dry-run
@@ -85,9 +84,6 @@ pub struct Install {
8584
pub jemalloc: bool,
8685
}
8786

88-
#[derive(Debug)]
89-
pub struct Lint;
90-
9187
#[derive(Debug)]
9288
pub struct FuzzTests;
9389

@@ -106,8 +102,7 @@ pub struct Promote {
106102

107103
#[derive(Debug)]
108104
pub struct Dist {
109-
pub nightly: bool,
110-
pub client: Option<String>,
105+
pub client_patch_version: Option<String>,
111106
}
112107

113108
#[derive(Debug)]

xtask/src/main.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ use std::{
2828
use walkdir::{DirEntry, WalkDir};
2929
use xshell::{cmd, cp, pushd, pushenv};
3030

31-
use crate::dist::DistCmd;
32-
3331
fn main() -> Result<()> {
3432
let _d = pushd(project_root())?;
3533

@@ -44,9 +42,7 @@ fn main() -> Result<()> {
4442
flags::XtaskCmd::PreCache(cmd) => cmd.run(),
4543
flags::XtaskCmd::Release(cmd) => cmd.run(),
4644
flags::XtaskCmd::Promote(cmd) => cmd.run(),
47-
flags::XtaskCmd::Dist(flags) => {
48-
DistCmd { nightly: flags.nightly, client_version: flags.client }.run()
49-
}
45+
flags::XtaskCmd::Dist(cmd) => cmd.run(),
5046
flags::XtaskCmd::Metrics(cmd) => cmd.run(),
5147
flags::XtaskCmd::Bb(cmd) => {
5248
{
@@ -112,7 +108,7 @@ fn run_fuzzer() -> Result<()> {
112108
}
113109

114110
fn date_iso() -> Result<String> {
115-
let res = cmd!("date --iso --utc").read()?;
111+
let res = cmd!("date --utc +%Y-%m-%d").read()?;
116112
Ok(res)
117113
}
118114

0 commit comments

Comments
 (0)