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: 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/rpc/proto/"
75 against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/rpc/proto/"
76
77 macos_tests:
78 name: (macOS) Run Clippy and tests
79 runs-on:
80 - self-hosted
81 - test
82 steps:
83 - name: Checkout repo
84 uses: actions/checkout@v4
85 with:
86 clean: false
87 submodules: "recursive"
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 # todo(linux): Actually run the tests
102 linux_tests:
103 name: (Linux) Run Clippy and tests
104 runs-on: ubuntu-latest
105 steps:
106 - name: Checkout repo
107 uses: actions/checkout@v4
108 with:
109 clean: false
110 submodules: "recursive"
111
112 - name: Cache dependencies
113 uses: swatinem/rust-cache@v2
114 with:
115 save-if: ${{ github.ref == 'refs/heads/main' }}
116
117 - name: configure linux
118 shell: bash -euxo pipefail {0}
119 run: script/linux
120
121 - name: cargo clippy
122 run: cargo xtask clippy
123
124 - name: Build Zed
125 run: cargo build -p zed
126
127 # todo(windows): Actually run the tests
128 windows_tests:
129 name: (Windows) Run Clippy and tests
130 runs-on: windows-latest
131 steps:
132 - name: Checkout repo
133 uses: actions/checkout@v4
134 with:
135 clean: false
136 submodules: "recursive"
137
138 - name: Cache dependencies
139 uses: swatinem/rust-cache@v2
140 with:
141 save-if: ${{ github.ref == 'refs/heads/main' }}
142
143 - name: cargo clippy
144 run: cargo xtask clippy
145
146 - name: Build Zed
147 run: cargo build -p zed
148
149 bundle-mac:
150 name: Create a macOS bundle
151 runs-on:
152 - self-hosted
153 - bundle
154 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
155 needs: [macos_tests]
156 env:
157 MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
158 MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
159 APPLE_NOTARIZATION_USERNAME: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
160 APPLE_NOTARIZATION_PASSWORD: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
161 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
162 DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
163 DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
164 steps:
165 - name: Install Node
166 uses: actions/setup-node@v4
167 with:
168 node-version: "18"
169
170 - name: Checkout repo
171 uses: actions/checkout@v4
172 with:
173 clean: false
174 submodules: "recursive"
175
176 - name: Limit target directory size
177 run: script/clear-target-dir-if-larger-than 100
178
179 - name: Determine version and release channel
180 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
181 run: |
182 set -eu
183
184 version=$(script/get-crate-version zed)
185 channel=$(cat crates/zed/RELEASE_CHANNEL)
186 echo "Publishing version: ${version} on release channel ${channel}"
187 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
188
189 expected_tag_name=""
190 case ${channel} in
191 stable)
192 expected_tag_name="v${version}";;
193 preview)
194 expected_tag_name="v${version}-pre";;
195 nightly)
196 expected_tag_name="v${version}-nightly";;
197 *)
198 echo "can't publish a release on channel ${channel}"
199 exit 1;;
200 esac
201 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
202 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
203 exit 1
204 fi
205
206 - name: Generate license file
207 run: script/generate-licenses
208
209 - name: Create macOS app bundle
210 run: script/bundle-mac
211
212 - name: Upload app bundle (universal) to workflow run if main branch or specific label
213 uses: actions/upload-artifact@v4
214 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
215 with:
216 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg
217 path: target/release/Zed.dmg
218 - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
219 uses: actions/upload-artifact@v4
220 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
221 with:
222 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}_aarch64.dmg
223 path: target/aarch64-apple-darwin/release/Zed.dmg
224
225 - name: Upload app bundle (x86_64) 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 }}_x86_64.dmg
230 path: target/x86_64-apple-darwin/release/Zed.dmg
231
232 - uses: softprops/action-gh-release@v1
233 name: Upload app bundle to release
234 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
235 with:
236 draft: true
237 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
238 files: |
239 target/aarch64-apple-darwin/release/Zed.dmg
240 target/x86_64-apple-darwin/release/Zed.dmg
241 body: ""
242 env:
243 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244
245 bundle-deb:
246 name: Create a *.deb Linux bundle
247 runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
248 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
249 needs: [linux_tests]
250 env:
251 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
252 DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
253 DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
254 steps:
255 - name: Checkout repo
256 uses: actions/checkout@v4
257 with:
258 clean: false
259 submodules: "recursive"
260
261 - name: Cache dependencies
262 uses: swatinem/rust-cache@v2
263 with:
264 save-if: ${{ github.ref == 'refs/heads/main' }}
265
266 - name: Configure linux
267 shell: bash -euxo pipefail {0}
268 run: script/linux
269
270 - name: Determine version and release channel
271 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
272 run: |
273 set -eu
274
275 version=$(script/get-crate-version zed)
276 channel=$(cat crates/zed/RELEASE_CHANNEL)
277 echo "Publishing version: ${version} on release channel ${channel}"
278 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
279
280 expected_tag_name=""
281 case ${channel} in
282 stable)
283 expected_tag_name="v${version}";;
284 preview)
285 expected_tag_name="v${version}-pre";;
286 nightly)
287 expected_tag_name="v${version}-nightly";;
288 *)
289 echo "can't publish a release on channel ${channel}"
290 exit 1;;
291 esac
292 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
293 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
294 exit 1
295 fi
296
297 # TODO linux : Find a way to add licenses to the final bundle
298 # - name: Generate license file
299 # run: script/generate-licenses
300
301 - name: Create Linux *.deb bundle
302 run: script/bundle-linux
303
304 - name: Upload app bundle to workflow run if main branch or specific label
305 uses: actions/upload-artifact@v4
306 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
307 with:
308 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.deb
309 path: target/release/*.deb
310
311 # TODO linux : make it stable enough to be uploaded as a release
312 # - uses: softprops/action-gh-release@v1
313 # name: Upload app bundle to release
314 # if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
315 # with:
316 # draft: true
317 # prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
318 # files: target/release/Zed.dmg
319 # body: ""
320 # env:
321 # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}