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