aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yaml11
-rw-r--r--editors/code/package.json2
-rw-r--r--xtask/src/install.rs18
-rw-r--r--xtask/src/not_bash.rs30
4 files changed, 14 insertions, 47 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 4584a271f..d6d5dba95 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -93,7 +93,7 @@ jobs:
93 working-directory: ./editors/code 93 working-directory: ./editors/code
94 94
95 - name: Copy vscode extension 95 - name: Copy vscode extension
96 run: mkdir -p ./dist/code && cp ./editors/code/*.vsix ./dist/ 96 run: mkdir -p ./dist/code && cp ./editors/code/rust-analyzer.vsix ./dist/
97 97
98 - name: Upload artifacts 98 - name: Upload artifacts
99 uses: actions/upload-artifact@v1 99 uses: actions/upload-artifact@v1
@@ -112,8 +112,7 @@ jobs:
112 node-version: 12.x 112 node-version: 12.x
113 113
114 - run: echo "::set-env name=TAG::$(date --iso)" 114 - run: echo "::set-env name=TAG::$(date --iso)"
115 - run: echo "::set-env name=EXT_VERSION::0.1.$(date +%Y%m%d)" 115 - run: 'echo "TAG: $TAG"'
116 - run: 'echo "TAG: $TAG EXT_VERSION: $EXT_VERSION"'
117 116
118 - name: Checkout repository 117 - name: Checkout repository
119 uses: actions/checkout@v1 118 uses: actions/checkout@v1
@@ -181,8 +180,8 @@ jobs:
181 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 180 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182 with: 181 with:
183 upload_url: ${{ steps.create_release.outputs.upload_url }} 182 upload_url: ${{ steps.create_release.outputs.upload_url }}
184 asset_path: ./dist/rust-analyzer-${{ env.EXT_VERSION }}.vsix 183 asset_path: ./dist/rust-analyzer.vsix
185 asset_name: rust-analyzer-${{ env.EXT_VERSION }}.vsix 184 asset_name: rust-analyzer.vsix
186 asset_content_type: application/octet-stream 185 asset_content_type: application/octet-stream
187 186
188 - run: npm ci 187 - run: npm ci
@@ -191,4 +190,4 @@ jobs:
191 - name: Publish Extension 190 - name: Publish Extension
192 working-directory: ./editors/code 191 working-directory: ./editors/code
193 # token from https://dev.azure.com/rust-analyzer/ 192 # token from https://dev.azure.com/rust-analyzer/
194 run: npx vsce publish $EXT_VERSION --pat ${{ secrets.MARKETPLACE_TOKEN }} 193 run: npx vsce publish 0.1.$(date +%Y%m%d) --pat ${{ secrets.MARKETPLACE_TOKEN }}
diff --git a/editors/code/package.json b/editors/code/package.json
index 8f24a13f5..d54b1750a 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -20,7 +20,7 @@
20 }, 20 },
21 "scripts": { 21 "scripts": {
22 "vscode:prepublish": "tsc && rollup -c", 22 "vscode:prepublish": "tsc && rollup -c",
23 "package": "vsce package", 23 "package": "vsce package -o rust-analyzer.vsix",
24 "watch": "tsc --watch", 24 "watch": "tsc --watch",
25 "fmt": "tsfmt -r && tslint -p tsconfig.json -c tslint.json 'src/**/*.ts' --fix" 25 "fmt": "tsfmt -r && tslint -p tsconfig.json -c tslint.json 'src/**/*.ts' --fix"
26 }, 26 },
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index 00bbabce4..91426377f 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -4,7 +4,7 @@ use std::{env, path::PathBuf, str};
4 4
5use anyhow::{bail, format_err, Context, Result}; 5use anyhow::{bail, format_err, Context, Result};
6 6
7use crate::not_bash::{ls, pushd, rm, run}; 7use crate::not_bash::{pushd, run};
8 8
9// Latest stable, feel free to send a PR if this lags behind. 9// Latest stable, feel free to send a PR if this lags behind.
10const REQUIRED_RUST_VERSION: u32 = 41; 10const REQUIRED_RUST_VERSION: u32 = 41;
@@ -99,28 +99,20 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
99 run!("npm --version").context("`npm` is required to build the VS Code plugin")?; 99 run!("npm --version").context("`npm` is required to build the VS Code plugin")?;
100 run!("npm install")?; 100 run!("npm install")?;
101 101
102 let vsix_pkg = { 102 run!("npm run package --scripts-prepend-node-path")?;
103 rm("*.vsix")?;
104 run!("npm run package --scripts-prepend-node-path")?;
105 ls("*.vsix")?.pop().unwrap()
106 };
107 103
108 let code = find_code(|bin| run!("{} --version", bin).is_ok())?; 104 let code = find_code(|bin| run!("{} --version", bin).is_ok())?;
109 run!("{} --install-extension {} --force", code, vsix_pkg.display())?; 105 run!("{} --install-extension rust-analyzer.vsix --force", code)?;
110 installed_extensions = run!("{} --list-extensions", code; echo = false)?; 106 installed_extensions = run!("{} --list-extensions", code; echo = false)?;
111 } else { 107 } else {
112 run!("cmd.exe /c npm --version") 108 run!("cmd.exe /c npm --version")
113 .context("`npm` is required to build the VS Code plugin")?; 109 .context("`npm` is required to build the VS Code plugin")?;
114 run!("cmd.exe /c npm install")?; 110 run!("cmd.exe /c npm install")?;
115 111
116 let vsix_pkg = { 112 run!("cmd.exe /c npm run package")?;
117 rm("*.vsix")?;
118 run!("cmd.exe /c npm run package")?;
119 ls("*.vsix")?.pop().unwrap()
120 };
121 113
122 let code = find_code(|bin| run!("cmd.exe /c {}.cmd --version", bin).is_ok())?; 114 let code = find_code(|bin| run!("cmd.exe /c {}.cmd --version", bin).is_ok())?;
123 run!(r"cmd.exe /c {}.cmd --install-extension {} --force", code, vsix_pkg.display())?; 115 run!(r"cmd.exe /c {}.cmd --install-extension rust-analyzer.vsix --force", code)?;
124 installed_extensions = run!("cmd.exe /c {}.cmd --list-extensions", code; echo = false)?; 116 installed_extensions = run!("cmd.exe /c {}.cmd --list-extensions", code; echo = false)?;
125 } 117 }
126 118
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs
index 3e30e7279..d5577cce9 100644
--- a/xtask/src/not_bash.rs
+++ b/xtask/src/not_bash.rs
@@ -2,8 +2,6 @@
2use std::{ 2use std::{
3 cell::RefCell, 3 cell::RefCell,
4 env, 4 env,
5 ffi::OsStr,
6 fs,
7 path::{Path, PathBuf}, 5 path::{Path, PathBuf},
8 process::{Command, Stdio}, 6 process::{Command, Stdio},
9}; 7};
@@ -68,14 +66,11 @@ impl Drop for Pushd {
68 } 66 }
69} 67}
70 68
71pub fn rm(glob: &str) -> Result<()> {
72 let cwd = Env::with(|env| env.cwd());
73 ls(glob)?.into_iter().try_for_each(|it| fs::remove_file(cwd.join(it)))?;
74 Ok(())
75}
76
77pub fn rm_rf(path: impl AsRef<Path>) -> Result<()> { 69pub fn rm_rf(path: impl AsRef<Path>) -> Result<()> {
78 let path = path.as_ref(); 70 let path = path.as_ref();
71 if !path.exists() {
72 return Ok(());
73 }
79 if path.is_file() { 74 if path.is_file() {
80 fs2::remove_file(path) 75 fs2::remove_file(path)
81 } else { 76 } else {
@@ -83,25 +78,6 @@ pub fn rm_rf(path: impl AsRef<Path>) -> Result<()> {
83 } 78 }
84} 79}
85 80
86pub fn ls(glob: &str) -> Result<Vec<PathBuf>> {
87 let cwd = Env::with(|env| env.cwd());
88 let mut res = Vec::new();
89 for entry in fs::read_dir(&cwd)? {
90 let entry = entry?;
91 if matches(&entry.file_name(), glob) {
92 let path = entry.path();
93 let path = path.strip_prefix(&cwd).unwrap();
94 res.push(path.to_path_buf())
95 }
96 }
97 return Ok(res);
98
99 fn matches(file_name: &OsStr, glob: &str) -> bool {
100 assert!(glob.starts_with('*'));
101 file_name.to_string_lossy().ends_with(&glob[1..])
102 }
103}
104
105#[doc(hidden)] 81#[doc(hidden)]
106pub fn run_process(cmd: String, echo: bool) -> Result<String> { 82pub fn run_process(cmd: String, echo: bool) -> Result<String> {
107 run_process_inner(&cmd, echo).with_context(|| format!("process `{}` failed", cmd)) 83 run_process_inner(&cmd, echo).with_context(|| format!("process `{}` failed", cmd))