]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
Merge #11021
[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: 14.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 # use the default (12.5.1 as of today)
201 #    - name: Select XCode version
202 #      run: sudo xcode-select -s "${SELECT_XCODE}"
203
204     - name: Checkout repository
205       uses: actions/checkout@v2
206       with:
207         fetch-depth: ${{ env.FETCH_DEPTH }}
208
209     - name: Install Rust toolchain
210       uses: actions-rs/toolchain@v1
211       with:
212         toolchain: stable
213         profile: minimal
214         override: true
215
216     - name: Dist
217       run: cargo xtask dist
218
219     - name: Upload artifacts
220       uses: actions/upload-artifact@v1
221       with:
222         name: dist-x86_64-apple-darwin
223         path: ./dist
224
225   dist-aarch64-apple-darwin:
226     name: dist (aarch64-apple-darwin)
227     runs-on: macos-latest
228     env:
229       RA_TARGET: aarch64-apple-darwin
230       SELECT_XCODE: /Applications/Xcode_12.2.app
231
232     steps:
233     - name: Select XCode version
234       run: sudo xcode-select -s "${SELECT_XCODE}"
235
236     - name: Checkout repository
237       uses: actions/checkout@v2
238       with:
239         fetch-depth: ${{ env.FETCH_DEPTH }}
240
241     - name: Install Rust toolchain
242       uses: actions-rs/toolchain@v1
243       with:
244         toolchain: stable
245         target: aarch64-apple-darwin
246         profile: minimal
247         override: true
248
249     - name: Dist
250       run: SDKROOT=$(xcrun -sdk macosx11.0 --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.0 --show-sdk-platform-version) cargo xtask dist
251
252     - name: Upload artifacts
253       uses: actions/upload-artifact@v1
254       with:
255         name: dist-aarch64-apple-darwin
256         path: ./dist
257
258   publish:
259     name: publish
260     runs-on: ubuntu-latest
261     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']
262     steps:
263     - name: Install Nodejs
264       uses: actions/setup-node@v1
265       with:
266         node-version: 14.x
267
268     - run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
269       if: github.ref == 'refs/heads/release'
270     - run: echo "TAG=nightly" >> $GITHUB_ENV
271       if: github.ref != 'refs/heads/release'
272     - run: 'echo "TAG: $TAG"'
273
274     - name: Checkout repository
275       uses: actions/checkout@v2
276       with:
277         fetch-depth: ${{ env.FETCH_DEPTH }}
278
279     - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
280     - run: 'echo "HEAD_SHA: $HEAD_SHA"'
281
282     - uses: actions/download-artifact@v1
283       with:
284         name: dist-aarch64-apple-darwin
285         path: dist
286     - uses: actions/download-artifact@v1
287       with:
288         name: dist-x86_64-apple-darwin
289         path: dist
290     - uses: actions/download-artifact@v1
291       with:
292         name: dist-x86_64-unknown-linux-gnu
293         path: dist
294     - uses: actions/download-artifact@v1
295       with:
296         name: dist-x86_64-unknown-linux-musl
297         path: dist
298     - uses: actions/download-artifact@v1
299       with:
300         name: dist-aarch64-unknown-linux-gnu
301         path: dist
302     - uses: actions/download-artifact@v1
303       with:
304         name: dist-x86_64-pc-windows-msvc
305         path: dist
306     - uses: actions/download-artifact@v1
307       with:
308         name: dist-aarch64-pc-windows-msvc
309         path: dist
310     - run: ls -al ./dist
311
312     - name: Publish Release
313       uses: ./.github/actions/github-release
314       with:
315         files: "dist/*"
316         name: ${{ env.TAG }}
317         token: ${{ secrets.GITHUB_TOKEN }}
318
319     - run: npm ci
320       working-directory: ./editors/code
321
322     - name: Publish Extension
323       if: github.ref == 'refs/heads/release'
324       working-directory: ./editors/code
325       # token from https://dev.azure.com/rust-analyzer/
326       run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer.vsix