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