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