about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yaml114
-rw-r--r--xtask/src/dist.rs72
2 files changed, 154 insertions, 32 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 919d58925e9..09752b817f0 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -15,12 +15,9 @@ env:
   RUSTUP_MAX_RETRIES: 10
 
 jobs:
-  dist:
-    name: dist
-    runs-on: ${{ matrix.os }}
-    strategy:
-      matrix:
-        os: [ubuntu-16.04, windows-latest, macos-latest]
+  dist-windows:
+    name: dist (Windows)
+    runs-on: windows-latest
 
     steps:
     - name: Checkout repository
@@ -30,8 +27,7 @@ jobs:
     # which takes a long time. The fastest way to do this is to rename the
     # existing folder, as deleting it takes about as much time as not doing
     # anything and just updating rust-docs.
-    - name: Rename existing rust toolchain (Windows)
-      if: matrix.os == 'windows-latest'
+    - name: Rename existing rust toolchain
       run: Rename-Item C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc C:\Users\runneradmin\.rustup\toolchains\stable-x86_64-pc-windows-msvc.old
 
     - name: Install Rust toolchain
@@ -41,38 +37,116 @@ jobs:
         profile: minimal
         override: true
 
+    - name: Dist
+      run: cargo xtask dist
+      env:
+        RA_TARGET: x86_64-pc-windows-msvc
+
+    - name: Upload artifacts
+      uses: actions/upload-artifact@v1
+      with:
+        name: dist-windows-latest
+        path: ./dist
+
+  dist-ubuntu:
+    name: dist (Ubuntu 16.04)
+    runs-on: ubuntu-16.04
+
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v2
+
+    - name: Install Rust toolchain
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: stable
+        profile: minimal
+        override: true
+
     - name: Install Nodejs
-      if: matrix.os == 'ubuntu-16.04'
       uses: actions/setup-node@v1
       with:
         node-version: 12.x
 
     - name: Dist
-      if: matrix.os == 'ubuntu-16.04' && github.ref == 'refs/heads/release'
+      if: github.ref == 'refs/heads/release'
       run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER
+      env:
+        RA_TARGET: x86_64-unknown-linux-gnu
 
     - name: Dist
-      if: matrix.os == 'ubuntu-16.04' && github.ref != 'refs/heads/release'
+      if: github.ref != 'refs/heads/release'
       run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly
+      env:
+        RA_TARGET: x86_64-unknown-linux-gnu
+
+    - name: Nightly analysis-stats check
+      if: github.ref != 'refs/heads/release'
+      run: ./dist/rust-analyzer-x86_64-unknown-linux-gnu analysis-stats .
+
+    - name: Upload artifacts
+      uses: actions/upload-artifact@v1
+      with:
+        name: dist-ubuntu-16.04
+        path: ./dist
+
+  dist-macos-latest:
+    name: dist (MacOS latest)
+    runs-on: macos-latest
+
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v2
+
+    - name: Install Rust toolchain
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: stable
+        profile: minimal
+        override: true
 
     - name: Dist
-      if: matrix.os != 'ubuntu-16.04'
       run: cargo xtask dist
+      env:
+        RA_TARGET: x86_64-apple-darwin
 
-    - name: Nightly analysis-stats check
-      if: matrix.os == 'ubuntu-16.04' && github.ref != 'refs/heads/release'
-      run: ./dist/rust-analyzer-linux analysis-stats .
+    - name: Upload artifacts
+      uses: actions/upload-artifact@v1
+      with:
+        name: dist-macos-latest
+        path: ./dist
+
+  dist-macos-11:
+    name: dist (MacOS 11.0)
+    runs-on: macos-11.0
+
+    steps:
+    - name: Checkout repository
+      uses: actions/checkout@v2
+
+    - name: Install Rust toolchain (beta)
+      uses: actions-rs/toolchain@v1
+      with:
+        toolchain: beta
+        target: aarch64-apple-darwin
+        profile: minimal
+        override: true
+
+    - name: Dist
+      run: cargo xtask dist
+      env:
+        RA_TARGET: aarch64-apple-darwin
 
     - name: Upload artifacts
       uses: actions/upload-artifact@v1
       with:
