fork/rust-analyzer

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

borsAuto merge of #12776 - matklad:nosu, r=matkladf2c2c36efe

2022-07-18
8.5 KiB249 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      - name: Install Rust toolchain
59        run: |
60          rustup update --no-self-update stable
61          rustup target add ${{ matrix.target }}
62          rustup component add rust-src
63
64      - name: Install Node.js
65        uses: actions/setup-node@v1
66        with:
67          node-version: 14.x
68
69      - name: Update apt repositories
70        if: matrix.target == 'aarch64-unknown-linux-gnu'
71        run: sudo apt-get update
72
73      - name: Install target toolchain
74        if: matrix.target == 'aarch64-unknown-linux-gnu'
75        run: sudo apt-get install gcc-aarch64-linux-gnu
76
77      - name: Dist
78        run: cargo xtask dist --client-patch-version ${{ github.run_number }}
79
80      - run: npm ci
81        working-directory: editors/code
82
83      - name: Package Extension (release)
84        if: github.ref == 'refs/heads/release'
85        run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}
86        working-directory: editors/code
87
88      - name: Package Extension (nightly)
89        if: github.ref != 'refs/heads/release'
90        run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }} --pre-release
91        working-directory: editors/code
92
93      - if: matrix.target == 'x86_64-unknown-linux-gnu'
94        run: rm -rf editors/code/server
95
96      - if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref == 'refs/heads/release'
97        run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix
98        working-directory: editors/code
99
100      - if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref != 'refs/heads/release'
101        run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix --pre-release
102        working-directory: editors/code
103
104      - name: Run analysis-stats on rust-analyzer
105        if: matrix.target == 'x86_64-unknown-linux-gnu'
106        run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats .
107
108      - name: Run analysis-stats on rust std library
109        if: matrix.target == 'x86_64-unknown-linux-gnu'
110        run: target/${{ matrix.target }}/release/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std
111
112      - name: Upload artifacts
113        uses: actions/upload-artifact@v1
114        with:
115          name: dist-${{ matrix.target }}
116          path: ./dist
117
118  dist-x86_64-unknown-linux-musl:
119    name: dist (x86_64-unknown-linux-musl)
120    runs-on: ubuntu-latest
121    env:
122      RA_TARGET: x86_64-unknown-linux-musl
123      # For some reason `-crt-static` is not working for clang without lld
124      RUSTFLAGS: "-C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
125    container:
126      image: rust:alpine
127      volumes:
128        - /usr/local/cargo/registry
129
130    steps:
131      - name: Install dependencies
132        run: apk add --no-cache git clang lld musl-dev nodejs npm
133
134      - name: Checkout repository
135        uses: actions/checkout@v3
136        with:
137          fetch-depth: ${{ env.FETCH_DEPTH }}
138
139      - name: Dist
140        run: cargo xtask dist --client-patch-version ${{ github.run_number }}
141
142      - run: npm ci
143        working-directory: editors/code
144
145      - name: Package Extension (release)
146        if: github.ref == 'refs/heads/release'
147        run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64
148        working-directory: editors/code
149
150      - name: Package Extension (nightly)
151        if: github.ref != 'refs/heads/release'
152        run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64 --pre-release
153        working-directory: editors/code
154
155      - run: rm -rf editors/code/server
156
157      - name: Upload artifacts
158        uses: actions/upload-artifact@v1
159        with:
160          name: dist-x86_64-unknown-linux-musl
161          path: ./dist
162
163  publish:
164    name: publish
165    runs-on: ubuntu-latest
166    needs: ["dist", "dist-x86_64-unknown-linux-musl"]
167    steps:
168      - name: Install Nodejs
169        uses: actions/setup-node@v1
170        with:
171          node-version: 14.x
172
173      - run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
174        if: github.ref == 'refs/heads/release'
175      - run: echo "TAG=nightly" >> $GITHUB_ENV
176        if: github.ref != 'refs/heads/release'
177      - run: 'echo "TAG: $TAG"'
178
179      - name: Checkout repository
180        uses: actions/checkout@v3
181        with:
182          fetch-depth: ${{ env.FETCH_DEPTH }}
183
184      - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
185      - run: 'echo "HEAD_SHA: $HEAD_SHA"'
186
187      - uses: actions/download-artifact@v1
188        with:
189          name: dist-aarch64-apple-darwin
190          path: dist
191      - uses: actions/download-artifact@v1
192        with:
193          name: dist-x86_64-apple-darwin
194          path: dist
195      - uses: actions/download-artifact@v1
196        with:
197          name: dist-x86_64-unknown-linux-gnu
198          path: dist
199      - uses: actions/download-artifact@v1
200        with:
201          name: dist-x86_64-unknown-linux-musl
202          path: dist
203      - uses: actions/download-artifact@v1
204        with:
205          name: dist-aarch64-unknown-linux-gnu
206          path: dist
207      - uses: actions/download-artifact@v1
208        with:
209          name: dist-x86_64-pc-windows-msvc
210          path: dist
211      - uses: actions/download-artifact@v1
212        with:
213          name: dist-aarch64-pc-windows-msvc
214          path: dist
215      - run: ls -al ./dist
216
217      - name: Publish Release
218        uses: ./.github/actions/github-release
219        with:
220          files: "dist/*"
221          name: ${{ env.TAG }}
222          token: ${{ secrets.GITHUB_TOKEN }}
223
224      - run: rm dist/rust-analyzer-no-server.vsix
225
226      - run: npm ci
227        working-directory: ./editors/code
228
229      - name: Publish Extension (Code Marketplace, release)
230        if: github.ref == 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
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
234
235      - name: Publish Extension (OpenVSX, release)
236        if: github.ref == 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
237        working-directory: ./editors/code
238        # token from https://dev.azure.com/rust-analyzer/
239        run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
240
241      - name: Publish Extension (Code Marketplace, nightly)
242        if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
243        working-directory: ./editors/code
244        run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release
245
246      - name: Publish Extension (OpenVSX, nightly)
247        if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
248        working-directory: ./editors/code
249        run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release