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