aboutsummaryrefslogtreecommitdiff
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 919d58925..09752b817 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -15,12 +15,9 @@ env:
15 RUSTUP_MAX_RETRIES: 10 15 RUSTUP_MAX_RETRIES: 10
16 16
17jobs: 17jobs:
18 dist: 18 dist-windows:
19 name: dist 19 name: dist (Windows)
20 runs-on: ${{ matrix.os }} 20 runs-on: windows-latest
21 strategy:
22 matrix:
23 os: [ubuntu-16.04, windows-latest, macos-latest]
24 21
25 steps: 22 steps:
26 - name: Checkout repository 23 - name: Checkout repository
@@ -30,8 +27,7 @@ jobs:
30 # which takes a long time. The fastest way to do this is to rename the 27 # which takes a long time. The fastest way to do this is to rename the
31 # existing folder, as deleting it takes about as much time as not doing 28 # existing folder, as deleting it takes about as much time as not doing
32 # anything and just updating rust-docs. 29 # anything and just updating rust-docs.
33 - name: Rename existing rust toolchain (Windows) 30 - name: Rename existing rust toolchain
34 if: matrix.os == 'windows-latest'
35 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 31 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
36 32
37 - name: Install Rust toolchain 33 - name: Install Rust toolchain
@@ -41,38 +37,116 @@ jobs:
41 profile: minimal 37 profile: minimal
42 override: true 38 override: true
43 39
40 - name: Dist
41 run: cargo xtask dist
42 env:
43 RA_TARGET: x86_64-pc-windows-msvc
44
45 - name: Upload artifacts
46 uses: actions/upload-artifact@v1
47 with:
48 name: dist-windows-latest
49 path: ./dist
50
51 dist-ubuntu:
52 name: dist (Ubuntu 16.04)
53 runs-on: ubuntu-16.04
54
55 steps:
56 - name: Checkout repository
57 uses: actions/checkout@v2
58
59 - name: Install Rust toolchain
60 uses: actions-rs/toolchain@v1
61 with:
62 toolchain: stable
63 profile: minimal
64 override: true
65
44 - name: Install Nodejs 66 - name: Install Nodejs
45 if: matrix.os == 'ubuntu-16.04'
46 uses: actions/setup-node@v1 67 uses: actions/setup-node@v1
47 with: 68 with:
48 node-version: 12.x 69 node-version: 12.x
49 70
50 - name: Dist 71 - name: Dist
51 if: matrix.os == 'ubuntu-16.04' && github.ref == 'refs/heads/release' 72 if: github.ref == 'refs/heads/release'
52 run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER 73 run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER
74 env:
75 RA_TARGET: x86_64-unknown-linux-gnu
53 76
54 - name: Dist 77 - name: Dist
55 if: matrix.os == 'ubuntu-16.04' && github.ref != 'refs/heads/release' 78 if: github.ref != 'refs/heads/release'
56 run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly 79 run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly
80 env:
81 RA_TARGET: x86_64-unknown-linux-gnu
82
83 - name: Nightly analysis-stats check
84 if: github.ref != 'refs/heads/release'
85 run: ./dist/rust-analyzer-x86_64-unknown-linux-gnu analysis-stats .
86
87 - name: Upload artifacts
88 uses: actions/upload-artifact@v1
89 with:
90 name: dist-ubuntu-16.04
91 path: ./dist
92
93 dist-macos-latest:
94 name: dist (MacOS latest)
95 runs-on: macos-latest
96
97 steps:
98 - name: Checkout repository
99 uses: actions/checkout@v2
100
101 - name: Install Rust toolchain
102 uses: actions-rs/toolchain@v1
103 with:
104 toolchain: stable
105 profile: minimal
106 override: true
57 107
58 - name: Dist 108 - name: Dist
59 if: matrix.os != 'ubuntu-16.04'
60 run: cargo xtask dist 109 run: cargo xtask dist
110 env:
111 RA_TARGET: x86_64-apple-darwin
61 112
62 - name: Nightly analysis-stats check 113 - name: Upload artifacts
63 if: matrix.os == 'ubuntu-16.04' && github.ref != 'refs/heads/release' 114 uses: actions/upload-artifact@v1
64 run: ./dist/rust-analyzer-linux analysis-stats . 115 with:
116 name: dist-macos-latest
117 path: ./dist
118
119 dist-macos-11:
120 name: dist (MacOS 11.0)
121 runs-on: macos-11.0
122
123 steps:
124 - name: Checkout repository
125 uses: actions/checkout@v2
126
127 - name: Install Rust toolchain (beta)
128 uses: actions-rs/toolchain@v1
129 with:
130 toolchain: beta
131 target: aarch64-apple-darwin
132 profile: minimal
133 override: true
134
135 - name: Dist
136 run: cargo xtask dist
137 env:
138 RA_TARGET: aarch64-apple-darwin
65 139
66 - name: Upload artifacts 140 - name: Upload artifacts
67 uses: actions/upload-artifact@v1 141 uses: actions/upload-artifact@v1
68 with: 142 with:
69 name: dist-${{ matrix.os }} 143 name: dist-macos-11.0
70 path: ./dist 144 path: ./dist
71 145
72 publish: 146 publish:
73 name: publish 147 name: publish
74 runs-on: ubuntu-16.04 148 runs-on: ubuntu-16.04
75 needs: ['dist'] 149 needs: ['dist-windows', 'dist-ubuntu', 'dist-macos-latest', 'dist-macos-11']
76 steps: 150 steps:
77 - name: Install Nodejs 151 - name: Install Nodejs
78 uses: actions/setup-node@v1 152 uses: actions/setup-node@v1
@@ -93,6 +167,10 @@ jobs:
93 167
94 - uses: actions/download-artifact@v1 168 - uses: actions/download-artifact@v1
95 with: 169 with:
170 name: dist-macos-11.0
171 path: dist
172 - uses: actions/download-artifact@v1
173 with:
96 name: dist-macos-latest 174 name: dist-macos-latest
97 path: dist 175 path: dist
98 - uses: actions/download-artifact@v1 176 - uses: actions/download-artifact@v1
@@ -103,7 +181,7 @@ jobs:
103 with: 181 with:
104 name: dist-windows-latest 182 name: dist-windows-latest
105 path: dist 183 path: dist
106 - run: ls -all ./dist 184 - run: ls -al ./dist
107 185
108 - name: Publish Release 186 - name: Publish Release
109 uses: ./.github/actions/github-release 187 uses: ./.github/actions/github-release
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs
index 9e15a5a4c..d07ad9420 100644
--- a/xtask/src/dist.rs
+++ b/xtask/src/dist.rs
@@ -58,30 +58,74 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> {
58} 58}
59 59
60fn dist_server() -> Result<()> { 60fn dist_server() -> Result<()> {
61 if cfg!(target_os = "linux") { 61 let target = get_target();
62 if target.contains("-linux-gnu") {
62 env::set_var("CC", "clang"); 63 env::set_var("CC", "clang");
63 } 64 }
64 cmd!("cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --release").run()?;
65
66 let (src, dst) = if cfg!(target_os = "linux") {
67 ("./target/release/rust-analyzer", "./dist/rust-analyzer-linux")
68 } else if cfg!(target_os = "windows") {
69 ("./target/release/rust-analyzer.exe", "./dist/rust-analyzer-windows.exe")
70 } else if cfg!(target_os = "macos") {
71 ("./target/release/rust-analyzer", "./dist/rust-analyzer-mac")
72 } else {
73 panic!("Unsupported OS")
74 };
75 65
76 let src = Path::new(src); 66 let toolchain = toolchain(&target);
77 let dst = Path::new(dst); 67 cmd!("cargo +{toolchain} build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target} --release").run()?;
78 68
69 let suffix = exe_suffix(&target);
70 let src =
71 Path::new("target").join(&target).join("release").join(format!("rust-analyzer{}", suffix));
72 let dst = Path::new("dist").join(format!("rust-analyzer-{}{}", target, suffix));
79 cp(&src, &dst)?; 73 cp(&src, &dst)?;
80 gzip(&src, &dst.with_extension("gz"))?; 74 gzip(&src, &dst.with_extension("gz"))?;
81 75
76 // FIXME: the old names are temporarily kept for client compatibility, but they should be removed
77 // Remove this block after a couple of releases
78 match target.as_ref() {
79 "x86_64-unknown-linux-gnu" => {
80 cp(&src, "dist/rust-analyzer-linux")?;
81 gzip(&src, Path::new("dist/rust-analyzer-linux.gz"))?;
82 }
83 "x86_64-pc-windows-msvc" => {
84 cp(&src, "dist/rust-analyzer-windows.exe")?;
85 gzip(&src, Path::new("dist/rust-analyzer-windows.gz"))?;
86 }
87 "x86_64-apple-darwin" => {
88 cp(&src, "dist/rust-analyzer-mac")?;
89 gzip(&src, Path::new("dist/rust-analyzer-mac.gz"))?;
90 }
91 _ => {}
92 }
93
82 Ok(()) 94 Ok(())
83} 95}
84 96
97fn get_target() -> String {
98 match env::var("RA_TARGET") {
99 Ok(target) => target,
100 _ => {
101 if cfg!(target_os = "linux") {
102 "x86_64-unknown-linux-gnu".to_string()
103 } else if cfg!(target_os = "windows") {
104 "x86_64-pc-windows-msvc".to_string()
105 } else if cfg!(target_os = "macos") {
106 "x86_64-apple-darwin".to_string()
107 } else {
108 panic!("Unsupported OS, maybe try setting RA_TARGET")
109 }
110 }
111 }
112}
113
114fn exe_suffix(target: &str) -> String {
115 if target.contains("-windows-") {
116 ".exe".into()
117 } else {
118 "".into()
119 }
120}
121
122fn toolchain(target: &str) -> String {
123 match target {
124 "aarch64-apple-darwin" => "beta".to_string(),
125 _ => "stable".to_string(),
126 }
127}
128
85fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> { 129fn gzip(src_path: &Path, dest_path: &Path) -> Result<()> {
86 let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best()); 130 let mut encoder = GzEncoder::new(File::create(dest_path)?, Compression::best());
87 let mut input = io::BufReader::new(File::open(src_path)?); 131 let mut input = io::BufReader::new(File::open(src_path)?);