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