mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-26 11:55:04 +00:00
Simplify extension tag sniffing
This commit is contained in:
parent
aca3c3086e
commit
3d1cb5e20f
6 changed files with 27 additions and 34 deletions
5
.github/workflows/release.yaml
vendored
5
.github/workflows/release.yaml
vendored
|
@ -6,6 +6,7 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- release
|
- release
|
||||||
|
- nightly
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
dist:
|
dist:
|
||||||
|
@ -49,11 +50,11 @@ jobs:
|
||||||
|
|
||||||
- name: Dist
|
- name: Dist
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
run: cargo xtask dist
|
run: cargo xtask dist --version 0.2.$GITHUB_RUN_NUMBER --tag $(date --iso --utc)
|
||||||
|
|
||||||
- name: Dist
|
- name: Dist
|
||||||
if: github.event_name != 'push'
|
if: github.event_name != 'push'
|
||||||
run: cargo xtask dist --nightly
|
run: cargo xtask dist --version 0.3.$GITHUB_RUN_NUMBER-nightly --tag nightly
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
"preview": true,
|
"preview": true,
|
||||||
"private": true,
|
"private": true,
|
||||||
"icon": "icon.png",
|
"icon": "icon.png",
|
||||||
"//": "The real version is in release.yaml, this one just needs to be bigger",
|
"version": "0.4.0-dev",
|
||||||
"version": "0.2.20200309-nightly",
|
"releaseTag": "nightly",
|
||||||
"publisher": "matklad",
|
"publisher": "matklad",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/rust-analyzer/rust-analyzer.git",
|
"url": "https://github.com/rust-analyzer/rust-analyzer.git",
|
||||||
|
|
|
@ -38,23 +38,17 @@ export class Config {
|
||||||
]
|
]
|
||||||
.map(opt => `${this.rootSection}.${opt}`);
|
.map(opt => `${this.rootSection}.${opt}`);
|
||||||
|
|
||||||
readonly packageJsonVersion = vscode
|
readonly packageJsonVersion: string = vscode
|
||||||
.extensions
|
.extensions
|
||||||
.getExtension(this.extensionId)!
|
.getExtension(this.extensionId)!
|
||||||
.packageJSON
|
.packageJSON
|
||||||
.version as string; // n.n.YYYYMMDD[-nightly]
|
.version;
|
||||||
|
|
||||||
/**
|
readonly releaseTag: string = vscode
|
||||||
* Either `nightly` or `YYYY-MM-DD` (i.e. `stable` release)
|
.extensions
|
||||||
*/
|
.getExtension(this.extensionId)!
|
||||||
readonly extensionReleaseTag: string = (() => {
|
.packageJSON
|
||||||
if (this.packageJsonVersion.endsWith(NIGHTLY_TAG)) return NIGHTLY_TAG;
|
.releaseTag;
|
||||||
|
|
||||||
const realVersionRegexp = /^\d+\.\d+\.(\d{4})(\d{2})(\d{2})/;
|
|
||||||
const [, yyyy, mm, dd] = this.packageJsonVersion.match(realVersionRegexp)!;
|
|
||||||
|
|
||||||
return `${yyyy}-${mm}-${dd}`;
|
|
||||||
})();
|
|
||||||
|
|
||||||
private cfg!: vscode.WorkspaceConfiguration;
|
private cfg!: vscode.WorkspaceConfiguration;
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ async function bootstrap(config: Config, state: PersistentState): Promise<string
|
||||||
|
|
||||||
async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> {
|
async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> {
|
||||||
if (config.channel === "stable") {
|
if (config.channel === "stable") {
|
||||||
if (config.extensionReleaseTag === NIGHTLY_TAG) {
|
if (config.releaseTag === NIGHTLY_TAG) {
|
||||||
vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension.
|
vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension.
|
||||||
To switch to stable, uninstall the extension and re-install it from the marketplace`);
|
To switch to stable, uninstall the extension and re-install it from the marketplace`);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
|
||||||
if (userResponse !== "Download now") return dest;
|
if (userResponse !== "Download now") return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
const release = await fetchRelease(config.extensionReleaseTag);
|
const release = await fetchRelease(config.releaseTag);
|
||||||
const artifact = release.assets.find(artifact => artifact.name === binaryName);
|
const artifact = release.assets.find(artifact => artifact.name === binaryName);
|
||||||
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
|
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
|
||||||
|
|
||||||
|
|
|
@ -7,31 +7,27 @@ use crate::{
|
||||||
project_root,
|
project_root,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn run_dist(nightly: bool) -> Result<()> {
|
pub fn run_dist(version: &str, release_tag: &str) -> Result<()> {
|
||||||
let dist = project_root().join("dist");
|
let dist = project_root().join("dist");
|
||||||
rm_rf(&dist)?;
|
rm_rf(&dist)?;
|
||||||
fs2::create_dir_all(&dist)?;
|
fs2::create_dir_all(&dist)?;
|
||||||
|
|
||||||
if cfg!(target_os = "linux") {
|
if cfg!(target_os = "linux") {
|
||||||
dist_client(nightly)?;
|
dist_client(version, release_tag)?;
|
||||||
}
|
}
|
||||||
dist_server()?;
|
dist_server()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dist_client(nightly: bool) -> Result<()> {
|
fn dist_client(version: &str, release_tag: &str) -> Result<()> {
|
||||||
let _d = pushd("./editors/code");
|
let _d = pushd("./editors/code");
|
||||||
|
let nightly = release_tag == "nightly";
|
||||||
|
|
||||||
let package_json_path = PathBuf::from("./package.json");
|
let mut patch = Patch::new("./package.json")?;
|
||||||
let mut patch = Patch::new(package_json_path.clone())?;
|
|
||||||
|
|
||||||
let date = run!("date --utc +%Y%m%d")?;
|
patch
|
||||||
let version_suffix = if nightly { "-nightly" } else { "" };
|
.replace(r#""version": "0.4.0-dev""#, &format!(r#""version": "{}""#, version))
|
||||||
|
.replace(r#""releaseTag": "nightly""#, &format!(r#""releaseTag": "{}""#, release_tag));
|
||||||
patch.replace(
|
|
||||||
r#""version": "0.2.20200309-nightly""#,
|
|
||||||
&format!(r#""version": "0.1.{}{}""#, date, version_suffix),
|
|
||||||
);
|
|
||||||
|
|
||||||
if nightly {
|
if nightly {
|
||||||
patch.replace(
|
patch.replace(
|
||||||
|
@ -86,7 +82,8 @@ struct Patch {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Patch {
|
impl Patch {
|
||||||
fn new(path: PathBuf) -> Result<Patch> {
|
fn new(path: impl Into<PathBuf>) -> Result<Patch> {
|
||||||
|
let path = path.into();
|
||||||
let contents = fs2::read_to_string(&path)?;
|
let contents = fs2::read_to_string(&path)?;
|
||||||
Ok(Patch { path, original_contents: contents.clone(), contents })
|
Ok(Patch { path, original_contents: contents.clone(), contents })
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,9 +103,10 @@ FLAGS:
|
||||||
run_release(dry_run)
|
run_release(dry_run)
|
||||||
}
|
}
|
||||||
"dist" => {
|
"dist" => {
|
||||||
let nightly = args.contains("--nightly");
|
let version: String = args.value_from_str("--version")?;
|
||||||
|
let release_tag: String = args.value_from_str("--tag")?;
|
||||||
args.finish()?;
|
args.finish()?;
|
||||||
run_dist(nightly)
|
run_dist(&version, &release_tag)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|
Loading…
Reference in a new issue