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