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