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          [[ "${{ needs.check_docs.result }}" != 'success' ]] && { RET_CODE=1; echo "docs checks failed"; }
464
465          # Only check test jobs if they were supposed to run
466          if [[ "${{ needs.job_spec.outputs.run_tests }}" == "true" ]]; then
467            [[ "${{ needs.workspace_hack.result }}"       != 'success' ]] && { RET_CODE=1; echo "Workspace Hack failed"; }
468            [[ "${{ needs.macos_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "macOS tests failed"; }
469            [[ "${{ needs.linux_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "Linux tests failed"; }
470            [[ "${{ needs.windows_tests.result }}"        != 'success' ]] && { RET_CODE=1; echo "Windows tests failed"; }
471            [[ "${{ needs.build_remote_server.result }}"  != 'success' ]] && { RET_CODE=1; echo "Remote server build failed"; }
472            # This check is intentionally disabled. See: https://github.com/zed-industries/zed/pull/28431
473            # [[ "${{ needs.migration_checks.result }}"     != 'success' ]] && { RET_CODE=1; echo "Migration Checks failed"; }
474          fi
475          if [[ "$RET_CODE" -eq 0 ]]; then
476            echo "All tests passed successfully!"
477          fi
478          exit $RET_CODE
479
480  bundle-mac:
481    timeout-minutes: 120
482    name: Create a macOS bundle
483    runs-on:
484      - self-hosted
485      - bundle
486    if: |
487      startsWith(github.ref, 'refs/tags/v')
488      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
489    needs: [macos_tests]
490    env:
491      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
492      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
493      APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
494      APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
495      APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
496      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
497      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
498      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
499    steps:
500      - name: Install Node
501        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
502        with:
503          node-version: "18"
504
505      - name: Checkout repo
506        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
507        with:
508          # We need to fetch more than one commit so that `script/draft-release-notes`
509          # is able to diff between the current and previous tag.
510          #
511          # 25 was chosen arbitrarily.
512          fetch-depth: 25
513          clean: false
514          ref: ${{ github.ref }}
515
516      - name: Limit target directory size
517        run: script/clear-target-dir-if-larger-than 100
518
519      - name: Determine version and release channel
520        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
521        run: |
522          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
523          script/determine-release-channel
524
525      - name: Draft release notes
526        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
527        run: |
528          mkdir -p target/
529          # Ignore any errors that occur while drafting release notes to not fail the build.
530          script/draft-release-notes "$RELEASE_VERSION" "$RELEASE_CHANNEL" > target/release-notes.md || true
531          script/create-draft-release target/release-notes.md
532        env:
533          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
534
535      - name: Create macOS app bundle
536        run: script/bundle-mac
537
538      - name: Rename binaries
539        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
540        run: |
541          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
542          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
543
544      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
545        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
546        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
547        with:
548          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
549          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
550
551      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
552        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
553        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
554        with:
555          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
556          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
557
558      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
559        name: Upload app bundle to release
560        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
561        with:
562          draft: true
563          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
564          files: |
565            target/zed-remote-server-macos-x86_64.gz
566            target/zed-remote-server-macos-aarch64.gz
567            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
568            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
569        env:
570          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
571
572  bundle-linux-x86_x64:
573    timeout-minutes: 60
574    name: Linux x86_x64 release bundle
575    runs-on:
576      - buildjet-16vcpu-ubuntu-2004 # ubuntu 20.04 for minimal glibc
577    if: |
578      startsWith(github.ref, 'refs/tags/v')
579      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
580    needs: [linux_tests]
581    env:
582      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
583      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
584      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
585    steps:
586      - name: Checkout repo
587        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
588        with:
589          clean: false
590
591      - name: Install Linux dependencies
592        run: ./script/linux && ./script/install-mold 2.34.0
593
594      - name: Determine version and release channel
595        if: startsWith(github.ref, 'refs/tags/v')
596        run: |
597          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
598          script/determine-release-channel
599
600      - name: Create Linux .tar.gz bundle
601        run: script/bundle-linux
602
603      - name: Upload Artifact to Workflow - zed (run-bundling)
604        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
605        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
606        with:
607          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
608          path: target/release/zed-*.tar.gz
609
610      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
611        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
612        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
613        with:
614          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.gz
615          path: target/zed-remote-server-linux-x86_64.gz
616
617      - name: Upload Artifacts to release
618        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
619        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
620        with:
621          draft: true
622          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
623          files: |
624            target/zed-remote-server-linux-x86_64.gz
625            target/release/zed-linux-x86_64.tar.gz
626        env:
627          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
628
629  bundle-linux-aarch64: # this runs on ubuntu22.04
630    timeout-minutes: 60
631    name: Linux arm64 release bundle
632    runs-on:
633      - buildjet-16vcpu-ubuntu-2204-arm
634    if: |
635      startsWith(github.ref, 'refs/tags/v')
636      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
637    needs: [linux_tests]
638    env:
639      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
640      DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
641      DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
642    steps:
643      - name: Checkout repo
644        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
645        with:
646          clean: false
647
648      - name: Install Linux dependencies
649        run: ./script/linux
650
651      - name: Determine version and release channel
652        if: startsWith(github.ref, 'refs/tags/v')
653        run: |
654          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
655          script/determine-release-channel
656
657      - name: Create and upload Linux .tar.gz bundles
658        run: script/bundle-linux
659
660      - name: Upload Artifact to Workflow - zed (run-bundling)
661        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
662        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
663        with:
664          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
665          path: target/release/zed-*.tar.gz
666
667      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
668        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
669        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
670        with:
671          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.gz
672          path: target/zed-remote-server-linux-aarch64.gz
673
674      - name: Upload Artifacts to release
675        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
676        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
677        with:
678          draft: true
679          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
680          files: |
681            target/zed-remote-server-linux-aarch64.gz
682            target/release/zed-linux-aarch64.tar.gz
683        env:
684          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
685
686  freebsd:
687    timeout-minutes: 60
688    runs-on: github-8vcpu-ubuntu-2404
689    if: |
690      startsWith(github.ref, 'refs/tags/v')
691      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
692    needs: [linux_tests]
693    name: Build Zed on FreeBSD
694    # env:
695    #   MYTOKEN : ${{ secrets.MYTOKEN }}
696    #   MYTOKEN2: "value2"
697    steps:
698      - uses: actions/checkout@v4
699      - name: Build FreeBSD remote-server
700        id: freebsd-build
701        uses: vmactions/freebsd-vm@c3ae29a132c8ef1924775414107a97cac042aad5 # v1.2.0
702        with:
703          # envs: "MYTOKEN MYTOKEN2"
704          usesh: true
705          release: 13.5
706          copyback: true
707          prepare: |
708            pkg install -y \
709              bash curl jq git \
710              rustup-init cmake-core llvm-devel-lite pkgconf protobuf # ibx11 alsa-lib rust-bindgen-cli
711          run: |
712            freebsd-version
713            sysctl hw.model
714            sysctl hw.ncpu
715            sysctl hw.physmem
716            sysctl hw.usermem
717            git config --global --add safe.directory /home/runner/work/zed/zed
718            rustup-init --profile minimal --default-toolchain none -y
719            . "$HOME/.cargo/env"
720            ./script/bundle-freebsd
721            mkdir -p out/
722            mv "target/zed-remote-server-freebsd-x86_64.gz" out/
723            rm -rf target/
724            cargo clean
725
726      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
727        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
728        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
729        with:
730          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-freebsd.gz
731          path: out/zed-remote-server-freebsd-x86_64.gz
732
733      - name: Upload Artifacts to release
734        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
735        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
736        with:
737          draft: true
738          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
739          files: |
740            out/zed-remote-server-freebsd-x86_64.gz
741        env:
742          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
743
744  nix-build:
745    name: Build with Nix
746    uses: ./.github/workflows/nix.yml
747    if: github.repository_owner == 'zed-industries' && contains(github.event.pull_request.labels.*.name, 'run-nix')
748    secrets: inherit
749    with:
750      flake-output: debug
751      # excludes the final package to only cache dependencies
752      cachix-filter: "-zed-editor-[0-9.]*-nightly"
753
754  auto-release-preview:
755    name: Auto release preview
756    if: |
757      startsWith(github.ref, 'refs/tags/v')
758      && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')
759    needs: [bundle-mac, bundle-linux-x86_x64, bundle-linux-aarch64, freebsd]
760    runs-on:
761      - self-hosted
762      - bundle
763    steps:
764      - name: gh release
765        run: gh release edit $GITHUB_REF_NAME --draft=false
766        env:
767          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}