]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
312ea066ff3c12d2a7176bf3bd69bc7eaec2dee8
[rust.git] / .github / workflows / release.yaml
1 name: release
2 on:
3   schedule:
4     - cron: "0 0 * * *" # midnight UTC
5
6   workflow_dispatch:
7
8   push:
9     branches:
10       - release
11       - trigger-nightly
12
13 env:
14   CARGO_INCREMENTAL: 0
15   CARGO_NET_RETRY: 10
16   RUSTFLAGS: "-D warnings -W unreachable-pub"
17   RUSTUP_MAX_RETRIES: 10
18   FETCH_DEPTH: 0 # pull in the tags for the version string
19   MACOSX_DEPLOYMENT_TARGET: 10.15
20   CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
21   CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
22
23 jobs:
24   dist:
25     strategy:
26       matrix:
27         include:
28           - os: windows-latest
29             target: x86_64-pc-windows-msvc
30             code-target: win32-x64
31           - os: windows-latest
32             target: aarch64-pc-windows-msvc
33             code-target: win32-arm64
34           - os: ubuntu-20.04
35             target: x86_64-unknown-linux-gnu
36             code-target: linux-x64
37             container: ubuntu:18.04
38           - os: ubuntu-20.04
39             target: aarch64-unknown-linux-gnu
40             code-target: linux-arm64
41           - os: ubuntu-20.04
42             target: arm-unknown-linux-gnueabihf
43             code-target: linux-armhf
44           - os: macos-11
45             target: x86_64-apple-darwin
46             code-target: darwin-x64
47           - os: macos-11
48             target: aarch64-apple-darwin
49             code-target: darwin-arm64
50
51     name: dist (${{ matrix.target }})
52     runs-on: ${{ matrix.os }}
53     container: ${{ matrix.container }}
54
55     env:
56       RA_TARGET: ${{ matrix.target }}
57
58     steps:
59       - name: Checkout repository
60         uses: actions/checkout@v3
61         with:
62           fetch-depth: ${{ env.FETCH_DEPTH }}
63
64       - name: Install toolchain dependencies
65         if: matrix.container == 'ubuntu:18.04'
66         run: apt-get update && apt-get install -y build-essential curl
67
68       - name: Install Rust toolchain
69         uses: actions-rs/toolchain@v1
70         with:
71           toolchain: stable
72           target: ${{ matrix.target }}
73           components: rust-src
74           override: true
75
76       - name: Install Node.js
77         uses: actions/setup-node@v1
78         with:
79           node-version: 16.x
80
81       - name: Update apt repositories
82         if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'arm-unknown-linux-gnueabihf'
83         run: sudo apt-get update
84
85       - name: Install AArch64 target toolchain
86         if: matrix.target == 'aarch64-unknown-linux-gnu'
87         run: sudo apt-get install gcc-aarch64-linux-gnu
88
89       - name: Install ARM target toolchain
90         if: matrix.target == 'arm-unknown-linux-gnueabihf'
91         run: sudo apt-get install gcc-arm-linux-gnueabihf
92
93       - name: Dist
94         run: cargo xtask dist --client-patch-version ${{ github.run_number }}
95
96       - run: npm ci
97         working-directory: editors/code
98
99       - name: Package Extension (release)
100         if: github.ref == 'refs/heads/release'
101         run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}
102         working-directory: editors/code
103
104       - name: Package Extension (nightly)
105         if: github.ref != 'refs/heads/release'
106         run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }} --pre-release
107         working-directory: editors/code
108
109       - if: matrix.target == 'x86_64-unknown-linux-gnu'
110         run: rm -rf editors/code/server
111
112       - if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref == 'refs/heads/release'
113         run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix
114         working-directory: editors/code
115
116       - if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref != 'refs/heads/release'
117         run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix --pre-release
118         working-directory: editors/code
119
120       - name: Run analysis-stats on rust-analyzer
121         if: matrix.target == 'x86_64-unknown-linux-gnu'
122         run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats .
123
124       - name: Run analysis-stats on rust std library
125         if: matrix.target == 'x86_64-unknown-linux-gnu'
126         run: target/${{ matrix.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-${{ matrix.target }}
132           path: ./dist
133
134   dist-x86_64-unknown-linux-musl:
135     name: dist (x86_64-unknown-linux-musl)
136     runs-on: ubuntu-latest
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:/usr/local/cargo/registry
145
146     steps:
147       - name: Install dependencies
148         run: apk add --no-cache git clang lld musl-dev nodejs npm
149
150       - name: Checkout repository
151         uses: actions/checkout@v3
152         with:
153           fetch-depth: ${{ env.FETCH_DEPTH }}
154
155       - name: Dist
156         run: cargo xtask dist --client-patch-version ${{ github.run_number }}
157
158       - run: npm ci
159         working-directory: editors/code
160
161       - name: Package Extension (release)
162         if: github.ref == 'refs/heads/release'
163         run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64
164         working-directory: editors/code
165
166       - name: Package Extension (nightly)
167         if: github.ref != 'refs/heads/release'
168         run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64 --pre-release
169         working-directory: editors/code
170
171       - run: rm -rf editors/code/server
172
173       - name: Upload artifacts
174         uses: actions/upload-artifact@v1
175         with:
176           name: dist-x86_64-unknown-linux-musl
177           path: ./dist
178
179   publish:
180     name: publish
181     runs-on: ubuntu-latest
182     needs: ["dist", "dist-x86_64-unknown-linux-musl"]
183     steps:
184       - name: Install Nodejs
185         uses: actions/setup-node@v1
186         with:
187           node-version: 16.x
188
189       - run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
190         if: github.ref == 'refs/heads/release'
191       - run: echo "TAG=nightly" >> $GITHUB_ENV
192         if: github.ref != 'refs/heads/release'
193       - run: 'echo "TAG: $TAG"'
194
195       - name: Checkout repository
196         uses: actions/checkout@v3
197         with:
198           fetch-depth: ${{ env.FETCH_DEPTH }}
199
200       - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
201       - run: 'echo "HEAD_SHA: $HEAD_SHA"'
202
203       - uses: actions/download-artifact@v1
204         with:
205           name: dist-aarch64-apple-darwin
206           path: dist
207       - uses: actions/download-artifact@v1
208         with:
209           name: dist-x86_64-apple-darwin
210           path: dist
211       - uses: actions/download-artifact@v1
212         with:
213           name: dist-x86_64-unknown-linux-gnu
214           path: dist
215       - uses: actions/download-artifact@v1
216         with:
217           name: dist-x86_64-unknown-linux-musl
218           path: dist
219       - uses: actions/download-artifact@v1
220         with:
221           name: dist-aarch64-unknown-linux-gnu
222           path: dist
223       - uses: actions/download-artifact@v1
224         with:
225           name: dist-arm-unknown-linux-gnueabihf
226           path: dist
227       - uses: actions/download-artifact@v1
228         with:
229           name: dist-x86_64-pc-windows-msvc
230           path: dist
231       - uses: actions/download-artifact@v1
232         with:
233           name: dist-aarch64-pc-windows-msvc
234           path: dist
235       - run: ls -al ./dist
236
237       - name: Publish Release
238         uses: ./.github/actions/github-release
239         with:
240           files: "dist/*"
241           name: ${{ env.TAG }}
242           token: ${{ secrets.GITHUB_TOKEN }}
243
244       - run: rm dist/rust-analyzer-no-server.vsix
245
246       - run: npm ci
247         working-directory: ./editors/code
248
249       - name: Publish Extension (Code Marketplace, release)
250         if: github.ref == 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
251         working-directory: ./editors/code
252         # token from https://dev.azure.com/rust-analyzer/
253         run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
254
255       - name: Publish Extension (OpenVSX, release)
256         if: github.ref == 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
257         working-directory: ./editors/code
258         # token from https://dev.azure.com/rust-analyzer/
259         run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix || true
260
261       - name: Publish Extension (Code Marketplace, nightly)
262         if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
263         working-directory: ./editors/code
264         run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
265
266       - name: Publish Extension (OpenVSX, nightly)
267         if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
268         working-directory: ./editors/code
269         run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix || true