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