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