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: Rename single-architecture binaries
213 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
214 run: |
215 mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
216 mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
217
218 - name: Upload app bundle (universal) 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 }}.dmg
223 path: target/release/Zed.dmg
224 - name: Upload app bundle (aarch64) 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 }}-aarch64.dmg
229 path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
230
231 - name: Upload app bundle (x86_64) 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 }}-x86_64.dmg
236 path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
237
238 - uses: softprops/action-gh-release@v1
239 name: Upload app bundle to release
240 if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
241 with:
242 draft: true
243 prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
244 files: |
245 target/aarch64-apple-darwin/release/Zed-aarch64.dmg
246 target/x86_64-apple-darwin/release/Zed-x86_64.dmg
247 target/release/Zed.dmg
248 body: ""
249 env:
250 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
251
252 bundle-deb:
253 name: Create a *.deb Linux bundle
254 runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues
255 if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
256 needs: [linux_tests]
257 env:
258 ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
259 DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
260 DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
261 steps:
262 - name: Checkout repo
263 uses: actions/checkout@v4
264 with:
265 clean: false
266 submodules: "recursive"
267
268 - name: Cache dependencies
269 uses: swatinem/rust-cache@v2
270 with:
271 save-if: ${{ github.ref == 'refs/heads/main' }}
272
273 - name: Configure linux
274 shell: bash -euxo pipefail {0}
275 run: script/linux
276
277 - name: Determine version and release channel
278 if: ${{ startsWith(github.ref, 'refs/tags/v') }}
279 run: |
280 set -eu
281
282 version=$(script/get-crate-version zed)
283 channel=$(cat crates/zed/RELEASE_CHANNEL)
284 echo "Publishing version: ${version} on release channel ${channel}"
285 echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV
286
287 expected_tag_name=""
288 case ${channel} in
289 stable)
290 expected_tag_name="v${version}";;
291 preview)
292 expected_tag_name="v${version}-pre";;
293 nightly)
294 expected_tag_name="v${version}-nightly";;
295 *)
296 echo "can't publish a release on channel ${channel}"
297 exit 1;;
298 esac
299 if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then
300 echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}"
301 exit 1
302 fi
303
304 # TODO linux : Find a way to add licenses to the final bundle
305 # - name: Generate license file
306 # run: script/generate-licenses
307
308 - name: Create Linux *.deb bundle
309 run: script/bundle-linux
310
311 - name: Upload app bundle to workflow run if main branch or specific label
312 uses: actions/upload-artifact@v4
313 if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
314 with:
315 name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.deb
316 path: target/release/*.deb
317
318 # TODO linux : make it stable enough to be uploaded as a release
319 # - uses: softprops/action-gh-release@v1
320 # name: Upload app bundle to release
321 # if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
322 # with:
323 # draft: true
324 # prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
325 # files: target/release/Zed.dmg
326 # body: ""
327 # env:
328 # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}