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: ubuntu-latest
108 steps:
109 - name: Checkout repo
110 uses: actions/checkout@v4
111 with:
112 clean: false
113 submodules: "recursive"
114
115 - name: Cache dependencies
116 uses: swatinem/rust-cache@v2
117 with:
118 save-if: ${{ github.ref == 'refs/heads/main' }}
119
120 - name: configure linux
121 shell: bash -euxo pipefail {0}
122 run: script/linux
123
124 - name: cargo clippy
125 run: cargo xtask clippy
126
127 - name: Build Zed
128 run: cargo build -p zed
129
130 # todo(windows): Actually run the tests
131 windows_tests:
132 name: (Windows) Run Clippy and tests
133 runs-on: windows-latest
134 steps:
135 - name: Checkout repo
136 uses: actions/checkout@v4
137 with:
138 clean: false
139 submodules: "recursive"
140
141 - name: Cache dependencies
142 uses: swatinem/rust-cache@v2
143 with:
144 save-if: ${{ github.ref == 'refs/heads/main' }}
145
146 - name: cargo clippy
147 run: cargo xtask clippy
148
149 - name: Build Zed
150 run: cargo build -p zed
151
152 bundle-mac:
153 name: Create a macOS bundle
154 runs-on:
155 - self-hosted
156 - bundle
157 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
158 needs: [macos_tests]
159 env:
160 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
161 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
162 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
163 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
164 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
165 DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
166 DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
167 steps:
168 - name: Install Node
169 uses: actions/setup-node@v4
170 with:
171 node-version: "18"
172
173 - name: Checkout repo
174 uses: actions/checkout@v4
175 with:
176 # We need to fetch more than one commit so that `script/draft-release-notes`
177 # is able to diff between the current and previous tag.
178 #
179 # 25 was chosen arbitrarily.
180 fetch-depth: 25
181 clean: false
182 submodules: "recursive"
183
184 - name: Limit target directory size
185 run: script/clear-target-dir-if-larger-than 100
186
187 - name: Determine version and release channel
188 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
189 run: |
190 set -eu
191
192 version=$(script/get-crate-version zed)
193 channel=$(cat crates/zed/RELEASE_CHANNEL)
194 echo "Publishing version: ${version} on release channel ${channel}"
195 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
196
197 expected_tag_name=""
198 case ${channel} in
199 stable)
200 expected_tag_name="v${version}";;
201 preview)
202 expected_tag_name="v${version}-pre";;
203 nightly)
204 expected_tag_name="v${version}-nightly";;
205 *)
206 echo "can't publish a release on channel ${channel}"
207 exit 1;;
208 esac
209 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
210 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
211 exit 1
212 fi
213 mkdir -p target/
214 # Ignore any errors that occur while drafting release notes to not fail the build.
215 script/draft-release-notes "$version" "$channel" > target/release-notes.md || true
216
217 - name: Generate license file
218 run: script/generate-licenses
219
220 - name: Create macOS app bundle
221 run: script/bundle-mac
222
223 - name: Rename single-architecture binaries
224 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
225 run: |
226 mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
227 mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
228
229 - name: Upload app bundle (universal) to workflow run if main branch or specific label
230 uses: actions/upload-artifact@v4
231 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
232 with:
233 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
234 path: target/release/Zed.dmg
235 - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
236 uses: actions/upload-artifact@v4
237 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
238 with:
239 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
240 path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
241
242 - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
243 uses: actions/upload-artifact@v4
244 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
245 with:
246 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
247 path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
248
249 - uses: softprops/action-gh-release@v1
250 name: Upload app bundle to release
251 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
252 with:
253 draft: true
254 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
255 files: |
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_file: target/release-notes.md
260 env:
261 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
262
263 bundle-linux:
264 name: Create a Linux bundle
265 runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
266 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
267 needs: [linux_tests]
268 env:
269 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
270 steps:
271 - name: Checkout repo
272 uses: actions/checkout@v4
273 with:
274 clean: false
275 submodules: "recursive"
276
277 - name: Cache dependencies
278 uses: swatinem/rust-cache@v2
279 with:
280 save-if: ${{ github.ref == 'refs/heads/main' }}
281
282 - name: Configure linux
283 shell: bash -euxo pipefail {0}
284 run: script/linux
285
286 - name: Determine version and release channel
287 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
288 run: |
289 set -eu
290
291 version=$(script/get-crate-version zed)
292 channel=$(cat crates/zed/RELEASE_CHANNEL)
293 echo "Publishing version: ${version} on release channel ${channel}"
294 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
295
296 expected_tag_name=""
297 case ${channel} in
298 stable)
299 expected_tag_name="v${version}";;
300 preview)
301 expected_tag_name="v${version}-pre";;
302 nightly)
303 expected_tag_name="v${version}-nightly";;
304 *)
305 echo "can't publish a release on channel ${channel}"
306 exit 1;;
307 esac
308 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
309 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
310 exit 1
311 fi
312
313 - name: Generate license file
314 run: script/generate-licenses
315
316 - name: Create and upload Linux .tar.gz bundle
317 run: script/bundle-linux
318
319 - name: Upload Linux bundle to workflow run if main branch or specific label
320 uses: actions/upload-artifact@v4
321 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
322 with:
323 name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
324 path: zed-*.tar.gz
325
326 - name: Upload app bundle to release
327 uses: softprops/action-gh-release@v1
328 if: ${{ env.RELEASE_CHANNEL == 'preview' }}
329 with:
330 draft: true
331 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
332 files: zed-linux-x86_64.tar.gz
333 body: ""
334 env:
335 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}