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: Check that Cargo.lock is up to date
273        run: |
274          cargo update --locked --workspace
275
276      - name: cargo clippy
277        run: ./script/clippy
278
279      - name: Install cargo-machete
280        uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2
281        with:
282          command: install
283          args: cargo-machete@0.7.0
284
285      - name: Check unused dependencies
286        uses: clechasseur/rs-cargo@8435b10f6e71c2e3d4d3b7573003a8ce4bfc6386 # v2
287        with:
288          command: machete
289
290      - name: Check licenses
291        run: |
292          script/check-licenses
293          if [[ "${{ needs.job_spec.outputs.run_license }}" == "true" ]]; then
294            script/generate-licenses /tmp/zed_licenses_output
295          fi
296
297      - name: Check for new vulnerable dependencies
298        if: github.event_name == 'pull_request'
299        uses: actions/dependency-review-action@67d4f4bd7a9b17a0db54d2a7519187c65e339de8 # v4
300        with:
301          license-check: false
302
303      - name: Run tests
304        uses: ./.github/actions/run_tests
305
306      - name: Build collab
307        run: cargo build -p collab
308
309      - name: Build other binaries and features
310        run: |
311          cargo build --workspace --bins --all-features
312          cargo check -p gpui --features "macos-blade"
313          cargo check -p workspace
314          cargo build -p remote_server
315          cargo check -p gpui --examples
316
317      # Since the macOS runners are stateful, so we need to remove the config file to prevent potential bug.
318      - name: Clean CI config file
319        if: always()
320        run: rm -rf ./../.cargo
321
322  linux_tests:
323    timeout-minutes: 60
324    name: (Linux) Run Clippy and tests
325    needs: [job_spec]
326    if: |
327      github.repository_owner == 'zed-industries' &&
328      needs.job_spec.outputs.run_tests == 'true'
329    runs-on:
330      - buildjet-16vcpu-ubuntu-2204
331    steps:
332      - name: Add Rust to the PATH
333        run: echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
334
335      - name: Checkout repo
336        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
337        with:
338          clean: false
339
340      - name: Cache dependencies
341        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
342        with:
343          save-if: ${{ github.ref == 'refs/heads/main' }}
344          cache-provider: "buildjet"
345
346      - name: Install Linux dependencies
347        run: ./script/linux
348
349      - name: Configure CI
350        run: |
351          mkdir -p ./../.cargo
352          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
353
354      - name: cargo clippy
355        run: ./script/clippy
356
357      - name: Run tests
358        uses: ./.github/actions/run_tests
359
360      - name: Build other binaries and features
361        run: |
362          cargo build -p zed
363          cargo check -p workspace
364          cargo check -p gpui --examples
365
366      # Even the Linux runner is not stateful, in theory there is no need to do this cleanup.
367      # But, to avoid potential issues in the future if we choose to use a stateful Linux runner and forget to add code
368      # to clean up the config file, I’ve included the cleanup code here as a precaution.
369      # While it’s not strictly necessary at this moment, I believe it’s better to err on the side of caution.
370      - name: Clean CI config file
371        if: always()
372        run: rm -rf ./../.cargo
373
374  build_remote_server:
375    timeout-minutes: 60
376    name: (Linux) Build Remote Server
377    needs: [job_spec]
378    if: |
379      github.repository_owner == 'zed-industries' &&
380      needs.job_spec.outputs.run_tests == 'true'
381    runs-on:
382      - buildjet-8vcpu-ubuntu-2204
383    steps:
384      - name: Add Rust to the PATH
385        run: echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
386
387      - name: Checkout repo
388        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
389        with:
390          clean: false
391
392      - name: Cache dependencies
393        uses: swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
394        with:
395          save-if: ${{ github.ref == 'refs/heads/main' }}
396          cache-provider: "buildjet"
397
398      - name: Install Clang & Mold
399        run: ./script/remote-server && ./script/install-mold 2.34.0
400
401      - name: Configure CI
402        run: |
403          mkdir -p ./../.cargo
404          cp ./.cargo/ci-config.toml ./../.cargo/config.toml
405
406      - name: Build Remote Server
407        run: cargo build -p remote_server
408
409      - name: Clean CI config file
410        if: always()
411        run: rm -rf ./../.cargo
412
413  windows_tests:
414    timeout-minutes: 60
415    name: (Windows) Run Clippy and tests
416    needs: [job_spec]
417    if: |
418      github.repository_owner == 'zed-industries' &&
419      needs.job_spec.outputs.run_tests == 'true'
420    runs-on: [self-hosted, Windows, X64]
421    steps:
422      - name: Environment Setup
423        run: |
424          $RunnerDir = Split-Path -Parent $env:RUNNER_WORKSPACE
425          Write-Output `
426            "RUSTUP_HOME=$RunnerDir\.rustup" `
427            "CARGO_HOME=$RunnerDir\.cargo" `
428            "PATH=$RunnerDir\.cargo\bin;$env:PATH" `
429          >> $env:GITHUB_ENV
430
431      - name: Checkout repo
432        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
433        with:
434          clean: false
435
436      - name: Configure CI
437        run: |
438          New-Item -ItemType Directory -Path "./../.cargo" -Force
439          Copy-Item -Path "./.cargo/ci-config.toml" -Destination "./../.cargo/config.toml"
440
441      - name: cargo clippy
442        run: |
443          .\script\clippy.ps1
444
445      - name: Run tests
446        uses: ./.github/actions/run_tests_windows
447
448      - name: Build Zed
449        run: cargo build
450
451      - name: Limit target directory size
452        run: ./script/clear-target-dir-if-larger-than.ps1 250
453
454      - name: Clean CI config file
455        if: always()
456        run: Remove-Item -Recurse -Path "./../.cargo" -Force -ErrorAction SilentlyContinue
457
458  tests_pass:
459    name: Tests Pass
460    runs-on: ubuntu-latest
461    needs:
462      - job_spec
463      - style
464      - check_docs
465      - actionlint
466      - migration_checks
467      # run_tests: If adding required tests, add them here and to script below.
468      - workspace_hack
469      - linux_tests
470      - build_remote_server
471      - macos_tests
472      - windows_tests
473    if: |
474      github.repository_owner == 'zed-industries' &&
475      always()
476    steps:
477      - name: Check all tests passed
478        run: |
479          # Check dependent jobs...
480          RET_CODE=0
481          # Always check style
482          [[ "${{ needs.style.result }}"      != 'success' ]] && { RET_CODE=1; echo "style tests failed"; }
483
484          if [[ "${{ needs.job_spec.outputs.run_docs }}" == "true" ]]; then
485            [[ "${{ needs.check_docs.result }}" != 'success' ]] && { RET_CODE=1; echo "docs checks failed"; }
486          fi
487
488          if [[ "${{ needs.job_spec.outputs.run_actionlint }}" == "true" ]]; then
489            [[ "${{ needs.actionlint.result }}" != 'success' ]] && { RET_CODE=1; echo "actionlint checks failed"; }
490          fi
491
492          # Only check test jobs if they were supposed to run
493          if [[ "${{ needs.job_spec.outputs.run_tests }}" == "true" ]]; then
494            [[ "${{ needs.workspace_hack.result }}"       != 'success' ]] && { RET_CODE=1; echo "Workspace Hack failed"; }
495            [[ "${{ needs.macos_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "macOS tests failed"; }
496            [[ "${{ needs.linux_tests.result }}"          != 'success' ]] && { RET_CODE=1; echo "Linux tests failed"; }
497            [[ "${{ needs.windows_tests.result }}"        != 'success' ]] && { RET_CODE=1; echo "Windows tests failed"; }
498            [[ "${{ needs.build_remote_server.result }}"  != 'success' ]] && { RET_CODE=1; echo "Remote server build failed"; }
499            # This check is intentionally disabled. See: https://github.com/zed-industries/zed/pull/28431
500            # [[ "${{ needs.migration_checks.result }}"     != 'success' ]] && { RET_CODE=1; echo "Migration Checks failed"; }
501          fi
502          if [[ "$RET_CODE" -eq 0 ]]; then
503            echo "All tests passed successfully!"
504          fi
505          exit $RET_CODE
506
507  bundle-mac:
508    timeout-minutes: 120
509    name: Create a macOS bundle
510    runs-on:
511      - self-mini-macos
512    if: |
513      startsWith(github.ref, 'refs/tags/v')
514      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
515    needs: [macos_tests]
516    env:
517      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
518      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
519      APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
520      APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
521      APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
522    steps:
523      - name: Install Node
524        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
525        with:
526          node-version: "18"
527
528      - name: Checkout repo
529        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
530        with:
531          # We need to fetch more than one commit so that `script/draft-release-notes`
532          # is able to diff between the current and previous tag.
533          #
534          # 25 was chosen arbitrarily.
535          fetch-depth: 25
536          clean: false
537          ref: ${{ github.ref }}
538
539      - name: Limit target directory size
540        run: script/clear-target-dir-if-larger-than 100
541
542      - name: Determine version and release channel
543        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
544        run: |
545          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
546          script/determine-release-channel
547
548      - name: Draft release notes
549        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
550        run: |
551          mkdir -p target/
552          # Ignore any errors that occur while drafting release notes to not fail the build.
553          script/draft-release-notes "$RELEASE_VERSION" "$RELEASE_CHANNEL" > target/release-notes.md || true
554          script/create-draft-release target/release-notes.md
555        env:
556          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
557
558      - name: Create macOS app bundle
559        run: script/bundle-mac
560
561      - name: Rename binaries
562        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
563        run: |
564          mv target/aarch64-apple-darwin/release/Zed.dmg target/aarch64-apple-darwin/release/Zed-aarch64.dmg
565          mv target/x86_64-apple-darwin/release/Zed.dmg target/x86_64-apple-darwin/release/Zed-x86_64.dmg
566
567      - name: Upload app bundle (aarch64) to workflow run if main branch or specific label
568        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
569        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
570        with:
571          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-aarch64.dmg
572          path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
573
574      - name: Upload app bundle (x86_64) to workflow run if main branch or specific label
575        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
576        if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
577        with:
578          name: Zed_${{ github.event.pull_request.head.sha || github.sha }}-x86_64.dmg
579          path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
580
581      - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
582        name: Upload app bundle to release
583        if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }}
584        with:
585          draft: true
586          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
587          files: |
588            target/zed-remote-server-macos-x86_64.gz
589            target/zed-remote-server-macos-aarch64.gz
590            target/aarch64-apple-darwin/release/Zed-aarch64.dmg
591            target/x86_64-apple-darwin/release/Zed-x86_64.dmg
592        env:
593          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
594
595  bundle-linux-x86_x64:
596    timeout-minutes: 60
597    name: Linux x86_x64 release bundle
598    runs-on:
599      - buildjet-16vcpu-ubuntu-2004 # ubuntu 20.04 for minimal glibc
600    if: |
601      startsWith(github.ref, 'refs/tags/v')
602      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
603    needs: [linux_tests]
604    steps:
605      - name: Checkout repo
606        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
607        with:
608          clean: false
609
610      - name: Install Linux dependencies
611        run: ./script/linux && ./script/install-mold 2.34.0
612
613      - name: Determine version and release channel
614        if: startsWith(github.ref, 'refs/tags/v')
615        run: |
616          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
617          script/determine-release-channel
618
619      - name: Create Linux .tar.gz bundle
620        run: script/bundle-linux
621
622      - name: Upload Artifact to Workflow - zed (run-bundling)
623        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
624        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
625        with:
626          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.tar.gz
627          path: target/release/zed-*.tar.gz
628
629      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
630        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
631        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
632        with:
633          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-x86_64-unknown-linux-gnu.gz
634          path: target/zed-remote-server-linux-x86_64.gz
635
636      - name: Upload Artifacts to release
637        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
638        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
639        with:
640          draft: true
641          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
642          files: |
643            target/zed-remote-server-linux-x86_64.gz
644            target/release/zed-linux-x86_64.tar.gz
645        env:
646          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
647
648  bundle-linux-aarch64: # this runs on ubuntu22.04
649    timeout-minutes: 60
650    name: Linux arm64 release bundle
651    runs-on:
652      - buildjet-16vcpu-ubuntu-2204-arm
653    if: |
654      startsWith(github.ref, 'refs/tags/v')
655      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
656    needs: [linux_tests]
657    steps:
658      - name: Checkout repo
659        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
660        with:
661          clean: false
662
663      - name: Install Linux dependencies
664        run: ./script/linux
665
666      - name: Determine version and release channel
667        if: startsWith(github.ref, 'refs/tags/v')
668        run: |
669          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
670          script/determine-release-channel
671
672      - name: Create and upload Linux .tar.gz bundles
673        run: script/bundle-linux
674
675      - name: Upload Artifact to Workflow - zed (run-bundling)
676        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
677        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
678        with:
679          name: zed-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.tar.gz
680          path: target/release/zed-*.tar.gz
681
682      - name: Upload Artifact to Workflow - zed-remote-server (run-bundling)
683        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
684        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
685        with:
686          name: zed-remote-server-${{ github.event.pull_request.head.sha || github.sha }}-aarch64-unknown-linux-gnu.gz
687          path: target/zed-remote-server-linux-aarch64.gz
688
689      - name: Upload Artifacts to release
690        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
691        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) }}
692        with:
693          draft: true
694          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
695          files: |
696            target/zed-remote-server-linux-aarch64.gz
697            target/release/zed-linux-aarch64.tar.gz
698        env:
699          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
700
701  freebsd:
702    timeout-minutes: 60
703    runs-on: github-8vcpu-ubuntu-2404
704    if: |
705      false && (
706      startsWith(github.ref, 'refs/tags/v')
707      || contains(github.event.pull_request.labels.*.name, 'run-bundling')
708      )
709    needs: [linux_tests]
710    name: Build Zed on FreeBSD
711    steps:
712      - uses: actions/checkout@v4
713      - name: Build FreeBSD remote-server
714        id: freebsd-build
715        uses: vmactions/freebsd-vm@c3ae29a132c8ef1924775414107a97cac042aad5 # v1.2.0
716        with:
717          usesh: true
718          release: 13.5
719          copyback: true
720          prepare: |
721            pkg install -y \
722              bash curl jq git \
723              rustup-init cmake-core llvm-devel-lite pkgconf protobuf # ibx11 alsa-lib rust-bindgen-cli
724          run: |
725            freebsd-version
726            sysctl hw.model
727            sysctl hw.ncpu
728            sysctl hw.physmem
729            sysctl hw.usermem
730            git config --global --add safe.directory /home/runner/work/zed/zed
731            rustup-init --profile minimal --default-toolchain none -y
732            . "$HOME/.cargo/env"
733            ./script/bundle-freebsd
734            mkdir -p out/
735            mv "target/zed-remote-server-freebsd-x86_64.gz" out/
736            rm -rf target/
737            cargo clean
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 }}-x86_64-unknown-freebsd.gz
744          path: out/zed-remote-server-freebsd-x86_64.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            out/zed-remote-server-freebsd-x86_64.gz
754        env:
755          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
756
757  nix-build:
758    name: Build with Nix
759    uses: ./.github/workflows/nix.yml
760    needs: [job_spec]
761    if: github.repository_owner == 'zed-industries' &&
762      (contains(github.event.pull_request.labels.*.name, 'run-nix') ||
763      needs.job_spec.outputs.run_nix == 'true')
764    secrets: inherit
765    with:
766      flake-output: debug
767      # excludes the final package to only cache dependencies
768      cachix-filter: "-zed-editor-[0-9.]*-nightly"
769
770  bundle-windows-x64:
771    timeout-minutes: 120
772    name: Create a Windows installer
773    runs-on: [self-hosted, Windows, X64]
774    if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
775    # if: (startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling'))
776    needs: [windows_tests]
777    env:
778      AZURE_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
779      AZURE_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
780      AZURE_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
781      ACCOUNT_NAME: ${{ vars.AZURE_SIGNING_ACCOUNT_NAME }}
782      CERT_PROFILE_NAME: ${{ vars.AZURE_SIGNING_CERT_PROFILE_NAME }}
783      ENDPOINT: ${{ vars.AZURE_SIGNING_ENDPOINT }}
784      FILE_DIGEST: SHA256
785      TIMESTAMP_DIGEST: SHA256
786      TIMESTAMP_SERVER: "http://timestamp.acs.microsoft.com"
787    steps:
788      - name: Checkout repo
789        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
790        with:
791          clean: false
792
793      - name: Determine version and release channel
794        working-directory: ${{ env.ZED_WORKSPACE }}
795        if: ${{ startsWith(github.ref, 'refs/tags/v') }}
796        run: |
797          # This exports RELEASE_CHANNEL into env (GITHUB_ENV)
798          script/determine-release-channel.ps1
799
800      - name: Build Zed installer
801        working-directory: ${{ env.ZED_WORKSPACE }}
802        run: script/bundle-windows.ps1
803
804      - name: Upload installer (x86_64) to Workflow - zed (run-bundling)
805        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
806        if: contains(github.event.pull_request.labels.*.name, 'run-bundling')
807        with:
808          name: ZedEditorUserSetup-x64-${{ github.event.pull_request.head.sha || github.sha }}.exe
809          path: ${{ env.SETUP_PATH }}
810
811      - name: Upload Artifacts to release
812        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
813        # Re-enable when we are ready to publish windows preview releases
814        if: ${{ !(contains(github.event.pull_request.labels.*.name, 'run-bundling')) && env.RELEASE_CHANNEL == 'preview' }} # upload only preview
815        with:
816          draft: true
817          prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }}
818          files: ${{ env.SETUP_PATH }}
819        env:
820          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
821
822  auto-release-preview:
823    name: Auto release preview
824    if: |
825      startsWith(github.ref, 'refs/tags/v')
826      && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')
827    needs: [bundle-mac, bundle-linux-x86_x64, bundle-linux-aarch64, bundle-windows-x64]
828    runs-on:
829      - self-mini-macos
830    steps:
831      - name: gh release
832        run: gh release edit "$GITHUB_REF_NAME" --draft=false
833        env:
834          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}