fork/rust-analyzer

git clone https://git.julia.blue/fork/rust-analyzer

borsAuto merge of #12366 - rust-lang:revert-12349-universal-vsix, r=lnicola81805d4cfc

2022-06-27
8.6 KiB258 linesraw
1name: release
2on:
3  schedule:
4    - cron: "0 0 * * *" # midnight UTC
5
6  workflow_dispatch:
7
8  push:
9    branches:
10      - release
11      - trigger-nightly
12
13env:
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
22jobs:
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-18.04
34            target: x86_64-unknown-linux-gnu
35            code-target: linux-x64
36          - os: ubuntu-18.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@v3
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      - name: Package Extension (release)
104        if: github.ref == 'refs/heads/release'
105        run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}
106        working-directory: editors/code
107
108      - name: Package Extension (nightly)
109        if: github.ref != 'refs/heads/release'
110        run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }} --pre-release
111        working-directory: editors/code
112
113      - if: matrix.target == 'x86_64-unknown-linux-gnu'
114        run: rm -rf editors/code/server
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
118        working-directory: editors/code
119
120      - if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref != 'refs/heads/release'
121        run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix --pre-release
122        working-directory: editors/code
123
124      - name: Run analysis-stats on rust-analyzer
125        if: matrix.target == 'x86_64-unknown-linux-gnu'
126        run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats .
127
128      - name: Run analysis-stats on rust std library
129        if: matrix.target == 'x86_64-unknown-linux-gnu'
130        run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
131
132      - name: Upload artifacts
133        uses: actions/upload-artifact@v1
134        with:
135          name: dist-${{ matrix.target }}
136          path: ./dist
137
138  dist-x86_64-unknown-linux-musl:
139    name: dist (x86_64-unknown-linux-musl)
140    runs-on: ubuntu-latest
141    env:
142      RA_TARGET: x86_64-unknown-linux-musl
143      # For some reason `-crt-static` is not working for clang without lld
144      RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
145    container:
146      image: rust:alpine
147      volumes:
148        - /usr/local/cargo/registry
149
150    steps:
151      - name: Install dependencies
152        run: apk add --no-cache git clang lld musl-dev nodejs npm
153
154      - name: Checkout repository
155        uses: actions/checkout@v3
156        with:
157          fetch-depth: ${{ env.FETCH_DEPTH }}
158
159      - name: Dist
160        run: cargo xtask dist --client-patch-version ${{ github.run_number }}
161
162      - run: npm ci
163        working-directory: editors/code
164
165      - name: Package Extension (release)
166        if: github.ref == 'refs/heads/release'
167        run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64
168        working-directory: editors/code
169
170      - name: Package Extension (nightly)
171        if: github.ref != 'refs/heads/release'
172        run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64 --pre-release
173        working-directory: editors/code
174
175      - run: rm -rf editors/code/server
176
177      - name: Upload artifacts
178        uses: actions/upload-artifact@v1
179        with:
180          name: dist-x86_64-unknown-linux-musl
181          path: ./dist
182
183  publish:
184    name: publish
185    runs-on: ubuntu-latest
186    needs: ["dist", "dist-x86_64-unknown-linux-musl"]
187    steps:
188      - name: Install Nodejs
189        uses: actions/setup-node@v1
190        with:
191          node-version: 14.x
192
193      - run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
194        if: github.ref == 'refs/heads/release'
195      - run: echo "TAG=nightly" >> $GITHUB_ENV
196        if: github.ref != 'refs/heads/release'
197      - run: 'echo "TAG: $TAG"'
198
199      - name: Checkout repository
200        uses: actions/checkout@v3
201        with:
202          fetch-depth: ${{ env.FETCH_DEPTH }}
203
204      - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
205      - run: 'echo "HEAD_SHA: $HEAD_SHA"'
206
207      - uses: actions/download-artifact@v1
208        with:
209          name: dist-aarch64-apple-darwin
210          path: dist
211      - uses: actions/download-artifact@v1
212        with:
213          name: dist-x86_64-apple-darwin
214          path: dist
215      - uses: actions/download-artifact@v1
216        with:
217          name: dist-x86_64-unknown-linux-gnu
218          path: dist
219      - uses: actions/download-artifact@v1
220        with:
221          name: dist-x86_64-unknown-linux-musl
222          path: dist
223      - uses: actions/download-artifact@v1
224        with:
225          name: dist-aarch64-unknown-linux-gnu
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 (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 (nightly)
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        run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release