]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
Merge #7658
[rust.git] / .github / workflows / release.yaml
1 name: release
2 on:
3   schedule:
4   - cron: '0 0 * * *' # midnight UTC
5
6   push:
7     branches:
8     - release
9     - trigger-nightly
10
11 env:
12   CARGO_INCREMENTAL: 0
13   CARGO_NET_RETRY: 10
14   RUSTFLAGS: "-D warnings -W unreachable-pub"
15   RUSTUP_MAX_RETRIES: 10
16
17 jobs:
18   dist-x86_64-pc-windows-msvc:
19     name: dist (x86_64-pc-windows-msvc)
20     runs-on: windows-latest
21     env:
22       RA_TARGET: x86_64-pc-windows-msvc
23
24     steps:
25     - name: Checkout repository
26       uses: actions/checkout@v2
27
28     # We need to disable the existing toolchain to avoid updating rust-docs
29     # which takes a long time. The fastest way to do this is to rename the
30     # existing folder, as deleting it takes about as much time as not doing
31     # anything and just updating rust-docs.
32     - name: Rename existing rust toolchain
33       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
34
35     - name: Install Rust toolchain
36       uses: actions-rs/toolchain@v1
37       with:
38         toolchain: stable
39         profile: minimal
40         override: true
41
42     - name: Dist
43       run: cargo xtask dist
44
45     - name: Upload artifacts
46       uses: actions/upload-artifact@v1
47       with:
48         name: dist-x86_64-pc-windows-msvc
49         path: ./dist
50
51   dist-aarch64-pc-windows-msvc:
52     name: dist (aarch64-pc-windows-msvc)
53     runs-on: windows-latest
54     env:
55       RA_TARGET: aarch64-pc-windows-msvc
56
57     steps:
58     - name: Checkout repository
59       uses: actions/checkout@v2
60
61     - name: Rename existing rust toolchain
62       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
63
64     - name: Install Rust toolchain
65       uses: actions-rs/toolchain@v1
66       with:
67         toolchain: stable
68         target: aarch64-pc-windows-msvc
69         profile: minimal
70         override: true
71
72     - name: Dist
73       run: cargo xtask dist
74
75     - name: Upload artifacts
76       uses: actions/upload-artifact@v1
77       with:
78         name: dist-aarch64-pc-windows-msvc
79         path: ./dist
80
81   dist-x86_64-unknown-linux-gnu:
82     name: dist (x86_64-unknown-linux-gnu)
83     runs-on: ubuntu-16.04
84     env:
85       RA_TARGET: x86_64-unknown-linux-gnu
86
87     steps:
88     - name: Checkout repository
89       uses: actions/checkout@v2
90
91     - name: Install Rust toolchain
92       uses: actions-rs/toolchain@v1
93       with:
94         toolchain: stable
95         profile: minimal
96         override: true
97         components: rust-src
98
99     - name: Install Nodejs
100       uses: actions/setup-node@v1
101       with:
102         node-version: 12.x
103
104     - name: Dist
105       if: github.ref == 'refs/heads/release'
106       run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER
107
108     - name: Dist
109       if: github.ref != 'refs/heads/release'
110       run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly
111
112     - name: Run analysis-stats on rust-analyzer
113       run: target/${{ env.RA_TARGET }}/release/rust-analyzer analysis-stats .
114
115     - name: Run analysis-stats on rust std library
116       run: target/${{ env.RA_TARGET }}/release/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
117
118     - name: Upload artifacts
119       uses: actions/upload-artifact@v1
120       with:
121         name: dist-x86_64-unknown-linux-gnu
122         path: ./dist
123
124   dist-x86_64-unknown-linux-musl:
125     name: dist (x86_64-unknown-linux-musl)
126     runs-on: ubuntu-20.04
127     env:
128       RA_TARGET: x86_64-unknown-linux-musl
129       # For some reason `-crt-static` is not working for clang without lld
130       RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
131     container:
132       image: rust:alpine
133       volumes:
134       - /usr/local/cargo/registry
135
136     steps:
137     - name: Install dependencies
138       run: apk add --no-cache git clang lld musl-dev
139
140     - name: Checkout repository
141       uses: actions/checkout@v2
142
143     - name: Dist
144       run: cargo xtask dist
145
146     - name: Upload artifacts
147       uses: actions/upload-artifact@v1
148       with:
149         name: dist-x86_64-unknown-linux-musl
150         path: ./dist
151
152   dist-aarch64-unknown-linux-gnu:
153     name: dist (aarch64-unknown-linux-gnu)
154     runs-on: ubuntu-16.04
155     env:
156       RA_TARGET: aarch64-unknown-linux-gnu
157       CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
158
159     steps:
160     - name: Checkout repository
161       uses: actions/checkout@v2
162
163     - name: Install Rust toolchain
164       uses: actions-rs/toolchain@v1
165       with:
166         toolchain: stable
167         target: aarch64-unknown-linux-gnu
168         profile: minimal
169         override: true
170
171     - name: Install target toolchain
172       run: sudo apt-get install gcc-aarch64-linux-gnu
173
174     - name: Dist
175       run: cargo xtask dist
176
177     - name: Upload artifacts
178       uses: actions/upload-artifact@v1
179       with:
180         name: dist-aarch64-unknown-linux-gnu
181         path: ./dist
182
183   dist-x86_64-apple-darwin:
184     name: dist (x86_64-apple-darwin)
185     runs-on: macos-latest
186     env:
187       RA_TARGET: x86_64-apple-darwin
188       SELECT_XCODE: /Applications/Xcode_12.2.app
189
190     steps:
191     - name: Select XCode version
192       run: sudo xcode-select -s "${SELECT_XCODE}"
193
194     - name: Checkout repository
195       uses: actions/checkout@v2
196
197     - name: Install Rust toolchain
198       uses: actions-rs/toolchain@v1
199       with:
200         toolchain: stable
201         profile: minimal
202         override: true
203
204     - name: Dist
205       run: cargo xtask dist
206
207     - name: Upload artifacts
208       uses: actions/upload-artifact@v1
209       with:
210         name: dist-x86_64-apple-darwin
211         path: ./dist
212
213   dist-aarch64-apple-darwin:
214     name: dist (aarch64-apple-darwin)
215     runs-on: macos-latest
216     env:
217       RA_TARGET: aarch64-apple-darwin
218       SELECT_XCODE: /Applications/Xcode_12.2.app
219
220     steps:
221     - name: Select XCode version
222       run: sudo xcode-select -s "${SELECT_XCODE}"
223
224     - name: Checkout repository
225       uses: actions/checkout@v2
226
227     - name: Install Rust toolchain
228       uses: actions-rs/toolchain@v1
229       with:
230         toolchain: stable
231         target: aarch64-apple-darwin
232         profile: minimal
233         override: true
234
235     - name: Dist
236       run: SDKROOT=$(xcrun -sdk macosx11.0 --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.0 --show-sdk-platform-version) cargo xtask dist
237
238     - name: Upload artifacts
239       uses: actions/upload-artifact@v1
240       with:
241         name: dist-aarch64-apple-darwin
242         path: ./dist
243
244   publish:
245     name: publish
246     runs-on: ubuntu-16.04
247     needs: ['dist-x86_64-pc-windows-msvc', 'dist-aarch64-pc-windows-msvc', 'dist-x86_64-unknown-linux-gnu', 'dist-x86_64-unknown-linux-musl', 'dist-aarch64-unknown-linux-gnu', 'dist-x86_64-apple-darwin', 'dist-aarch64-apple-darwin']
248     steps:
249     - name: Install Nodejs
250       uses: actions/setup-node@v1
251       with:
252         node-version: 12.x
253
254     - run: echo "TAG=$(date --iso --utc)" >> $GITHUB_ENV
255       if: github.ref == 'refs/heads/release'
256     - run: echo "TAG=nightly" >> $GITHUB_ENV
257       if: github.ref != 'refs/heads/release'
258     - run: 'echo "TAG: $TAG"'
259
260     - name: Checkout repository
261       uses: actions/checkout@v2
262
263     - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
264     - run: 'echo "HEAD_SHA: $HEAD_SHA"'
265
266     - uses: actions/download-artifact@v1
267       with:
268         name: dist-aarch64-apple-darwin
269         path: dist
270     - uses: actions/download-artifact@v1
271       with:
272         name: dist-x86_64-apple-darwin
273         path: dist
274     - uses: actions/download-artifact@v1
275       with:
276         name: dist-x86_64-unknown-linux-gnu
277         path: dist
278     - uses: actions/download-artifact@v1
279       with:
280         name: dist-x86_64-unknown-linux-musl
281         path: dist
282     - uses: actions/download-artifact@v1
283       with:
284         name: dist-aarch64-unknown-linux-gnu
285         path: dist
286     - uses: actions/download-artifact@v1
287       with:
288         name: dist-x86_64-pc-windows-msvc
289         path: dist
290     - uses: actions/download-artifact@v1
291       with:
292         name: dist-aarch64-pc-windows-msvc
293         path: dist
294     - run: ls -al ./dist
295
296     - name: Publish Release
297       uses: ./.github/actions/github-release
298       with:
299         files: "dist/*"
300         name: ${{ env.TAG }}
301         token: ${{ secrets.GITHUB_TOKEN }}
302
303     - run: npm ci
304       working-directory: ./editors/code
305
306     - name: Publish Extension
307       if: github.ref == 'refs/heads/release'
308       working-directory: ./editors/code
309       # token from https://dev.azure.com/rust-analyzer/
310       run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer.vsix