ci.yml

  1name: CI
  2
  3on:
  4  push:
  5    branches:
  6      - main
  7      - "v[0-9]+.[0-9]+.x"
  8    tags:
  9      - "v*"
 10
 11  pull_request:
 12    branches:
 13      - "**"
 14
 15concurrency:
 16  # Allow only one workflow per any non-`main` branch.
 17  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
 18  cancel-in-progress: true
 19
 20env:
 21  CARGO_TERM_COLOR: always
 22  CARGO_INCREMENTAL: 0
 23  RUST_BACKTRACE: 1
 24
 25jobs:
 26  job_spec:
 27    name: Decide which jobs to run
 28    if: github.repository_owner == 'zed-industries'
 29    outputs:
 30      run_tests: ${{ steps.filter.outputs.run_tests }}
 31      run_license: ${{ steps.filter.outputs.run_license }}
 32    runs-on:
 33      - ubuntu-latest
 34    steps:
 35      - name: Checkout repo
 36        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
 37        with:
 38          # 350 is arbitrary; ~10days of history on main (5secs); full history is ~25secs
 39          fetch-depth: ${{ github.ref == 'refs/heads/main' && 2 || 350 }}
 40      - name: Fetch git history and generate output filters
 41        id: filter
 42        run: |
 43          if [ -z "$GITHUB_BASE_REF" ]; then
 44            echo "Not in a PR context (i.e., push to main/stable/preview)"
 45            COMPARE_REV=$(git rev-parse HEAD~1)
 46          else
 47            echo "In a PR context comparing to pull_request.base.ref"
 48            git fetch origin "$GITHUB_BASE_REF" --depth=350
 49            COMPARE_REV=$(git merge-base "origin/${GITHUB_BASE_REF}" HEAD)
 50          fi
 51          # Specify anything which should skip full CI in this regex:
 52          # - docs/
 53          # - .github/ISSUE_TEMPLATE/
 54          # - .github/workflows/  (except .github/workflows/ci.yml)
 55          SKIP_REGEX='^(docs/|\.github/(ISSUE_TEMPLATE|workflows/(?!ci)))'
 56          if [[ $(git diff --name-only $COMPARE_REV ${{ github.sha }} | grep -vP "$SKIP_REGEX") ]]; then
 57            echo "run_tests=true" >> $GITHUB_OUTPUT
 58          else
 59            echo "run_tests=false" >> $GITHUB_OUTPUT
 60          fi
 61          if [[ $(git diff --name-only $COMPARE_REV ${{ github.sha }} | grep '^Cargo.lock') ]]; then
 62            echo "run_license=true" >> $GITHUB_OUTPUT
 63          else
 64            echo "run_license=false" >> $GITHUB_OUTPUT
 65          fi
 66
 67  migration_checks:
 68    name: Check Postgres and Protobuf migrations, mergability
 69    needs: [job_spec]
 70    if: |
 71      github.repository_owner == 'zed-industries' &&
 72      needs.job_spec.outputs.run_tests == 'true'
 73    timeout-minutes: 60
 74    runs-on:
 75      - self-hosted
 76      - test
 77    steps:
 78      - name: Checkout repo
 79        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
 80        with:
 81          clean: false
 82          fetch-depth: 0 # fetch full history
 83
 84      - name: Remove untracked files
 85        run: git clean -df
 86
 87      - name: Find modified migrations
 88        shell: bash -euxo pipefail {0}
 89        run: |
 90          export SQUAWK_GITHUB_TOKEN=${{ github.token }}
 91          . ./script/squawk
 92
 93      - name: Ensure fresh merge
 94        shell: bash -euxo pipefail {0}
 95        run: |
 96          if [ -z "$GITHUB_BASE_REF" ];
 97          then
 98            echo "BUF_BASE_BRANCH=$(git merge-base origin/main HEAD)" >> $GITHUB_ENV
 99          else
