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      - macOS
 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      - name: Prettier Check on default.json
173        run: |
174          pnpm dlx prettier@${PRETTIER_VERSION} assets/settings/default.json --check || {
175            echo "To fix, run from the root of the Zed repo:"
176            echo "  pnpm dlx prettier@${PRETTIER_VERSION} assets/settings/default.json --write"
177            false
178          }
179        env:
180          PRETTIER_VERSION: 3.5.0
181
182      # To support writing comments that they will certainly be revisited.
183      - name: Check for todo! and FIXME comments
184        run: script/check-todos
185
186      - name: Check modifier use in keymaps
187        run: script/check-keymaps
188
189      - name: Run style checks
190        uses: ./.github/actions/check_style
191
192      - name: Check for typos
193        uses: crate-ci/typos@8e6a4285bcbde632c5d79900a7779746e8b7ea3f # v1.24.6
194        with:
195          config: ./typos.toml
196
197  check_docs:
198    timeout-minutes: 60
199    name: Check docs
200    needs: [job_spec]
201    if: github.repository_owner == 'zed-industries'
202    runs-on:
203      - buildjet-8vcpu-ubuntu-2204
204    steps:
205      - name: Checkout repo
206        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
207        with:
208          clean: false
209
210      - name: Configure CI
211        run: |
212          mkdir -p ./../.cargo
213          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
214
215      - name: Build docs
216        uses: ./.github/actions/build_docs
217
218  macos_tests:
219    timeout-minutes: 60
220    name: (macOS) Run Clippy and tests
221    needs: [job_spec]
222    if: |
223      github.repository_owner == 'zed-industries' &&
224      needs.job_spec.outputs.run_tests == 'true'
225    runs-on:
226      - self-hosted
227      - macOS
228    steps:
229      - name: Checkout repo
230        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
231        with:
232          clean: false
233
234      - name: Configure CI
235        run: |
236          mkdir -p ./../.cargo
237          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
238
239      - name: cargo clippy
240        run: ./script/clippy
241
242      - name: Install cargo-machete
243        uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2
244        with:
245          command: install
246          args: cargo-machete@0.7.0
247
248      - name: Check unused dependencies
249        uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2
250        with:
251          command: machete
252
253      - name: Check licenses
254        run: |
255          script/check-licenses
256          if [[ "${{ needs.job_spec.outputs.run_license }}" == "true" ]]; then
257            script/generate-licenses /tmp/zed_licenses_output
258          fi
259
260      - name: Check for new vulnerable dependencies
261        if: github.event_name == 'pull_request'
262        uses: actions/dependency-review-action@67d4f4bd7a9b17a0db54d2a7519187c65e339de8 # v4
263        with:
264          license-check: false
265
266      - name: Run tests
267        uses: ./.github/actions/run_tests
268
269      - name: Build collab
270        run: cargo build -p collab
271
272      - name: Build other binaries and features
273        run: |
274          cargo build --workspace --bins --all-features
275          cargo check -p gpui --features "macos-blade"
276          cargo check -p workspace
277          cargo build -p remote_server
278          cargo check -p gpui --examples
279
280      # Since the macOS runners are stateful, so we need to remove the config file to prevent potential bug.
281      - name: Clean CI config file
282        if: always()
283        run: rm -rf ./../.cargo
284
285  linux_tests:
286    timeout-minutes: 60
287    name: (Linux) Run Clippy and tests
288    needs: [job_spec]
289    if: |
290      github.repository_owner == 'zed-industries' &&
291      needs.job_spec.outputs.run_tests == 'true'
292    runs-on:
293      - buildjet-16vcpu-ubuntu-2204
294    steps:
295      - name: Add Rust to the PATH
296        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
297
298      - name: Checkout repo
299        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
300        with:
301          clean: false
302
303      - name: Cache dependencies
304        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
305        with:
306          save-if: ${{ github.ref == 'refs/heads/main' }}
307          cache-provider: "buildjet"
308
309      - name: Install Linux dependencies
310        run: ./script/linux
311
312      - name: Configure CI
313        run: |
314          mkdir -p ./../.cargo
315          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
316
317      - name: cargo clippy
318        run: ./script/clippy
319
320      - name: Run tests
321        uses: ./.github/actions/run_tests
322
323      - name: Build other binaries and features
324        run: |
325          cargo build -p zed
326          cargo check -p workspace
327          cargo check -p gpui --examples
328
329      # Even the Linux runner is not stateful, in theory there is no need to do this cleanup.
330      # But, to avoid potential issues in the future if we choose to use a stateful Linux runner and forget to add code
331      # to clean up the config file, I’ve included the cleanup code here as a precaution.
332      # While it’s not strictly necessary at this moment, I believe it’s better to err on the side of caution.
333      - name: Clean CI config file
334        if: always()
335        run: rm -rf ./../.cargo
336
337  build_remote_server:
338    timeout-minutes: 60
339    name: (Linux) Build Remote Server
340    needs: [job_spec]
341    if: |
342      github.repository_owner == 'zed-industries' &&
343      needs.job_spec.outputs.run_tests == 'true'
344    runs-on:
345      - buildjet-8vcpu-ubuntu-2204
346    steps:
347      - name: Add Rust to the PATH
348        run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
349
350      - name: Checkout repo
351        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
352        with:
353          clean: false
354
355      - name: Cache dependencies
356        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
357        with:
358          save-if: ${{ github.ref == 'refs/heads/main' }}
359          cache-provider: "buildjet"
360
361      - name: Install Clang & Mold
362        run: ./script/remote-server && ./script/install-mold 2.34.0
363
364      - name: Configure CI
365        run: |
366          mkdir -p ./../.cargo
367          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
368
369      - name: Build Remote Server
370        run: cargo build -p remote_server
371
372      - name: Clean CI config file
373        if: always()
374        run: rm -rf ./../.cargo
375
376  windows_clippy:
377    timeout-minutes: 60
378    name: (Windows) Run Clippy
379    needs: [job_spec]
380    if: |
381      github.repository_owner == 'zed-industries' &&
382      needs.job_spec.outputs.run_tests == 'true'
383    runs-on: windows-2025-16
384    steps:
385      # more info here:- https://github.com/rust-lang/cargo/issues/13020
386      - name: Enable longer pathnames for git
387        run: git config --system core.longpaths true
388
389      - name: Checkout repo
390        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
391        with:
392          clean: false
393
394      - name: Create Dev Drive using ReFS
395        run: ./script/setup-dev-driver.ps1
396
397      # actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
398      - name: Copy Git Repo to Dev Drive
399        run: |
400          Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.ZED_WORKSPACE }}" -Recurse
401
402      - name: Cache dependencies
403        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
404        with:
405          save-if: ${{ github.ref == 'refs/heads/main' }}
406          workspaces: ${{ env.ZED_WORKSPACE }}
407          cache-provider: "github"
408
409      - name: Configure CI
410        run: |
411          mkdir -p ${{ env.CARGO_HOME }} -ErrorAction Ignore
412          cp ./.cargo/ci-config.toml ${{ env.CARGO_HOME }}/config.toml
413
414      - name: cargo clippy
415        working-directory: ${{ env.ZED_WORKSPACE }}
416        run: ./script/clippy.ps1
417
418      - name: Check dev drive space
419        working-directory: ${{ env.ZED_WORKSPACE }}
420        # `setup-dev-driver.ps1` creates a 100GB drive, with CI taking up ~45GB of the drive.
421        run: ./script/exit-ci-if-dev-drive-is-full.ps1 95
422
423      # Since the Windows runners are stateful, so we need to remove the config file to prevent potential bug.
424      - name: Clean CI config file
425        if: always()
426        run: |
427          if (Test-Path "${{ env.CARGO_HOME }}/config.toml") {
428            Remove-Item -Path "${{ env.CARGO_HOME }}/config.toml"  -Force
429          }
430
431  # Windows CI takes twice as long as our other platforms and fast github hosted runners are expensive.
432  # But we still want to do CI, so let's only run tests on main and come back to this when we're
433  # ready to self host our Windows CI (e.g. during the push for full Windows support)
434  windows_tests:
435    timeout-minutes: 60
436    name: (Windows) Run Tests
437    needs: [job_spec]
438    if: |
439      github.repository_owner == 'zed-industries' &&
440      needs.job_spec.outputs.run_tests == 'true'
441    # Use bigger runners for PRs (speed); smaller for async (cost)
442    runs-on: ${{ github.event_name == 'pull_request' && 'windows-2025-32' || 'windows-2025-16' }}
443    steps:
444      # more info here:- https://github.com/rust-lang/cargo/issues/13020
445      - name: Enable longer pathnames for git
446        run: git config --system core.longpaths true
447
448      - name: Checkout repo
449        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
450        with:
451          clean: false
452
453      - name: Create Dev Drive using ReFS
454        run: ./script/setup-dev-driver.ps1
455
456      # actions/checkout does not let us clone into anywhere outside ${{ github.workspace }}, so we have to copy the clone...
457      - name: Copy Git Repo to Dev Drive
458        run: |
459          Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.ZED_WORKSPACE }}" -Recurse
460
461      - name: Cache dependencies
462        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
463        with:
464          save-if: ${{ github.ref == 'refs/heads/main' }}
465          workspaces: ${{ env.ZED_WORKSPACE }}
466          cache-provider: "github"
467
468      - name: Configure CI
469        run: |
470          mkdir -p ${{ env.CARGO_HOME }} -ErrorAction Ignore
471          cp ./.cargo/ci-config.toml ${{ env.CARGO_HOME }}/config.toml
472
473      - name: Run tests
474        uses: ./.github/actions/run_tests_windows
475        with:
476          working-directory: ${{ env.ZED_WORKSPACE }}
477
478      - name: Build Zed
479        working-directory: ${{ env.ZED_WORKSPACE }}
480        run: cargo build
481
482      - name: Check dev drive space
483        working-directory: ${{ env.ZED_WORKSPACE }}
484        # `setup-dev-driver.ps1` creates a 100GB drive, with CI taking up ~45GB of the drive.
485        run: ./script/exit-ci-if-dev-drive-is-full.ps1 95
486
487      # Since the Windows runners are stateful, so we need to remove the config file to prevent potential bug.
488      - name: Clean CI config file
489        if: always()
490        run: |
491          if (Test-Path "${{ env.CARGO_HOME }}/config.toml") {
492            Remove-Item -Path "${{ env.CARGO_HOME }}/config.toml"  -Force
493          }
494
495  tests_pass:
496    name: Tests Pass
497    runs-on: ubuntu-latest
498    needs:
499      - job_spec
500      - style
501      - check_docs
502      - migration_checks
503      # run_tests: If adding required tests, add them here and to script below.
504      - workspace_hack
505      - linux_tests
506      - build_remote_server
507      - macos_tests
508      - windows_clippy
509      - windows_tests
510    if: |
511      github.repository_owner == 'zed-industries' &&
512      always()
513    steps:
514      - name: Check all tests passed
515        run: |
516          # Check dependent jobs...
517          RET_CODE=0
518          # Always check style
519          [[ "${{ needs.style.result }}"      != 'success' ]] && { RET_CODE=1; echo "style tests failed"; }
520          [[ "${{ needs.check_docs.result }}" != 'success' ]] && { RET_CODE=1; echo "docs checks failed"; }
521
522          # Only check test jobs if they were supposed to run
523          if [[ "${{ needs.job_spec.outputs.run_tests }}" == "true" ]]; then
524            [[ "${{ needs.workspace_hack.result }}"       != 'success' ]] && { RET_CODE=1; echo "Workspace Hack failed"; }
525            [[ "${{ needs.macos_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "macOS tests failed"; }
526            [[ "${{ needs.linux_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "Linux tests failed"; }
527            [[ "${{ needs.windows_tests.result }}"        != 'success' ]] && { RET_CODE=1; echo "Windows tests failed"; }
528            [[ "${{ needs.windows_clippy.result }}"       != 'success' ]] && { RET_CODE=1; echo "Windows clippy failed"; }
529            [[ "${{ needs.build_remote_server.result }}"  != 'success' ]] && { RET_CODE=1; echo "Remote server build failed"; }
530            # This check is intentionally disabled. See: https://github.com/zed-industries/zed/pull/28431
531            # [[ "${{ needs.migration_checks.result }}"     != 'success' ]] && { RET_CODE=1; echo "Migration Checks failed"; }
532          fi
533          if [[ "$RET_CODE" -eq 0 ]]; then
534            echo "All tests passed successfully!"
535          fi
536          exit $RET_CODE
537
538  bundle-mac:
539    timeout-minutes: 120
540    name: Create a macOS bundle
541    runs-on:
542      - self-hosted
543      - bundle
544    if: |
545      startsWith(github.ref, 'refs/tags/v')
546      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
547    needs: [macos_tests]
548    env:
549      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
550      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
551      APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
552      APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
553      APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
554      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
555      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
556      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
557    steps:
558      - name: Install Node
559        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
560        with:
561          node-version: "18"
562
563      - name: Checkout repo
564        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
565        with:
566          # We need to fetch more than one commit so that `script/draft-release-notes`
567          # is able to diff between the current and previous tag.
568          #
569          # 25 was chosen arbitrarily.
570          fetch-depth: 25
571          clean: false
572          ref: ${{ github.ref }}
573
574      - name: Limit target directory size
575        run: script/clear-target-dir-if-larger-than 100
576
577      - name: Determine version and release channel
578        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
579        run: |
580          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
581          script/determine-release-channel
582
583      - name: Draft release notes
584        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
585        run: |
586          mkdir -p target/
587          # Ignore any errors that occur while drafting release notes to not fail the build.
588          script/draft-release-notes "$RELEASE_VERSION" "$RELEASE_CHANNEL" > target/release-notes.md || true
589          script/create-draft-release target/release-notes.md
590        env:
591          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
592
593      - name: Create macOS app bundle
594        run: script/bundle-mac
595
596      - name: Rename binaries
597        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
598        run: |
599          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
600          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
601
602      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
603        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
604        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
605        with:
606          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
607          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
608
609      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
610        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
611        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
612        with:
613          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
614          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
615
616      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
617        name: Upload app bundle to release
618        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
619        with:
620          draft: true
621          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
622          files: |
623            target/zed-remote-server-macos-x86_64.gz
624            target/zed-remote-server-macos-aarch64.gz
625            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
626            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
627        env:
628          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
629
630  bundle-linux-x86_x64:
631    timeout-minutes: 60
632    name: Linux x86_x64 release bundle
633    runs-on:
634      - buildjet-16vcpu-ubuntu-2004 # ubuntu 20.04 for minimal glibc
635    if: |
636      startsWith(github.ref, 'refs/tags/v')
637      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
638    needs: [linux_tests]
639    env:
640      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
641      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
642      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
643    steps:
644      - name: Checkout repo
645        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
646        with:
647          clean: false
648
649      - name: Install Linux dependencies
650        run: ./script/linux && ./script/install-mold 2.34.0
651
652      - name: Determine version and release channel
653        if: startsWith(github.ref, 'refs/tags/v')
654        run: |
655          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
656          script/determine-release-channel
657
658      - name: Create Linux .tar.gz bundle
659        run: script/bundle-linux
660
661      - name: Upload Artifact to Workflow - zed (run-bundling)
662        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
663        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
664        with:
665          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
666          path: target/release/zed-*.tar.gz
667
668      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
669        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
670        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
671        with:
672          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.gz
673          path: target/zed-remote-server-linux-x86_64.gz
674
675      - name: Upload Artifacts to release
676        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
677        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
678        with:
679          draft: true
680          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
681          files: |
682            target/zed-remote-server-linux-x86_64.gz
683            target/release/zed-linux-x86_64.tar.gz
684        env:
685          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
686
687  bundle-linux-aarch64: # this runs on ubuntu22.04
688    timeout-minutes: 60
689    name: Linux arm64 release bundle
690    runs-on:
691      - buildjet-16vcpu-ubuntu-2204-arm
692    if: |
693      startsWith(github.ref, 'refs/tags/v')
694      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
695    needs: [linux_tests]
696    env:
697      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
698      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
699      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
700    steps:
701      - name: Checkout repo
702        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
703        with:
704          clean: false
705
706      - name: Install Linux dependencies
707        run: ./script/linux
708
709      - name: Determine version and release channel
710        if: startsWith(github.ref, 'refs/tags/v')
711        run: |
712          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
713          script/determine-release-channel
714
715      - name: Create and upload Linux .tar.gz bundles
716        run: script/bundle-linux
717
718      - name: Upload Artifact to Workflow - zed (run-bundling)
719        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
720        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
721        with:
722          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
723          path: target/release/zed-*.tar.gz
724
725      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
726        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
727        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
728        with:
729          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.gz
730          path: target/zed-remote-server-linux-aarch64.gz
731
732      - name: Upload Artifacts to release
733        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
734        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
735        with:
736          draft: true
737          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
738          files: |
739            target/zed-remote-server-linux-aarch64.gz
740            target/release/zed-linux-aarch64.tar.gz
741        env:
742          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
743
744  freebsd:
745    timeout-minutes: 60
746    runs-on: github-8vcpu-ubuntu-2404
747    if: |
748      startsWith(github.ref, 'refs/tags/v')
749      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
750    needs: [linux_tests]
751    name: Build Zed on FreeBSD
752    # env:
753    #   MYTOKEN : ${{ secrets.MYTOKEN }}
754    #   MYTOKEN2: "value2"
755    steps:
756      - uses: actions/checkout@v4
757      - name: Build FreeBSD remote-server
758        id: freebsd-build
759        uses: vmactions/freebsd-vm@c3ae29a132c8ef1924775414107a97cac042aad5 # v1.2.0
760        with:
761          # envs: "MYTOKEN MYTOKEN2"
762          usesh: true
763          release: 13.5
764          copyback: true
765          prepare: |
766            pkg install -y \
767              bash curl jq git \
768              rustup-init cmake-core llvm-devel-lite pkgconf protobuf # ibx11 alsa-lib rust-bindgen-cli
769          run: |
770            freebsd-version
771            sysctl hw.model
772            sysctl hw.ncpu
773            sysctl hw.physmem
774            sysctl hw.usermem
775            git config --global --add safe.directory /home/runner/work/zed/zed
776            rustup-init --profile minimal --default-toolchain none -y
777            . "$HOME/.cargo/env"
778            ./script/bundle-freebsd
779            mkdir -p out/
780            mv "target/zed-remote-server-freebsd-x86_64.gz" out/
781            rm -rf target/
782            cargo clean
783
784      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
785        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
786        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
787        with:
788          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-freebsd.gz
789          path: out/zed-remote-server-freebsd-x86_64.gz
790
791      - name: Upload Artifacts to release
792        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
793        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
794        with:
795          draft: true
796          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
797          files: |
798            out/zed-remote-server-freebsd-x86_64.gz
799        env:
800          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
801
802  nix-build:
803    name: Build with Nix
804    uses: ./.github/workflows/nix.yml
805    if: github.repository_owner == 'zed-industries' && contains(github.event.pull_request.labels.*.name, 'run-nix')
806    secrets: inherit
807    with:
808      flake-output: debug
809      # excludes the final package to only cache dependencies
810      cachix-filter: "-zed-editor-[0-9.]*-nightly"
811
812  auto-release-preview:
813    name: Auto release preview
814    if: |
815      startsWith(github.ref, 'refs/tags/v')
816      && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')
817    needs: [bundle-mac, bundle-linux-x86_x64, bundle-linux-aarch64, freebsd]
818    runs-on:
819      - self-hosted
820      - bundle
821    steps:
822      - name: gh release
823        run: gh release edit $GITHUB_REF_NAME --draft=false
824        env:
825          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}