aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yaml5
-rw-r--r--editors/code/package.json4
-rw-r--r--editors/code/src/config.ts20
-rw-r--r--editors/code/src/main.ts4
-rw-r--r--xtask/src/dist.rs23
-rw-r--r--xtask/src/main.rs5
6 files changed, 27 insertions, 34 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 0434b6128..13bc172ba 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -6,6 +6,7 @@ on:
6 push: 6 push:
7 branches: 7 branches:
8 - release 8 - release
9 - nightly
9 10
10jobs: 11jobs:
11 dist: 12 dist:
@@ -49,11 +50,11 @@ jobs:
49 50
50 - name: Dist 51 - name: Dist
51 if: github.event_name == 'push' 52 if: github.event_name == 'push'
52 run: cargo xtask dist 53 run: cargo xtask dist --version 0.2.$GITHUB_RUN_NUMBER --tag $(date --iso --utc)
53 54
54 - name: Dist 55 - name: Dist
55 if: github.event_name != 'push' 56 if: github.event_name != 'push'
56 run: cargo xtask dist --nightly 57 run: cargo xtask dist --version 0.3.$GITHUB_RUN_NUMBER-nightly --tag nightly
57 58
58 - name: Upload artifacts 59 - name: Upload artifacts
59 uses: actions/upload-artifact@v1 60 uses: actions/upload-artifact@v1
diff --git a/editors/code/package.json b/editors/code/package.json
index 150c36845..9f2fe06f3 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -5,8 +5,8 @@
5 "preview": true, 5 "preview": true,
6 "private": true, 6 "private": true,
7 "icon": "icon.png", 7 "icon": "icon.png",
8 "//": "The real version is in release.yaml, this one just needs to be bigger", 8 "version": "0.4.0-dev",
9 "version": "0.2.20200309-nightly", 9 "releaseTag": "nightly",
10 "publisher": "matklad", 10 "publisher": "matklad",
11 "repository": { 11 "repository": {
12 "url": "https://github.com/rust-analyzer/rust-analyzer.git", 12 "url": "https://github.com/rust-analyzer/rust-analyzer.git",
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 28698ab8e..54b905303 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -38,23 +38,17 @@ export class Config {
38 ] 38 ]
39 .map(opt => `${this.rootSection}.${opt}`); 39 .map(opt => `${this.rootSection}.${opt}`);
40 40
41 readonly packageJsonVersion = vscode 41 readonly packageJsonVersion: string = vscode
42 .extensions 42 .extensions
43 .getExtension(this.extensionId)! 43 .getExtension(this.extensionId)!
44 .packageJSON 44 .packageJSON
45 .version as string; // n.n.YYYYMMDD[-nightly] 45 .version;
46 46
47 /** 47 readonly releaseTag: string = vscode
48 * Either `nightly` or `YYYY-MM-DD` (i.e. `stable` release) 48 .extensions
49 */ 49 .getExtension(this.extensionId)!
50 readonly extensionReleaseTag: string = (() => { 50 .packageJSON
51 if (this.packageJsonVersion.endsWith(NIGHTLY_TAG)) return NIGHTLY_TAG; 51 .releaseTag;
52
53 const realVersionRegexp = /^\d+\.\d+\.(\d{4})(\d{2})(\d{2})/;
54 const [, yyyy, mm, dd] = this.packageJsonVersion.match(realVersionRegexp)!;
55
56 return `${yyyy}-${mm}-${dd}`;
57 })();
58 52
59 private cfg!: vscode.WorkspaceConfiguration; 53 private cfg!: vscode.WorkspaceConfiguration;
60 54
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index d907f3e6f..5297614a9 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -111,7 +111,7 @@ async function bootstrap(config: Config, state: PersistentState): Promise<string
111 111
112async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> { 112async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> {
113 if (config.channel === "stable") { 113 if (config.channel === "stable") {
114 if (config.extensionReleaseTag === NIGHTLY_TAG) { 114 if (config.releaseTag === NIGHTLY_TAG) {
115 vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension. 115 vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension.
116To switch to stable, uninstall the extension and re-install it from the marketplace`); 116To switch to stable, uninstall the extension and re-install it from the marketplace`);
117 } 117 }
@@ -219,7 +219,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
219 if (userResponse !== "Download now") return dest; 219 if (userResponse !== "Download now") return dest;
220 } 220 }
221 221
222 const release = await fetchRelease(config.extensionReleaseTag); 222 const release = await fetchRelease(config.releaseTag);
223 const artifact = release.assets.find(artifact => artifact.name === binaryName); 223 const artifact = release.assets.find(artifact => artifact.name === binaryName);
224 assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); 224 assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
225 225
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index e3dddd9b1..3a14f8a63 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -7,31 +7,27 @@ use crate::{
7 project_root, 7 project_root,
8}; 8};
9 9
10pub fn run_dist(nightly: bool) -> Result<()> { 10pub fn run_dist(version: &str, release_tag: &str) -> Result<()> {
11 let dist = project_root().join("dist"); 11 let dist = project_root().join("dist");
12 rm_rf(&dist)?; 12 rm_rf(&dist)?;
13 fs2::create_dir_all(&dist)?; 13 fs2::create_dir_all(&dist)?;
14 14
15 if cfg!(target_os = "linux") { 15 if cfg!(target_os = "linux") {
16 dist_client(nightly)?; 16 dist_client(version, release_tag)?;
17 } 17 }
18 dist_server()?; 18 dist_server()?;
19 Ok(()) 19 Ok(())
20} 20}
21 21
22fn dist_client(nightly: bool) -> Result<()> { 22fn dist_client(version: &str, release_tag: &str) -> Result<()> {
23 let _d = pushd("./editors/code"); 23 let _d = pushd("./editors/code");
24 let nightly = release_tag == "nightly";
24 25
25 let package_json_path = PathBuf::from("./package.json"); 26 let mut patch = Patch::new("./package.json")?;
26 let mut patch = Patch::new(package_json_path.clone())?;
27 27
28 let date = run!("date --utc +%Y%m%d")?; 28 patch
29 let version_suffix = if nightly { "-nightly" } else { "" }; 29 .replace(r#""version": "0.4.0-dev""#, &format!(r#""version": "{}""#, version))
30 30 .replace(r#""releaseTag": "nightly""#, &format!(r#""releaseTag": "{}""#, release_tag));
31 patch.replace(
32 r#""version": "0.2.20200309-nightly""#,
33 &format!(r#""version": "0.1.{}{}""#, date, version_suffix),
34 );
35 31
36 if nightly { 32 if nightly {
37 patch.replace( 33 patch.replace(
@@ -86,7 +82,8 @@ struct Patch {
86} 82}
87 83
88impl Patch { 84impl Patch {
89 fn new(path: PathBuf) -> Result<Patch> { 85 fn new(path: impl Into<PathBuf>) -> Result<Patch> {
86 let path = path.into();
90 let contents = fs2::read_to_string(&path)?; 87 let contents = fs2::read_to_string(&path)?;
91 Ok(Patch { path, original_contents: contents.clone(), contents }) 88 Ok(Patch { path, original_contents: contents.clone(), contents })
92 } 89 }
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 7c8ea9001..aafa73610 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -103,9 +103,10 @@ FLAGS:
103 run_release(dry_run) 103 run_release(dry_run)
104 } 104 }
105 "dist" => { 105 "dist" => {
106 let nightly = args.contains("--nightly"); 106 let version: String = args.value_from_str("--version")?;
107 let release_tag: String = args.value_from_str("--tag")?;
107 args.finish()?; 108 args.finish()?;
108 run_dist(nightly) 109 run_dist(&version, &release_tag)
109 } 110 }
110 _ => { 111 _ => {
111 eprintln!( 112 eprintln!(