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