1name: CI
2
3on:
4 push:
5 branches:
6 - main
7 - "v[0-9]+.[0-9]+.x"
8 tags:
9 - "v*"
10 pull_request:
11 branches:
12 - "**"
13
14concurrency:
15 # Allow only one workflow per any non-`main` branch.
16 group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
17 cancel-in-progress: true
18
19env:
20 CARGO_TERM_COLOR: always
21 CARGO_INCREMENTAL: 0
22 RUST_BACKTRACE: 1
23
24jobs:
25 style:
26 timeout-minutes: 60
27 name: Check formatting and spelling
28 runs-on:
29 - self-hosted
30 - test
31 steps:
32 - name: Checkout repo
33 uses: actions/checkout@v4
34 with:
35 clean: false
36 fetch-depth: 0
37
38 - name: Remove untracked files
39 run: git clean -df
40
41 - name: Check spelling
42 run: |
43 if ! which typos > /dev/null; then
44 cargo install typos-cli
45 fi
46 typos
47
48 - name: Run style checks
49 uses: ./.github/actions/check_style
50
51 - name: Check unused dependencies
52 uses: bnjbvr/cargo-machete@main
53
54 - name: Check licenses are present
55 run: script/check-licenses
56
57 - name: Check license generation
58 run: script/generate-licenses /tmp/zed_licenses_output
59
60 - name: Ensure fresh merge
61 shell: bash -euxo pipefail {0}
62 run: |
63 if [ -z "$GITHUB_BASE_REF" ];
64 then
65 echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> $GITHUB_ENV
66 else
67 git checkout -B temp
68 git merge -q origin/$GITHUB_BASE_REF -m "merge main into temp"
69 echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> $GITHUB_ENV
70 fi
71
72 - uses: bufbuild/buf-setup-action@v1
73 with:
74 version: v1.29.0
75 - uses: bufbuild/buf-breaking-action@v1
76 with:
77 input: "crates/proto/proto/"
78 against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/proto/proto/"
79
80 macos_tests:
81 timeout-minutes: 60
82 name: (macOS) Run Clippy and tests
83 runs-on:
84 - self-hosted
85 - test
86 steps:
87 - name: Checkout repo
88 uses: actions/checkout@v4
89 with:
90 clean: false
91
92 - name: cargo clippy
93 run: ./script/clippy
94
95 - name: Run tests
96 uses: ./.github/actions/run_tests
97
98 - name: Build collab
99 run: cargo build -p collab
100
101 - name: Build other binaries and features
102 run: cargo build --workspace --bins --all-features; cargo check -p gpui --features "macos-blade"
103
104 linux_tests:
105 timeout-minutes: 60
106 name: (Linux) Run Clippy and tests
107 runs-on:
108 - self-hosted
109 - deploy
110 steps:
111 - name: Add Rust to the PATH
112 run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
113
114 - name: Checkout repo
115 uses: actions/checkout@v4
116 with:
117 clean: false
118
119 - name: cargo clippy
120 run: ./script/clippy
121
122 - name: Run tests
123 uses: ./.github/actions/run_tests
124
125 - name: Build Zed
126 run: cargo build -p zed
127
128 # todo(windows): Actually run the tests
129 windows_tests:
130 timeout-minutes: 60
131 name: (Windows) Run Clippy and tests
132 runs-on: hosted-windows-1
133 steps:
134 - name: Checkout repo
135 uses: actions/checkout@v4
136 with:
137 clean: false
138
139 - name: Cache dependencies
140 uses: swatinem/rust-cache@v2
141 with:
142 save-if: ${{ github.ref == 'refs/heads/main' }}
143
144 - name: cargo clippy
145 run: ./script/clippy
146
147 - name: Build Zed
148 run: cargo build -p zed
149
150 bundle-mac:
151 timeout-minutes: 60
152 name: Create a macOS bundle
153 runs-on:
154 - self-hosted
155 - bundle
156 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
157 needs: [macos_tests]
158 env:
159 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
160 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
161 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
162 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
163 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
164 DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
165 DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
166 steps:
167 - name: Install Node
168 uses: actions/setup-node@v4
169 with:
170 node-version: "18"
171
172 - name: Checkout repo
173 uses: actions/checkout@v4
174 with:
175 # We need to fetch more than one commit so that `script/draft-release-notes`
176 # is able to diff between the current and previous tag.
177 #
178 # 25 was chosen arbitrarily.
179 fetch-depth: 25
180 clean: false
181
182 - name: Limit target directory size
183 run: script/clear-target-dir-if-larger-than 100
184
185 - name: Determine version and release channel
186 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
187 run: |
188 set -eu
189
190 version=$(script/get-crate-version zed)
191 channel=$(cat crates/zed/RELEASE_CHANNEL)
192 echo "Publishing version: ${version} on release channel ${channel}"
193 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
194
195 expected_tag_name=""
196 case ${channel} in
197 stable)
198 expected_tag_name="v${version}";;
199 preview)
200 expected_tag_name="v${version}-pre";;
201 nightly)
202 expected_tag_name="v${version}-nightly";;
203 *)
204 echo "can't publish a release on channel ${channel}"
205 exit 1;;
206 esac
207 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
208 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
209 exit 1
210 fi
211 mkdir -p target/
212 # Ignore any errors that occur while drafting release notes to not fail the build.
213 script/draft-release-notes "$version" "$channel" > target/release-notes.md || true
214
215 - name: Generate license file
216 run: script/generate-licenses
217
218 - name: Create macOS app bundle
219 run: script/bundle-mac
220
221 - name: Rename single-architecture binaries
222 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
223 run: |
224 mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
225 mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
226
227 - name: Upload app bundle (universal) to workflow run if main branch or specific label
228 uses: actions/upload-artifact@v4
229 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
230 with:
231 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
232 path: target/release/Zed.dmg
233 - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
234 uses: actions/upload-artifact@v4
235 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
236 with:
237 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
238 path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
239
240 - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
241 uses: actions/upload-artifact@v4
242 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
243 with:
244 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
245 path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
246
247 - uses: softprops/action-gh-release@v1
248 name: Upload app bundle to release
249 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
250 with:
251 draft: true
252 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
253 files: |
254 target/zed-remote-server-mac-x86_64.gz
255 target/zed-remote-server-mac-aarch64.gz
256 target/aarch64-apple-darwin/release/Zed-aarch64.dmg
257 target/x86_64-apple-darwin/release/Zed-x86_64.dmg
258 target/release/Zed.dmg
259 body_path: target/release-notes.md
260 env:
261 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
262
263 bundle-linux:
264 timeout-minutes: 60
265 name: Create a Linux bundle
266 runs-on:
267 - self-hosted
268 - deploy
269 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
270 needs: [linux_tests]
271 env:
272 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
273 steps:
274 - name: Add Rust to the PATH
275 run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
276
277 - name: Checkout repo
278 uses: actions/checkout@v4
279 with:
280 clean: false
281
282 - name: Limit target directory size
283 run: script/clear-target-dir-if-larger-than 100
284
285 - name: Determine version and release channel
286 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
287 run: |
288 set -eu
289
290 version=$(script/get-crate-version zed)
291 channel=$(cat crates/zed/RELEASE_CHANNEL)
292 echo "Publishing version: ${version} on release channel ${channel}"
293 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
294
295 expected_tag_name=""
296 case ${channel} in
297 stable)
298 expected_tag_name="v${version}";;
299 preview)
300 expected_tag_name="v${version}-pre";;
301 nightly)
302 expected_tag_name="v${version}-nightly";;
303 *)
304 echo "can't publish a release on channel ${channel}"
305 exit 1;;
306 esac
307 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
308 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
309 exit 1
310 fi
311
312 - name: Create Linux .tar.gz bundle
313 run: script/bundle-linux
314
315 - name: Upload Linux bundle to workflow run if main branch or specific label
316 uses: actions/upload-artifact@v4
317 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
318 with:
319 name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
320 path: target/release/zed-*.tar.gz
321
322 - name: Upload app bundle to release
323 uses: softprops/action-gh-release@v1
324 with:
325 draft: true
326 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
327 files: |
328 target/zed-remote-server-linux-x86_64.gz
329 target/release/zed-linux-x86_64.tar.gz
330 body: ""
331 env:
332 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
333
334 bundle-linux-aarch64:
335 timeout-minutes: 60
336 name: Create arm64 Linux bundle
337 runs-on:
338 - hosted-linux-arm-1
339 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
340 needs: [linux_tests]
341 env:
342 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
343 steps:
344 - name: Checkout repo
345 uses: actions/checkout@v4
346 with:
347 clean: false
348 - name: "Setup jq"
349 uses: dcarbone/install-jq-action@v2
350
351 - name: Set up Clang
352 run: |
353 sudo apt-get update
354 sudo apt-get install -y llvm-10 clang-10 build-essential cmake pkg-config libasound2-dev libfontconfig-dev libwayland-dev libxkbcommon-x11-dev libssl-dev libsqlite3-dev libzstd-dev libvulkan1 libgit2-dev
355 echo "/usr/lib/llvm-10/bin" >> $GITHUB_PATH
356
357 - uses: rui314/setup-mold@v1
358 with:
359 mold-version: 2.32.0
360
361 - name: rustup
362 run: |
363 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
364 echo "$HOME/.cargo/bin" >> $GITHUB_PATH
365
366 - name: Limit target directory size
367 run: script/clear-target-dir-if-larger-than 100
368
369 - name: Determine version and release channel
370 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
371 run: |
372 set -eu
373
374 version=$(script/get-crate-version zed)
375 channel=$(cat crates/zed/RELEASE_CHANNEL)
376 echo "Publishing version: ${version} on release channel ${channel}"
377 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
378
379 expected_tag_name=""
380 case ${channel} in
381 stable)
382 expected_tag_name="v${version}";;
383 preview)
384 expected_tag_name="v${version}-pre";;
385 nightly)
386 expected_tag_name="v${version}-nightly";;
387 *)
388 echo "can't publish a release on channel ${channel}"
389 exit 1;;
390 esac
391 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
392 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
393 exit 1
394 fi
395
396 - name: Create and upload Linux .tar.gz bundle
397 run: script/bundle-linux
398
399 - name: Upload Linux bundle to workflow run if main branch or specific label
400 uses: actions/upload-artifact@v4
401 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
402 with:
403 name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
404 path: target/release/zed-*.tar.gz
405
406 - name: Upload app bundle to release
407 uses: softprops/action-gh-release@v1
408 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
409 with:
410 draft: true
411 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
412 files: |
413 target/zed-remote-server-linux-aarch64.gz
414 target/release/zed-linux-aarch64.tar.gz
415 body: ""
416 env:
417 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}