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 name: Check formatting and spelling
27 runs-on:
28 - self-hosted
29 - test
30 steps:
31 - name: Checkout repo
32 uses: actions/checkout@v4
33 with:
34 clean: false
35 submodules: "recursive"
36 fetch-depth: 0
37
38 - name: Remove untracked files
39 run: git clean -df
40
41 - name: Set up default .cargo/config.toml
42 run: cp ./.cargo/ci-config.toml ~/.cargo/config.toml
43
44 - name: Check spelling
45 run: |
46 if ! which typos > /dev/null; then
47 cargo install typos-cli
48 fi
49 typos
50
51 - name: Run style checks
52 uses: ./.github/actions/check_style
53
54 - name: Check unused dependencies
55 uses: bnjbvr/cargo-machete@main
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/rpc/proto/"
78 against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/rpc/proto/"
79
80 macos_tests:
81 name: (macOS) Run Clippy and tests
82 runs-on:
83 - self-hosted
84 - test
85 steps:
86 - name: Checkout repo
87 uses: actions/checkout@v4
88 with:
89 clean: false
90 submodules: "recursive"
91
92 - name: cargo clippy
93 run: cargo xtask 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 # todo(linux): Actually run the tests
105 linux_tests:
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 submodules: "recursive"
119
120 - name: cargo clippy
121 run: cargo xtask clippy
122
123 - name: Build Zed
124 run: cargo build -p zed
125
126 # todo(windows): Actually run the tests
127 windows_tests:
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 submodules: "recursive"
136
137 - name: Cache dependencies
138 uses: swatinem/rust-cache@v2
139 with:
140 save-if: ${{ github.ref == 'refs/heads/main' }}
141
142 - name: cargo clippy
143 run: cargo xtask clippy
144
145 - name: Build Zed
146 run: cargo build -p zed
147
148 bundle-mac:
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 submodules: "recursive"
179
180 - name: Limit target directory size
181 run: script/clear-target-dir-if-larger-than 100
182
183 - name: Determine version and release channel
184 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
185 run: |
186 set -eu
187
188 version=$(script/get-crate-version zed)
189 channel=$(cat crates/zed/RELEASE_CHANNEL)
190 echo "Publishing version: ${version} on release channel ${channel}"
191 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
192
193 expected_tag_name=""
194 case ${channel} in
195 stable)
196 expected_tag_name="v${version}";;
197 preview)
198 expected_tag_name="v${version}-pre";;
199 nightly)
200 expected_tag_name="v${version}-nightly";;
201 *)
202 echo "can't publish a release on channel ${channel}"
203 exit 1;;
204 esac
205 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
206 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
207 exit 1
208 fi
209 mkdir -p target/
210 # Ignore any errors that occur while drafting release notes to not fail the build.
211 script/draft-release-notes "$version" "$channel" > target/release-notes.md || true
212
213 - name: Generate license file
214 run: script/generate-licenses
215
216 - name: Create macOS app bundle
217 run: script/bundle-mac
218
219 - name: Rename single-architecture binaries
220 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
221 run: |
222 mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
223 mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
224
225 - name: Upload app bundle (universal) to workflow run if main branch or specific label
226 uses: actions/upload-artifact@v4
227 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
228 with:
229 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
230 path: target/release/Zed.dmg
231 - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
232 uses: actions/upload-artifact@v4
233 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
234 with:
235 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
236 path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
237
238 - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
239 uses: actions/upload-artifact@v4
240 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
241 with:
242 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
243 path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
244
245 - uses: softprops/action-gh-release@v1
246 name: Upload app bundle to release
247 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
248 with:
249 draft: true
250 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
251 files: |
252 target/aarch64-apple-darwin/release/Zed-aarch64.dmg
253 target/x86_64-apple-darwin/release/Zed-x86_64.dmg
254 target/release/Zed.dmg
255 body_file: target/release-notes.md
256 env:
257 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
258
259 bundle-linux:
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 submodules: "recursive"
277
278 - name: Limit target directory size
279 run: script/clear-target-dir-if-larger-than 100
280
281 - name: Determine version and release channel
282 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
283 run: |
284 set -eu
285
286 version=$(script/get-crate-version zed)
287 channel=$(cat crates/zed/RELEASE_CHANNEL)
288 echo "Publishing version: ${version} on release channel ${channel}"
289 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
290
291 expected_tag_name=""
292 case ${channel} in
293 stable)
294 expected_tag_name="v${version}";;
295 preview)
296 expected_tag_name="v${version}-pre";;
297 nightly)
298 expected_tag_name="v${version}-nightly";;
299 *)
300 echo "can't publish a release on channel ${channel}"
301 exit 1;;
302 esac
303 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
304 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
305 exit 1
306 fi
307
308 - name: Generate license file
309 run: script/generate-licenses
310
311 - name: Create and upload Linux .tar.gz bundle
312 run: script/bundle-linux
313
314 - name: Upload Linux bundle to workflow run if main branch or specific label
315 uses: actions/upload-artifact@v4
316 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
317 with:
318 name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
319 path: zed-*.tar.gz
320
321 - name: Upload app bundle to release
322 uses: softprops/action-gh-release@v1
323 if: ${{ env.RELEASE_CHANNEL == 'preview' }}
324 with:
325 draft: true
326 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
327 files: target/release/zed-linux-x86_64.tar.gz
328 body: ""
329 env:
330 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}