]> git.lizzy.rs Git - rust.git/blob - .github/workflows/release.yaml
Publish platform-specific Code VSIXes
[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
22 jobs:
23   dist:
24     strategy:
25       matrix:
26         include:
27           - os: windows-latest
28             target: x86_64-pc-windows-msvc
29             code-target: win32-x64
30           - os: windows-latest
31             target: aarch64-pc-windows-msvc
32             code-target: win32-arm64
33           - os: ubuntu-20.04
34             target: x86_64-unknown-linux-gnu
35             code-target: linux-x64
36           - os: ubuntu-20.04
37             target: aarch64-unknown-linux-gnu
38             code-target: linux-arm64
39           - os: macos-11
40             target: x86_64-apple-darwin
41             code-target: darwin-x64
42           - os: macos-11
43             target: aarch64-apple-darwin
44             code-target: darwin-arm64
45
46     name: dist (${{ matrix.target }})
47     runs-on: ${{ matrix.os }}
48
49     env:
50       RA_TARGET: ${{ matrix.target }}
51
52     steps:
53       - name: Checkout repository
54         uses: actions/checkout@v2
55         with:
56           fetch-depth: ${{ env.FETCH_DEPTH }}
57
58       # We need to disable the existing toolchain to avoid updating rust-docs
59       # which takes a long time. The fastest way to do this is to rename the
60       # existing folder, as deleting it takes about as much time as not doing
61       # anything and just updating rust-docs.
62       - name: Rename existing Rust toolchain
63         if: matrix.os == 'windows-latest'
64         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
65
66       - name: Install Rust toolchain
67         uses: actions-rs/toolchain@v1
68         with:
69           toolchain: stable
70           target: ${{ matrix.target }}
71           profile: minimal
72           override: true
73
74       - name: Install Rust library source
75         if: matrix.target == 'x86_64-unknown-linux-gnu'
76         uses: actions-rs/toolchain@v1
77         with:
78           toolchain: stable
79           target: ${{ matrix.target }}
80           profile: minimal
81           override: true
82           components: rust-src
83
84       - name: Install Node.js
85         uses: actions/setup-node@v1
86         with:
87           node-version: 14.x
88
89       - name: Update apt repositories
90         if: matrix.target == 'aarch64-unknown-linux-gnu'
91         run: sudo apt-get update
92
93       - name: Install target toolchain
94         if: matrix.target == 'aarch64-unknown-linux-gnu'
95         run: sudo apt-get install gcc-aarch64-linux-gnu
96
97       - name: Dist
98         run: cargo xtask dist --client-patch-version ${{ github.run_number }}
99
100       - run: npm ci
101         working-directory: editors/code
102
103       - run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}
104         working-directory: editors/code
105
106       - if: matrix.target == 'x86_64-unknown-linux-gnu'
107         run: rm -rf editors/code/server
108
109       - if: matrix.target == 'x86_64-unknown-linux-gnu'
110         run: npx vsce package -o ../../dist/rust-analyzer.vsix
111         working-directory: editors/code
112
113       - name: Run analysis-stats on rust-analyzer
114         if: matrix.target == 'x86_64-unknown-linux-gnu'
115         run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats .
116
117       - name: Run analysis-stats on rust std library
118         if: matrix.target == 'x86_64-unknown-linux-gnu'
119         run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
120
121       - name: Upload artifacts
122         uses: actions/upload-artifact@v1
123         with:
124           name: dist-${{ matrix.target }}
125           path: ./dist
126
127   dist-x86_64-unknown-linux-musl:
128     name: dist (x86_64-unknown-linux-musl)
129     runs-on: ubuntu-latest
130     env:
131       RA_TARGET: x86_64-unknown-linux-musl
132       # For some reason `-crt-static` is not working for clang without lld
133       RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
134     container:
135       image: rust:alpine
136       volumes:
137         - /usr/local/cargo/registry
138
139     steps:
140       - name: Install dependencies
141         run: apk add --no-cache git clang lld musl-dev nodejs npm
142
143       - name: Checkout repository
144         uses: actions/checkout@v2
145         with:
146           fetch-depth: ${{ env.FETCH_DEPTH }}
147
148       - name: Dist
149         run: cargo xtask dist --client-patch-version ${{ github.run_number }}
150
151       - run: npm ci
152         working-directory: editors/code
153
154       - run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64
155         working-directory: editors/code
156
157       - run: rm -rf editors/code/server
158
159       - name: Upload artifacts
160         uses: actions/upload-artifact@v1
161         with:
162           name: dist-x86_64-unknown-linux-musl
163           path: ./dist
164
165   publish:
166     name: publish
167     runs-on: ubuntu-latest
168     needs: ["dist", "dist-x86_64-unknown-linux-musl"]
169     steps:
170       - name: Install Nodejs
171         uses: actions/setup-node@v1
172         with:
173           node-version: 14.x
174
175       - run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
176         if: github.ref == 'refs/heads/release'
177       - run: echo "TAG=nightly" >> $GITHUB_ENV
178         if: github.ref != 'refs/heads/release'
179       - run: 'echo "TAG: $TAG"'
180
181       - name: Checkout repository
182         uses: actions/checkout@v2
183         with:
184           fetch-depth: ${{ env.FETCH_DEPTH }}
185
186       - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
187       - run: 'echo "HEAD_SHA: $HEAD_SHA"'
188
189       - uses: actions/download-artifact@v1
190         with:
191           name: dist-aarch64-apple-darwin
192           path: dist
193       - uses: actions/download-artifact@v1
194         with:
195           name: dist-x86_64-apple-darwin
196           path: dist
197       - uses: actions/download-artifact@v1
198         with:
199           name: dist-x86_64-unknown-linux-gnu
200           path: dist
201       - uses: actions/download-artifact@v1
202         with:
203           name: dist-x86_64-unknown-linux-musl
204           path: dist
205       - uses: actions/download-artifact@v1
206         with:
207           name: dist-aarch64-unknown-linux-gnu
208           path: dist
209       - uses: actions/download-artifact@v1
210         with:
211           name: dist-x86_64-pc-windows-msvc
212           path: dist
213       - uses: actions/download-artifact@v1
214         with:
215           name: dist-aarch64-pc-windows-msvc
216           path: dist
217       - run: ls -al ./dist
218
219       - name: Publish Release
220         uses: ./.github/actions/github-release
221         with:
222           files: "dist/*"
223           name: ${{ env.TAG }}
224           token: ${{ secrets.GITHUB_TOKEN }}
225
226       - run: npm ci
227         working-directory: ./editors/code
228
229       - name: Publish Extension
230         if: github.ref == 'refs/heads/release'
231         working-directory: ./editors/code
232         # token from https://dev.azure.com/rust-analyzer/
233         run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix