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