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