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