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