4 - cron: "0 0 * * *" # midnight UTC
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
28 target: x86_64-pc-windows-msvc
29 code-target: win32-x64
31 target: aarch64-pc-windows-msvc
32 code-target: win32-arm64
34 target: x86_64-unknown-linux-gnu
35 code-target: linux-x64
37 target: aarch64-unknown-linux-gnu
38 code-target: linux-arm64
40 target: x86_64-apple-darwin
41 code-target: darwin-x64
43 target: aarch64-apple-darwin
44 code-target: darwin-arm64
46 name: dist (${{ matrix.target }})
47 runs-on: ${{ matrix.os }}
50 RA_TARGET: ${{ matrix.target }}
53 - name: Checkout repository
54 uses: actions/checkout@v3
56 fetch-depth: ${{ env.FETCH_DEPTH }}
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
66 - name: Install Rust toolchain
67 uses: actions-rs/toolchain@v1
70 target: ${{ matrix.target }}
74 - name: Install Rust library source
75 if: matrix.target == 'x86_64-unknown-linux-gnu'
76 uses: actions-rs/toolchain@v1
79 target: ${{ matrix.target }}
84 - name: Install Node.js
85 uses: actions/setup-node@v1
89 - name: Update apt repositories
90 if: matrix.target == 'aarch64-unknown-linux-gnu'
91 run: sudo apt-get update
93 - name: Install target toolchain
94 if: matrix.target == 'aarch64-unknown-linux-gnu'
95 run: sudo apt-get install gcc-aarch64-linux-gnu
98 run: cargo xtask dist --client-patch-version ${{ github.run_number }}
101 working-directory: editors/code
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
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
113 - if: matrix.target == 'x86_64-unknown-linux-gnu'
114 run: rm -rf editors/code/server
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
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
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 .
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
132 - name: Upload artifacts
133 uses: actions/upload-artifact@v1
135 name: dist-${{ matrix.target }}
138 dist-x86_64-unknown-linux-musl:
139 name: dist (x86_64-unknown-linux-musl)
140 runs-on: ubuntu-latest
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"
148 - /usr/local/cargo/registry
151 - name: Install dependencies
152 run: apk add --no-cache git clang lld musl-dev nodejs npm
154 - name: Checkout repository
155 uses: actions/checkout@v3
157 fetch-depth: ${{ env.FETCH_DEPTH }}
160 run: cargo xtask dist --client-patch-version ${{ github.run_number }}
163 working-directory: editors/code
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
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
175 - run: rm -rf editors/code/server
177 - name: Upload artifacts
178 uses: actions/upload-artifact@v1
180 name: dist-x86_64-unknown-linux-musl
185 runs-on: ubuntu-latest
186 needs: ["dist", "dist-x86_64-unknown-linux-musl"]
188 - name: Install Nodejs
189 uses: actions/setup-node@v1
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"'
199 - name: Checkout repository
200 uses: actions/checkout@v3
202 fetch-depth: ${{ env.FETCH_DEPTH }}
204 - run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
205 - run: 'echo "HEAD_SHA: $HEAD_SHA"'
207 - uses: actions/download-artifact@v1
209 name: dist-aarch64-apple-darwin
211 - uses: actions/download-artifact@v1
213 name: dist-x86_64-apple-darwin
215 - uses: actions/download-artifact@v1
217 name: dist-x86_64-unknown-linux-gnu
219 - uses: actions/download-artifact@v1
221 name: dist-x86_64-unknown-linux-musl
223 - uses: actions/download-artifact@v1
225 name: dist-aarch64-unknown-linux-gnu
227 - uses: actions/download-artifact@v1
229 name: dist-x86_64-pc-windows-msvc
231 - uses: actions/download-artifact@v1
233 name: dist-aarch64-pc-windows-msvc
237 - name: Publish Release
238 uses: ./.github/actions/github-release
242 token: ${{ secrets.GITHUB_TOKEN }}
244 - run: rm dist/rust-analyzer-no-server.vsix
247 working-directory: ./editors/code
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
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
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 --pre-release
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 --pre-release