]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
Merge #10685
[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-20.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-aarch64-unknown-linux-gnu:
127     name: dist (aarch64-unknown-linux-gnu)
128     runs-on: ubuntu-20.04
129     env:
130       RA_TARGET: aarch64-unknown-linux-gnu
131       CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
132
133     steps:
134     - name: Checkout repository
135       uses: actions/checkout@v2
136       with:
137         fetch-depth: ${{ env.FETCH_DEPTH }}
138
139     - name: Install Rust toolchain
140       uses: actions-rs/toolchain@v1
141       with:
142         toolchain: stable
143         target: aarch64-unknown-linux-gnu
144         profile: minimal
145         override: true
146
147     - name: Update apt repositories
148       run: sudo apt-get update
149
150     - name: Install target toolchain
151       run: sudo apt-get install gcc-aarch64-linux-gnu
152
153     - name: Dist
154       run: cargo xtask dist
155
156     - name: Upload artifacts
157       uses: actions/upload-artifact@v1
158       with:
159         name: dist-aarch64-unknown-linux-gnu
160         path: ./dist
161
162   dist-x86_64-unknown-linux-musl:
163     name: dist (x86_64-unknown-linux-musl)
164     runs-on: ubuntu-latest
165     env:
166       RA_TARGET: x86_64-unknown-linux-musl
167       # For some reason `-crt-static` is not working for clang without lld
168       RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
169     container:
170       image: rust:alpine
171       volumes:
172       - /usr/local/cargo/registry
173
174     steps:
175     - name: Install dependencies
176       run: apk add --no-cache git clang lld musl-dev
177
178     - name: Checkout repository
179       uses: actions/checkout@v2
180       with:
181         fetch-depth: ${{ env.FETCH_DEPTH }}
182
183     - name: Dist
184       run: cargo xtask dist
185
186     - name: Upload artifacts
187       uses: actions/upload-artifact@v1
188       with:
189         name: dist-x86_64-unknown-linux-musl
190         path: ./dist
191
192   dist-x86_64-apple-darwin:
193     name: dist (x86_64-apple-darwin)
194     runs-on: macos-latest
195     env:
196       RA_TARGET: x86_64-apple-darwin
197       SELECT_XCODE: /Applications/Xcode_12.2.app
198
199     steps:
200     - name: Select XCode version
201       run: sudo xcode-select -s "${SELECT_XCODE}"
202
203     - name: Checkout repository
204       uses: actions/checkout@v2
205       with:
206         fetch-depth: ${{ env.FETCH_DEPTH }}
207
208     - name: Install Rust toolchain
209       uses: actions-rs/toolchain@v1
210       with:
211         toolchain: stable
212         profile: minimal
213         override: true
214
215     - name: Dist
216       run: cargo xtask dist
217
218     - name: Upload artifacts
219       uses: actions/upload-artifact@v1
220       with:
221         name: dist-x86_64-apple-darwin
222         path: ./dist
223
224   dist-aarch64-apple-darwin:
225     name: dist (aarch64-apple-darwin)
226     runs-on: macos-latest
227     env:
228       RA_TARGET: aarch64-apple-darwin
229       SELECT_XCODE: /Applications/Xcode_12.2.app
230
231     steps:
232     - name: Select XCode version
233       run: sudo xcode-select -s "${SELECT_XCODE}"
234
235     - name: Checkout repository
236       uses: actions/checkout@v2
237       with:
238         fetch-depth: ${{ env.FETCH_DEPTH }}
239
240     - name: Install Rust toolchain
241       uses: actions-rs/toolchain@v1
242       with:
243         toolchain: stable
244         target: aarch64-apple-darwin
245         profile: minimal
246         override: true
247
248     - name: Dist
249       run: SDKROOT=$(xcrun -sdk macosx11.0 --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.0 --show-sdk-platform-version) cargo xtask dist
250
251     - name: Upload artifacts
252       uses: actions/upload-artifact@v1
253       with:
254         name: dist-aarch64-apple-darwin
255         path: ./dist
256
257   publish:
258     name: publish
259     runs-on: ubuntu-latest
260     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']
261     steps:
262     - name: Install Nodejs
263       uses: actions/setup-node@v1
264       with:
265         node-version: 12.x
266
267     - run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
268       if: github.ref == 'refs/heads/release'
269     - run: echo "TAG=nightly" >> $GITHUB_ENV
270       if: github.ref != 'refs/heads/release'
271     - run: 'echo "TAG: $TAG"'
272
273     - name: Checkout repository
274       uses: actions/checkout@v2
275       with:
276         fetch-depth: ${{ env.FETCH_DEPTH }}
277
278     - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
279     - run: 'echo "HEAD_SHA: $HEAD_SHA"'
280
281     - uses: actions/download-artifact@v1
282       with:
283         name: dist-aarch64-apple-darwin
284         path: dist
285     - uses: actions/download-artifact@v1
286       with:
287         name: dist-x86_64-apple-darwin
288         path: dist
289     - uses: actions/download-artifact@v1
290       with:
291         name: dist-x86_64-unknown-linux-gnu
292         path: dist
293     - uses: actions/download-artifact@v1
294       with:
295         name: dist-x86_64-unknown-linux-musl
296         path: dist
297     - uses: actions/download-artifact@v1
298       with:
299         name: dist-aarch64-unknown-linux-gnu
300         path: dist
301     - uses: actions/download-artifact@v1
302       with:
303         name: dist-x86_64-pc-windows-msvc
304         path: dist
305     - uses: actions/download-artifact@v1
306       with:
307         name: dist-aarch64-pc-windows-msvc
308         path: dist
309     - run: ls -al ./dist
310
311     - name: Publish Release
312       uses: ./.github/actions/github-release
313       with:
314         files: "dist/*"
315         name: ${{ env.TAG }}
316         token: ${{ secrets.GITHUB_TOKEN }}
317
318     - run: npm ci
319       working-directory: ./editors/code
320
321     - name: Publish Extension
322       if: github.ref == 'refs/heads/release'
323       working-directory: ./editors/code
324       # token from https://dev.azure.com/rust-analyzer/
325       run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer.vsix