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