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