100            git checkout -B temp
101            git merge -q origin/$GITHUB_BASE_REF -m "merge main into temp"
102            echo "BUF_BASE_BRANCH=$GITHUB_BASE_REF" >> $GITHUB_ENV
103          fi
104
105      - uses: bufbuild/buf-setup-action@v1
106        with:
107          version: v1.29.0
108      - uses: bufbuild/buf-breaking-action@v1
109        with:
110          input: "crates/proto/proto/"
111          against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=${BUF_BASE_BRANCH},subdir=crates/proto/proto/"
112
113  workspace_hack:
114    timeout-minutes: 60
115    name: Check workspace-hack crate
116    needs: [job_spec]
117    if: |
118      github.repository_owner == 'zed-industries' &&
119      needs.job_spec.outputs.run_tests == 'true'
120    runs-on:
121      - buildjet-8vcpu-ubuntu-2204
122    steps:
123      - name: Checkout repo
124        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
125      - name: Add Rust to the PATH
126        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
127      - name: Install cargo-hakari
128        uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2
129        with:
130          command: install
131          args: cargo-hakari@0.9.35
132
133      - name: Check workspace-hack Cargo.toml is up-to-date
134        run: |
135          cargo hakari generate --diff || {
136            echo "To fix, run script/update-workspace-hack or script/update-workspace-hack.ps1";
137            false
138          }
139      - name: Check all crates depend on workspace-hack
140        run: |
141          cargo hakari manage-deps --dry-run || {
142            echo "To fix, run script/update-workspace-hack or script/update-workspace-hack.ps1"
143            false
144          }
145
146  style:
147    timeout-minutes: 60
148    name: Check formatting and spelling
149    needs: [job_spec]
150    if: github.repository_owner == 'zed-industries'
151    runs-on:
152      - buildjet-8vcpu-ubuntu-2204
153    steps:
154      - name: Checkout repo
155        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
156
157      - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
158        with:
159          version: 9
160
161      - name: Prettier Check on /docs
162        working-directory: ./docs
163        run: |
164          pnpm dlx prettier@${PRETTIER_VERSION} . --check || {
165            echo "To fix, run from the root of the zed repo:"
166            echo "  cd docs && pnpm dlx prettier@${PRETTIER_VERSION} . --write && cd .."
167            false
168          }
169        env:
170          PRETTIER_VERSION: 3.5.0
171
172      # To support writing comments that they will certainly be revisited.
173      - name: Check for todo! and FIXME comments
174        run: script/check-todos
175
176      - name: Run style checks
177        uses: ./.github/actions/check_style
178
179      - name: Check for typos
180        uses: crate-ci/typos@8e6a4285bcbde632c5d79900a7779746e8b7ea3f # v1.24.6
181        with:
182          config: ./typos.toml
183
184  macos_tests:
185    timeout-minutes: 60
186    name: (macOS) Run Clippy and tests
187    needs: [job_spec]
188    if: |
189      github.repository_owner == 'zed-industries' &&
190      needs.job_spec.outputs.run_tests == 'true'
191    runs-on:
192      - self-hosted
193      - test
194    steps:
195      - name: Checkout repo
196        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
197        with:
198          clean: false
199
200      - name: Configure CI
201        run: |
202          mkdir -p ./../.cargo
203          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
204
205      - name: cargo clippy
206        run: ./script/clippy
207
208      - name: Install cargo-machete
209        uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2
210        with:
211          command: install
212          args: cargo-machete@0.7.0
213
214      - name: Check unused dependencies
215        uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2
216        with:
217          command: machete
218
219      - name: Check licenses
220        run: |
221          script/check-licenses
222          if [[ "${{ needs.job_spec.outputs.run_license }}" == "true" ]]; then
223            script/generate-licenses /tmp/zed_licenses_output
224          fi
225
226      - name: Check for new vulnerable dependencies
227        if: github.event_name == 'pull_request'
228        uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4
229        with:
230          license-check: false
231
232      - name: Run tests
233        uses: ./.github/actions/run_tests
234
235      - name: Build collab
236        run: cargo build -p collab
237
238      - name: Build other binaries and features
239        run: |
240          cargo build --workspace --bins --all-features
241          cargo check -p gpui --features "macos-blade"
242          cargo check -p workspace
243          cargo build -p remote_server
244          cargo check -p gpui --examples
245
246      # Since the macOS runners are stateful, so we need to remove the config file to prevent potential bug.
247      - name: Clean CI config file
248        if: always()
249        run: rm -rf ./../.cargo
250
251  linux_tests:
252    timeout-minutes: 60
253    name: (Linux) Run Clippy and tests
254    needs: [job_spec]
255    if: |
256      github.repository_owner == 'zed-industries' &&
257      needs.job_spec.outputs.run_tests == 'true'
258    runs-on:
259      - buildjet-16vcpu-ubuntu-2204
260    steps:
261      - name: Add Rust to the PATH
262        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
263
264      - name: Checkout repo
265        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
266        with:
267          clean: false
268
269      - name: Cache dependencies
270        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
271        with:
272          save-if: ${{ github.ref == 'refs/heads/main' }}
273          cache-provider: "buildjet"
274
275      - name: Install Linux dependencies
276        run: ./script/linux
277
278      - name: Configure CI
279        run: |
280          mkdir -p ./../.cargo
281          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
282
283      - name: cargo clippy
284        run: ./script/clippy
285
286      - name: Run tests
287        uses: ./.github/actions/run_tests
288
289      - name: Build other binaries and features
290        run: |
291          cargo build -p zed
292          cargo check -p workspace
293          cargo check -p gpui --examples
294
295      # Even the Linux runner is not stateful, in theory there is no need to do this cleanup.
296      # But, to avoid potential issues in the future if we choose to use a stateful Linux runner and forget to add code
297      # to clean up the config file, I’ve included the cleanup code here as a precaution.
298      # While it’s not strictly necessary at this moment, I believe it’s better to err on the side of caution.
299      - name: Clean CI config file
300        if: always()
301        run: rm -rf ./../.cargo
302
303  build_remote_server:
304    timeout-minutes: 60
305    name: (Linux) Build Remote Server
306    needs: [job_spec]
307    if: |
308      github.repository_owner == 'zed-industries' &&
309      needs.job_spec.outputs.run_tests == 'true'
310    runs-on:
311      - buildjet-8vcpu-ubuntu-2204
312    steps:
313      - name: Add Rust to the PATH
314        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
315
316      - name: Checkout repo
317        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
318        with:
319          clean: false
320
321      - name: Cache dependencies
322        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
323        with:
324          save-if: ${{ github.ref == 'refs/heads/main' }}
325          cache-provider: "buildjet"
326
327      - name: Install Clang & Mold
328        run: ./script/remote-server && ./script/install-mold 2.34.0
329
330      - name: Configure CI
331        run: |
332          mkdir -p ./../.cargo
333          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
334
335      - name: Build Remote Server
336        run: cargo build -p remote_server
337
338      - name: Clean CI config file
339        if: always()
340        run: rm -rf ./../.cargo
341
342  windows_clippy:
343    timeout-minutes: 60
344    name: (Windows) Run Clippy
345    needs: [job_spec]
346    if: |
347      github.repository_owner == 'zed-industries' &&
348      needs.job_spec.outputs.run_tests == 'true'
349    runs-on: windows-2025-16
350    steps:
351      # more info here:- https://github.com/rust-lang/cargo/issues/13020
352      - name: Enable longer pathnames for git
353        run: git config --system core.longpaths true
354
355      - name: Checkout repo
356        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
357        with:
358          clean: false
359
360      - name: Create Dev Drive using ReFS
361        run: ./script/setup-dev-driver.ps1
362
363      # actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
364      - name: Copy Git Repo to Dev Drive
365        run: |
366          Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.ZED_WORKSPACE }}" -Recurse
367
368      - name: Cache dependencies
369        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
370        with:
371          save-if: ${{ github.ref == 'refs/heads/main' }}
372          workspaces: ${{ env.ZED_WORKSPACE }}
373          cache-provider: "github"
374
375      - name: Configure CI
376        run: |
377          mkdir -p ${{ env.CARGO_HOME }} -ErrorAction Ignore
378          cp ./.cargo/ci-config.toml ${{ env.CARGO_HOME }}/config.toml
379
380      - name: cargo clippy
381        working-directory: ${{ env.ZED_WORKSPACE }}
382        run: ./script/clippy.ps1
383
384      - name: Check dev drive space
385        working-directory: ${{ env.ZED_WORKSPACE }}
386        # `setup-dev-driver.ps1` creates a 100GB drive, with CI taking up ~45GB of the drive.
387        run: ./script/exit-ci-if-dev-drive-is-full.ps1 95
388
389      # Since the Windows runners are stateful, so we need to remove the config file to prevent potential bug.
390      - name: Clean CI config file
391        if: always()
392        run: |
393          if (Test-Path "${{ env.CARGO_HOME }}/config.toml") {
394            Remove-Item -Path "${{ env.CARGO_HOME }}/config.toml"  -Force
395          }
396
397  # Windows CI takes twice as long as our other platforms and fast github hosted runners are expensive.
398  # But we still want to do CI, so let's only run tests on main and come back to this when we're
399  # ready to self host our Windows CI (e.g. during the push for full Windows support)
400  windows_tests:
401    timeout-minutes: 60
402    name: (Windows) Run Tests
403    needs: [job_spec]
404    if: |
405      github.repository_owner == 'zed-industries' &&
406      needs.job_spec.outputs.run_tests == 'true'
407    # Use bigger runners for PRs (speed); smaller for async (cost)
408    runs-on: ${{ github.event_name == 'pull_request' && 'windows-2025-32' || 'windows-2025-16' }}
409    steps:
410      # more info here:- https://github.com/rust-lang/cargo/issues/13020
411      - name: Enable longer pathnames for git
412        run: git config --system core.longpaths true
413
414      - name: Checkout repo
415        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
416        with:
417          clean: false
418
419      - name: Create Dev Drive using ReFS
420        run: ./script/setup-dev-driver.ps1
421
422      # actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
423      - name: Copy Git Repo to Dev Drive
424        run: |
425          Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.ZED_WORKSPACE }}" -Recurse
426
427      - name: Cache dependencies
428        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
429        with:
430          save-if: ${{ github.ref == 'refs/heads/main' }}
431          workspaces: ${{ env.ZED_WORKSPACE }}
432          cache-provider: "github"
433
434      - name: Configure CI
435        run: |
436          mkdir -p ${{ env.CARGO_HOME }} -ErrorAction Ignore
437          cp ./.cargo/ci-config.toml ${{ env.CARGO_HOME }}/config.toml
438
439      - name: Run tests
440        uses: ./.github/actions/run_tests_windows
441        with:
442          working-directory: ${{ env.ZED_WORKSPACE }}
443
444      - name: Build Zed
445        working-directory: ${{ env.ZED_WORKSPACE }}
446        run: cargo build
447
448      - name: Check dev drive space
449        working-directory: ${{ env.ZED_WORKSPACE }}
450        # `setup-dev-driver.ps1` creates a 100GB drive, with CI taking up ~45GB of the drive.
451        run: ./script/exit-ci-if-dev-drive-is-full.ps1 95
452
453      # Since the Windows runners are stateful, so we need to remove the config file to prevent potential bug.
454      - name: Clean CI config file
455        if: always()
456        run: |
457          if (Test-Path "${{ env.CARGO_HOME }}/config.toml") {
458            Remove-Item -Path "${{ env.CARGO_HOME }}/config.toml"  -Force
459          }
460
461  tests_pass:
462    name: Tests Pass
463    runs-on: ubuntu-latest
464    needs:
465      - job_spec
466      - style
467      - migration_checks
468      - workspace_hack
469      - linux_tests
470      - build_remote_server
471      - macos_tests
472      - windows_clippy
473      - windows_tests
474    if: always()
475    steps:
476      - name: Check all tests passed
477        run: |
478          # Check dependent jobs...
479          RET_CODE=0
480          # Always check style
481          [[ "${{ needs.style.result }}" != 'success' ]] && { RET_CODE=1; echo "style tests failed"; }
482
483          # Only check test jobs if they were supposed to run
484          if [[ "${{ needs.job_spec.outputs.run_tests }}" == "true" ]]; then
485            [[ "${{ needs.macos_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "macOS tests failed"; }
486            [[ "${{ needs.linux_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "Linux tests failed"; }
487            [[ "${{ needs.windows_tests.result }}"        != 'success' ]] && { RET_CODE=1; echo "Windows tests failed"; }
488            [[ "${{ needs.windows_clippy.result }}"       != 'success' ]] && { RET_CODE=1; echo "Windows clippy failed"; }
489            [[ "${{ needs.build_remote_server.result }}"  != 'success' ]] && { RET_CODE=1; echo "Remote server build failed"; }
490          fi
491          if [[ "$RET_CODE" -eq 0 ]]; then
492            echo "All tests passed successfully!"
493          fi
494          exit $RET_CODE
495
496  bundle-mac:
497    timeout-minutes: 120
498    name: Create a macOS bundle
499    runs-on:
500      - self-hosted
501      - bundle
502    if: |
503      startsWith(github.ref, 'refs/tags/v')
504      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
505    needs: [macos_tests]
506    env:
507      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
508      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
509      APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
510      APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
511      APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
512      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
513      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
514      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
515      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
516    steps:
517      - name: Install Node
518        uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
519        with:
520          node-version: "18"
521
522      - name: Checkout repo
523        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
524        with:
525          # We need to fetch more than one commit so that `script/draft-release-notes`
526          # is able to diff between the current and previous tag.
527          #
528          # 25 was chosen arbitrarily.
529          fetch-depth: 25
530          clean: false
531          ref: ${{ github.ref }}
532
533      - name: Limit target directory size
534        run: script/clear-target-dir-if-larger-than 100
535
536      - name: Determine version and release channel
537        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
538        run: |
539          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
540          script/determine-release-channel
541
542      - name: Draft release notes
543        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
544        run: |
545          mkdir -p target/
546          # Ignore any errors that occur while drafting release notes to not fail the build.
547          script/draft-release-notes "$RELEASE_VERSION" "$RELEASE_CHANNEL" > target/release-notes.md || true
548          script/create-draft-release target/release-notes.md
549        env:
550          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
551
552      - name: Create macOS app bundle
553        run: script/bundle-mac
554
555      - name: Rename binaries
556        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
557        run: |
558          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
559          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
560
561      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
562        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
563        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
564        with:
565          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
566          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
567
568      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
569        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
570        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
571        with:
572          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
573          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
574
575      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
576        name: Upload app bundle to release
577        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
578        with:
579          draft: true
580          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
581          files: |
582            target/zed-remote-server-macos-x86_64.gz
583            target/zed-remote-server-macos-aarch64.gz
584            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
585            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
586        env:
587          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
588
589  bundle-linux-x86_x64:
590    timeout-minutes: 60
591    name: Linux x86_x64 release bundle
592    runs-on:
593      - buildjet-16vcpu-ubuntu-2004
594    if: |
595      startsWith(github.ref, 'refs/tags/v')
596      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
597    needs: [linux_tests]
598    env:
599      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
600      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
601      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
602      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
603    steps:
604      - name: Checkout repo
605        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
606        with:
607          clean: false
608
609      - name: Install Linux dependencies
610        run: ./script/linux && ./script/install-mold 2.34.0
611
612      - name: Determine version and release channel
613        if: startsWith(github.ref, 'refs/tags/v')
614        run: |
615          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
616          script/determine-release-channel
617
618      - name: Create Linux .tar.gz bundle
619        run: script/bundle-linux
620
621      - name: Upload Linux bundle to workflow run if main branch or specific label
622        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
623        if: |
624          github.ref == 'refs/heads/main'
625          || contains(github.event.pull_request.labels.*.name, 'run-bundling')
626        with:
627          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
628          path: target/release/zed-*.tar.gz
629
630      - name: Upload Linux remote server to workflow run if main branch or specific label
631        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
632        if: |
633          github.ref == 'refs/heads/main'
634          || contains(github.event.pull_request.labels.*.name, 'run-bundling')
635        with:
636          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.gz
637          path: target/zed-remote-server-linux-x86_64.gz
638
639      - name: Upload app bundle to release
640        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
641        with:
642          draft: true
643          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
644          files: |
645            target/zed-remote-server-linux-x86_64.gz
646            target/release/zed-linux-x86_64.tar.gz
647        env:
648          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
649
650  bundle-linux-aarch64: # this runs on ubuntu22.04
651    timeout-minutes: 60
652    name: Linux arm64 release bundle
653    runs-on:
654      - buildjet-16vcpu-ubuntu-2204-arm
655    if: |
656      startsWith(github.ref, 'refs/tags/v')
657      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
658    needs: [linux_tests]
659    env:
660      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
661      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
662      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
663      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
664    steps:
665      - name: Checkout repo
666        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
667        with:
668          clean: false
669
670      - name: Install Linux dependencies
671        run: ./script/linux
672
673      - name: Determine version and release channel
674        if: startsWith(github.ref, 'refs/tags/v')
675        run: |
676          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
677          script/determine-release-channel
678
679      - name: Create and upload Linux .tar.gz bundle
680        run: script/bundle-linux
681
682      - name: Upload Linux bundle to workflow run if main branch or specific label
683        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
684        if: |
685          github.ref == 'refs/heads/main'
686          || contains(github.event.pull_request.labels.*.name, 'run-bundling')
687        with:
688          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
689          path: target/release/zed-*.tar.gz
690
691      - name: Upload Linux remote server to workflow run if main branch or specific label
692        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
693        if: |
694          github.ref == 'refs/heads/main'
695          || contains(github.event.pull_request.labels.*.name, 'run-bundling')
696        with:
697          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.gz
698          path: target/zed-remote-server-linux-aarch64.gz
699
700      - name: Upload app bundle to release
701        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
702        with:
703          draft: true
704          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
705          files: |
706            target/zed-remote-server-linux-aarch64.gz
707            target/release/zed-linux-aarch64.tar.gz
708        env:
709          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
710
711  nix-build:
712    timeout-minutes: 60
713    name: Nix Build
714    continue-on-error: true
715    if: github.repository_owner == 'zed-industries' && contains(github.event.pull_request.labels.*.name, 'run-nix')
716    strategy:
717      fail-fast: false
718      matrix:
719        system:
720          - os: x86 Linux
721            runner: buildjet-16vcpu-ubuntu-2204
722            install_nix: true
723          - os: arm Mac
724            runner: [macOS, ARM64, test]
725            install_nix: false
726    runs-on: ${{ matrix.system.runner }}
727    env:
728      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
729      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
730      GIT_LFS_SKIP_SMUDGE: 1 # breaks the livekit rust sdk examples which we don't actually depend on
731    steps:
732      - name: Checkout repo
733        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
734        with:
735          clean: false
736      - name: Set path
737        if: ${{ ! matrix.system.install_nix }}
738        run: |
739          echo "/nix/var/nix/profiles/default/bin" >> $GITHUB_PATH
740          echo "/Users/administrator/.nix-profile/bin" >> $GITHUB_PATH
741
742      - uses: cachix/install-nix-action@d1ca217b388ee87b2507a9a93bf01368bde7cec2 # v31
743        if: ${{ matrix.system.install_nix }}
744        with:
745          github_access_token: ${{ secrets.GITHUB_TOKEN }}
746
747      - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
748        with:
749          name: zed-industries
750          authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
751          skipPush: true
752      - run: nix build .#debug
753      - name: Limit /nix/store to 50GB
754        run: "[ $(du -sm /nix/store | cut -f1) -gt 50000 ] && nix-collect-garbage -d"
755
756  auto-release-preview:
757    name: Auto release preview
758    if: |
759      startsWith(github.ref, 'refs/tags/v')
760      && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')
761    needs: [bundle-mac, bundle-linux-x86_x64, bundle-linux-aarch64]
762    runs-on:
763      - self-hosted
764      - bundle
765    steps:
766      - name: gh release
767        run: gh release edit $GITHUB_REF_NAME --draft=true
768        env:
769          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}