-        name: dist-${{ matrix.os }}
+        name: dist-macos-11.0
         path: ./dist
 
   publish:
     name: publish
     runs-on: ubuntu-16.04
-    needs: ['dist']
+    needs: ['dist-windows', 'dist-ubuntu', 'dist-macos-latest', 'dist-macos-11']
     steps:
     - name: Install Nodejs
       uses: actions/setup-node@v1
@@ -93,6 +167,10 @@ jobs:
 
     - uses: actions/download-artifact@v1
       with:
+        name: dist-macos-11.0
+        path: dist
+    - uses: actions/download-artifact@v1
+      with:
         name: dist-macos-latest
         path: dist
     - uses: actions/download-artifact@v1
@@ -103,7 +181,7 @@ jobs:
       with:
         name: dist-windows-latest
         path: dist
-    - run: ls -all ./dist
+    - run: ls -al ./dist
 
     - name: Publish Release
       uses: ./.github/actions/github-release
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index 9e15a5a4c9f..d07ad94204c 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -58,30 +58,74 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> {
 }
 
 fn dist_server() -> Result<()> {
-    if cfg!(target_os = "linux") {
+    let target = get_target();
+    if target.contains("-linux-gnu") {
         env::set_var("CC", "clang");
     }
-    cmd!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release").run()?;
-
-    let (src, dst) = if cfg!(target_os = "linux") {
-        ("./target/release/rust-analyzer", "./dist/rust-analyzer-linux")
-    } else if cfg!(target_os = "windows") {
-        ("./target/release/rust-analyzer.exe", "./dist/rust-analyzer-windows.exe")
-    } else if cfg!(target_os = "macos") {
-        ("./target/release/rust-analyzer", "./dist/rust-analyzer-mac")
-    } else {
-        panic!("Unsupported OS")
-    };
 
-    let src = Path::new(src);
-    let dst = Path::new(dst);
+    let toolchain = toolchain(&target);
+    cmd!("cargo +{toolchain} build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --release").run()?;
 
+    let suffix = exe_suffix(&target);
+    let src =
+        Path::new("target").join(&target).join("release").join(format!("rust-analyzer{}", suffix));
+    let dst = Path::new("dist").join(format!("rust-analyzer-{}{}", target, suffix));
     cp(&src, &dst)?;
     gzip(&src, &dst.with_extension("gz"))?;
 
+    // FIXME: the old names are temporarily kept for client compatibility, but they should be removed
+    // Remove this block after a couple of releases
+    match target.as_ref() {
+        "x86_64-unknown-linux-gnu" => {
+            cp(&src, "dist/rust-analyzer-linux")?;
+            gzip(&src, Path::new("dist/rust-analyzer-linux.gz"))?;
+        }
+        "x86_64-pc-windows-msvc" => {
+            cp(&src, "dist/rust-analyzer-windows.exe")?;
+            gzip(&src, Path::new("dist/rust-analyzer-windows.gz"))?;
+        }
+        "x86_64-apple-darwin" => {
+            cp(&src, "dist/rust-analyzer-mac")?;
+            gzip(&src, Path::new("dist/rust-analyzer-mac.gz"))?;
+        }
+        _ => {}
+    }
+
     Ok(())
 }
 
+fn get_target() -> String {
+    match env::var("RA_TARGET") {
+        Ok(target) => target,
+        _ => {
+            if cfg!(target_os = "linux") {
+                "x86_64-unknown-linux-gnu".to_string()
+            } else if cfg!(target_os = "windows") {
+                "x86_64-pc-windows-msvc".to_string()
+            } else if cfg!(target_os = "macos") {
+                "x86_64-apple-darwin".to_string()
+            } else {
+                panic!("Unsupported OS, maybe try setting RA_TARGET")
+            }
+        }
+    }
+}
+
+fn exe_suffix(target: &str) -> String {
+    if target.contains("-windows-") {
+        ".exe".into()
+    } else {
+        "".into()
+    }
+}
+
+fn toolchain(target: &str) -> String {
+    match target {
+        "aarch64-apple-darwin" => "beta".to_string(),
+        _ => "stable".to_string(),
+    }
+}
+
 fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> {
     let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best());
     let mut input = io::BufReader::new(File::open(src_path)?);