# Generated from xtask::workflows::release
# Rebuild with `cargo xtask workflows`.
name: release
env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: '1'
on:
  push:
    tags:
    - v*
jobs:
  run_tests_mac:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: namespace-profile-mac-large
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_cargo_config
      run: |
        mkdir -p ./../.cargo
        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
    - name: steps::cache_rust_dependencies_namespace
      uses: namespacelabs/nscloud-cache-action@v1
      with:
        cache: rust
        path: ~/.rustup
    - name: steps::setup_node
      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
      with:
        node-version: '20'
    - name: steps::cargo_install_nextest
      uses: taiki-e/install-action@nextest
    - name: steps::clear_target_dir_if_large
      run: ./script/clear-target-dir-if-larger-than 300
    - name: steps::cargo_nextest
      run: cargo nextest run --workspace --no-fail-fast
    - name: steps::cleanup_cargo_config
      if: always()
      run: |
        rm -rf ./../.cargo
    timeout-minutes: 60
  run_tests_linux:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: namespace-profile-16x32-ubuntu-2204
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_cargo_config
      run: |
        mkdir -p ./../.cargo
        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
    - name: steps::cache_rust_dependencies_namespace
      uses: namespacelabs/nscloud-cache-action@v1
      with:
        cache: rust
        path: ~/.rustup
    - name: steps::setup_linux
      run: ./script/linux
    - name: steps::install_mold
      run: ./script/install-mold
    - name: steps::download_wasi_sdk
      run: ./script/download-wasi-sdk
    - name: steps::setup_node
      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
      with:
        node-version: '20'
    - name: steps::cargo_install_nextest
      uses: taiki-e/install-action@nextest
    - name: steps::clear_target_dir_if_large
      run: ./script/clear-target-dir-if-larger-than 250
    - name: steps::cargo_nextest
      run: cargo nextest run --workspace --no-fail-fast
    - name: steps::cleanup_cargo_config
      if: always()
      run: |
        rm -rf ./../.cargo
    timeout-minutes: 60
    services:
      postgres:
        image: postgres:15
        env:
          POSTGRES_HOST_AUTH_METHOD: trust
        ports:
        - 5432:5432
        options: --health-cmd pg_isready --health-interval 500ms --health-timeout 5s --health-retries 10
  run_tests_windows:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: self-32vcpu-windows-2022
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_cargo_config
      run: |
        New-Item -ItemType Directory -Path "./../.cargo" -Force
        Copy-Item -Path "./.cargo/ci-config.toml" -Destination "./../.cargo/config.toml"
      shell: pwsh
    - name: steps::setup_node
      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
      with:
        node-version: '20'
    - name: steps::clear_target_dir_if_large
      run: ./script/clear-target-dir-if-larger-than.ps1 250
      shell: pwsh
    - name: steps::cargo_nextest
      run: cargo nextest run --workspace --no-fail-fast
      shell: pwsh
    - name: steps::cleanup_cargo_config
      if: always()
      run: |
        Remove-Item -Recurse -Path "./../.cargo" -Force -ErrorAction SilentlyContinue
      shell: pwsh
    timeout-minutes: 60
  clippy_mac:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: namespace-profile-mac-large
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_cargo_config
      run: |
        mkdir -p ./../.cargo
        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
    - name: steps::cache_rust_dependencies_namespace
      uses: namespacelabs/nscloud-cache-action@v1
      with:
        cache: rust
        path: ~/.rustup
    - name: steps::clippy
      run: ./script/clippy
    timeout-minutes: 60
  clippy_linux:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: namespace-profile-16x32-ubuntu-2204
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_cargo_config
      run: |
        mkdir -p ./../.cargo
        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
    - name: steps::cache_rust_dependencies_namespace
      uses: namespacelabs/nscloud-cache-action@v1
      with:
        cache: rust
        path: ~/.rustup
    - name: steps::setup_linux
      run: ./script/linux
    - name: steps::install_mold
      run: ./script/install-mold
    - name: steps::download_wasi_sdk
      run: ./script/download-wasi-sdk
    - name: steps::clippy
      run: ./script/clippy
    timeout-minutes: 60
  clippy_windows:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: self-32vcpu-windows-2022
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_cargo_config
      run: |
        New-Item -ItemType Directory -Path "./../.cargo" -Force
        Copy-Item -Path "./.cargo/ci-config.toml" -Destination "./../.cargo/config.toml"
      shell: pwsh
    - name: steps::clippy
      run: ./script/clippy.ps1
      shell: pwsh
    timeout-minutes: 60
  check_scripts:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: namespace-profile-2x4-ubuntu-2404
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: run_tests::check_scripts::run_shellcheck
      run: ./script/shellcheck-scripts error
    - id: get_actionlint
      name: run_tests::check_scripts::download_actionlint
      run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
    - name: run_tests::check_scripts::run_actionlint
      run: |
        ${{ steps.get_actionlint.outputs.executable }} -color
    - name: run_tests::check_scripts::check_xtask_workflows
      run: |
        cargo xtask workflows
        if ! git diff --exit-code .github; then
          echo "Error: .github directory has uncommitted changes after running 'cargo xtask workflows'"
          echo "Please run 'cargo xtask workflows' locally and commit the changes"
          exit 1
        fi
    timeout-minutes: 60
  create_draft_release:
    if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
    runs-on: namespace-profile-2x4-ubuntu-2404
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
        fetch-depth: 25
        ref: ${{ github.ref }}
    - name: script/determine-release-channel
      run: script/determine-release-channel
    - name: mkdir -p target/
      run: mkdir -p target/
    - name: release::create_draft_release::generate_release_notes
      run: node --redirect-warnings=/dev/null ./script/draft-release-notes "$RELEASE_VERSION" "$RELEASE_CHANNEL" > target/release-notes.md
    - name: release::create_draft_release::create_release
      run: script/create-draft-release target/release-notes.md
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    timeout-minutes: 60
  bundle_linux_aarch64:
    needs:
    - run_tests_linux
    - clippy_linux
    - check_scripts
    runs-on: namespace-profile-8x32-ubuntu-2004-arm-m4
    env:
      CARGO_INCREMENTAL: 0
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_sentry
      uses: matbour/setup-sentry-cli@3e938c54b3018bdd019973689ef984e033b0454b
      with:
        token: ${{ secrets.SENTRY_AUTH_TOKEN }}
    - name: steps::setup_linux
      run: ./script/linux
    - name: steps::install_mold
      run: ./script/install-mold
    - name: steps::download_wasi_sdk
      run: ./script/download-wasi-sdk
    - name: ./script/bundle-linux
      run: ./script/bundle-linux
    - name: '@actions/upload-artifact zed-linux-aarch64.tar.gz'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-linux-aarch64.tar.gz
        path: target/release/zed-linux-aarch64.tar.gz
        if-no-files-found: error
    - name: '@actions/upload-artifact zed-remote-server-linux-aarch64.gz'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-remote-server-linux-aarch64.gz
        path: target/zed-remote-server-linux-aarch64.gz
        if-no-files-found: error
    timeout-minutes: 60
  bundle_linux_x86_64:
    needs:
    - run_tests_linux
    - clippy_linux
    - check_scripts
    runs-on: namespace-profile-32x64-ubuntu-2004
    env:
      CARGO_INCREMENTAL: 0
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_sentry
      uses: matbour/setup-sentry-cli@3e938c54b3018bdd019973689ef984e033b0454b
      with:
        token: ${{ secrets.SENTRY_AUTH_TOKEN }}
    - name: steps::setup_linux
      run: ./script/linux
    - name: steps::install_mold
      run: ./script/install-mold
    - name: steps::download_wasi_sdk
      run: ./script/download-wasi-sdk
    - name: ./script/bundle-linux
      run: ./script/bundle-linux
    - name: '@actions/upload-artifact zed-linux-x86_64.tar.gz'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-linux-x86_64.tar.gz
        path: target/release/zed-linux-x86_64.tar.gz
        if-no-files-found: error
    - name: '@actions/upload-artifact zed-remote-server-linux-x86_64.gz'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-remote-server-linux-x86_64.gz
        path: target/zed-remote-server-linux-x86_64.gz
        if-no-files-found: error
    timeout-minutes: 60
  bundle_mac_aarch64:
    needs:
    - run_tests_mac
    - clippy_mac
    - check_scripts
    runs-on: namespace-profile-mac-large
    env:
      CARGO_INCREMENTAL: 0
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
      APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
      APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
      APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_node
      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
      with:
        node-version: '20'
    - name: steps::setup_sentry
      uses: matbour/setup-sentry-cli@3e938c54b3018bdd019973689ef984e033b0454b
      with:
        token: ${{ secrets.SENTRY_AUTH_TOKEN }}
    - name: steps::clear_target_dir_if_large
      run: ./script/clear-target-dir-if-larger-than 300
    - name: run_bundling::bundle_mac::bundle_mac
      run: ./script/bundle-mac aarch64-apple-darwin
    - name: '@actions/upload-artifact Zed-aarch64.dmg'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: Zed-aarch64.dmg
        path: target/aarch64-apple-darwin/release/Zed-aarch64.dmg
        if-no-files-found: error
    - name: '@actions/upload-artifact zed-remote-server-macos-aarch64.gz'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-remote-server-macos-aarch64.gz
        path: target/zed-remote-server-macos-aarch64.gz
        if-no-files-found: error
    timeout-minutes: 60
  bundle_mac_x86_64:
    needs:
    - run_tests_mac
    - clippy_mac
    - check_scripts
    runs-on: namespace-profile-mac-large
    env:
      CARGO_INCREMENTAL: 0
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
      MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
      MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
      APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
      APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
      APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_node
      uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
      with:
        node-version: '20'
    - name: steps::setup_sentry
      uses: matbour/setup-sentry-cli@3e938c54b3018bdd019973689ef984e033b0454b
      with:
        token: ${{ secrets.SENTRY_AUTH_TOKEN }}
    - name: steps::clear_target_dir_if_large
      run: ./script/clear-target-dir-if-larger-than 300
    - name: run_bundling::bundle_mac::bundle_mac
      run: ./script/bundle-mac x86_64-apple-darwin
    - name: '@actions/upload-artifact Zed-x86_64.dmg'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: Zed-x86_64.dmg
        path: target/x86_64-apple-darwin/release/Zed-x86_64.dmg
        if-no-files-found: error
    - name: '@actions/upload-artifact zed-remote-server-macos-x86_64.gz'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-remote-server-macos-x86_64.gz
        path: target/zed-remote-server-macos-x86_64.gz
        if-no-files-found: error
    timeout-minutes: 60
  bundle_windows_aarch64:
    needs:
    - run_tests_windows
    - clippy_windows
    - check_scripts
    runs-on: self-32vcpu-windows-2022
    env:
      CARGO_INCREMENTAL: 0
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
      AZURE_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
      AZURE_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
      AZURE_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
      ACCOUNT_NAME: ${{ vars.AZURE_SIGNING_ACCOUNT_NAME }}
      CERT_PROFILE_NAME: ${{ vars.AZURE_SIGNING_CERT_PROFILE_NAME }}
      ENDPOINT: ${{ vars.AZURE_SIGNING_ENDPOINT }}
      FILE_DIGEST: SHA256
      TIMESTAMP_DIGEST: SHA256
      TIMESTAMP_SERVER: http://timestamp.acs.microsoft.com
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_sentry
      uses: matbour/setup-sentry-cli@3e938c54b3018bdd019973689ef984e033b0454b
      with:
        token: ${{ secrets.SENTRY_AUTH_TOKEN }}
    - name: run_bundling::bundle_windows::bundle_windows
      run: script/bundle-windows.ps1 -Architecture aarch64
      shell: pwsh
      working-directory: ${{ env.ZED_WORKSPACE }}
    - name: '@actions/upload-artifact Zed-aarch64.exe'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: Zed-aarch64.exe
        path: target/Zed-aarch64.exe
        if-no-files-found: error
    - name: '@actions/upload-artifact zed-remote-server-windows-aarch64.zip'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-remote-server-windows-aarch64.zip
        path: target/zed-remote-server-windows-aarch64.zip
        if-no-files-found: error
    timeout-minutes: 60
  bundle_windows_x86_64:
    needs:
    - run_tests_windows
    - clippy_windows
    - check_scripts
    runs-on: self-32vcpu-windows-2022
    env:
      CARGO_INCREMENTAL: 0
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
      AZURE_TENANT_ID: ${{ secrets.AZURE_SIGNING_TENANT_ID }}
      AZURE_CLIENT_ID: ${{ secrets.AZURE_SIGNING_CLIENT_ID }}
      AZURE_CLIENT_SECRET: ${{ secrets.AZURE_SIGNING_CLIENT_SECRET }}
      ACCOUNT_NAME: ${{ vars.AZURE_SIGNING_ACCOUNT_NAME }}
      CERT_PROFILE_NAME: ${{ vars.AZURE_SIGNING_CERT_PROFILE_NAME }}
      ENDPOINT: ${{ vars.AZURE_SIGNING_ENDPOINT }}
      FILE_DIGEST: SHA256
      TIMESTAMP_DIGEST: SHA256
      TIMESTAMP_SERVER: http://timestamp.acs.microsoft.com
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: steps::setup_sentry
      uses: matbour/setup-sentry-cli@3e938c54b3018bdd019973689ef984e033b0454b
      with:
        token: ${{ secrets.SENTRY_AUTH_TOKEN }}
    - name: run_bundling::bundle_windows::bundle_windows
      run: script/bundle-windows.ps1 -Architecture x86_64
      shell: pwsh
      working-directory: ${{ env.ZED_WORKSPACE }}
    - name: '@actions/upload-artifact Zed-x86_64.exe'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: Zed-x86_64.exe
        path: target/Zed-x86_64.exe
        if-no-files-found: error
    - name: '@actions/upload-artifact zed-remote-server-windows-x86_64.zip'
      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
      with:
        name: zed-remote-server-windows-x86_64.zip
        path: target/zed-remote-server-windows-x86_64.zip
        if-no-files-found: error
    timeout-minutes: 60
  upload_release_assets:
    needs:
    - create_draft_release
    - bundle_linux_aarch64
    - bundle_linux_x86_64
    - bundle_mac_aarch64
    - bundle_mac_x86_64
    - bundle_windows_aarch64
    - bundle_windows_x86_64
    runs-on: namespace-profile-4x8-ubuntu-2204
    steps:
    - name: release::download_workflow_artifacts
      uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
      with:
        path: ./artifacts/
    - name: ls -lR ./artifacts
      run: ls -lR ./artifacts
    - name: release::prep_release_artifacts
      run: |-
        mkdir -p release-artifacts/

        mv ./artifacts/Zed-aarch64.dmg/Zed-aarch64.dmg release-artifacts/Zed-aarch64.dmg
        mv ./artifacts/Zed-x86_64.dmg/Zed-x86_64.dmg release-artifacts/Zed-x86_64.dmg
        mv ./artifacts/zed-linux-aarch64.tar.gz/zed-linux-aarch64.tar.gz release-artifacts/zed-linux-aarch64.tar.gz
        mv ./artifacts/zed-linux-x86_64.tar.gz/zed-linux-x86_64.tar.gz release-artifacts/zed-linux-x86_64.tar.gz
        mv ./artifacts/Zed-x86_64.exe/Zed-x86_64.exe release-artifacts/Zed-x86_64.exe
        mv ./artifacts/Zed-aarch64.exe/Zed-aarch64.exe release-artifacts/Zed-aarch64.exe
        mv ./artifacts/zed-remote-server-macos-aarch64.gz/zed-remote-server-macos-aarch64.gz release-artifacts/zed-remote-server-macos-aarch64.gz
        mv ./artifacts/zed-remote-server-macos-x86_64.gz/zed-remote-server-macos-x86_64.gz release-artifacts/zed-remote-server-macos-x86_64.gz
        mv ./artifacts/zed-remote-server-linux-aarch64.gz/zed-remote-server-linux-aarch64.gz release-artifacts/zed-remote-server-linux-aarch64.gz
        mv ./artifacts/zed-remote-server-linux-x86_64.gz/zed-remote-server-linux-x86_64.gz release-artifacts/zed-remote-server-linux-x86_64.gz
        mv ./artifacts/zed-remote-server-windows-aarch64.zip/zed-remote-server-windows-aarch64.zip release-artifacts/zed-remote-server-windows-aarch64.zip
        mv ./artifacts/zed-remote-server-windows-x86_64.zip/zed-remote-server-windows-x86_64.zip release-artifacts/zed-remote-server-windows-x86_64.zip
    - name: gh release upload "$GITHUB_REF_NAME" --repo=zed-industries/zed release-artifacts/*
      run: gh release upload "$GITHUB_REF_NAME" --repo=zed-industries/zed release-artifacts/*
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  validate_release_assets:
    needs:
    - upload_release_assets
    runs-on: namespace-profile-2x4-ubuntu-2404
    steps:
    - name: release::validate_release_assets
      run: |
        EXPECTED_ASSETS='["Zed-aarch64.dmg", "Zed-x86_64.dmg", "zed-linux-aarch64.tar.gz", "zed-linux-x86_64.tar.gz", "Zed-x86_64.exe", "Zed-aarch64.exe", "zed-remote-server-macos-aarch64.gz", "zed-remote-server-macos-x86_64.gz", "zed-remote-server-linux-aarch64.gz", "zed-remote-server-linux-x86_64.gz", "zed-remote-server-windows-aarch64.zip", "zed-remote-server-windows-x86_64.zip"]'
        TAG="$GITHUB_REF_NAME"

        ACTUAL_ASSETS=$(gh release view "$TAG" --repo=zed-industries/zed --json assets -q '[.assets[].name]')

        MISSING_ASSETS=$(echo "$EXPECTED_ASSETS" | jq -r --argjson actual "$ACTUAL_ASSETS" '. - $actual | .[]')

        if [ -n "$MISSING_ASSETS" ]; then
            echo "Error: The following assets are missing from the release:"
            echo "$MISSING_ASSETS"
            exit 1
        fi

        echo "All expected assets are present in the release."
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  auto_release_preview:
    needs:
    - validate_release_assets
    if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-pre') && !endsWith(github.ref, '.0-pre')
    runs-on: namespace-profile-2x4-ubuntu-2404
    steps:
    - id: get-app-token
      name: steps::authenticate_as_zippy
      uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1
      with:
        app-id: ${{ secrets.ZED_ZIPPY_APP_ID }}
        private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }}
    - name: gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false
      run: gh release edit "$GITHUB_REF_NAME" --repo=zed-industries/zed --draft=false
      env:
        GITHUB_TOKEN: ${{ steps.get-app-token.outputs.token }}
  push_release_update_notification:
    needs:
    - create_draft_release
    - upload_release_assets
    - validate_release_assets
    - auto_release_preview
    if: always()
    runs-on: namespace-profile-2x4-ubuntu-2404
    steps:
    - id: generate-webhook-message
      name: release::generate_slack_message
      run: |
        MESSAGE=$(DRAFT_RESULT="${{ needs.create_draft_release.result }}"
        UPLOAD_RESULT="${{ needs.upload_release_assets.result }}"
        VALIDATE_RESULT="${{ needs.validate_release_assets.result }}"
        AUTO_RELEASE_RESULT="${{ needs.auto_release_preview.result }}"
        TAG="$GITHUB_REF_NAME"
        RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

        if [ "$DRAFT_RESULT" == "failure" ]; then
            echo "❌ Draft release creation failed for $TAG: $RUN_URL"
        else
            RELEASE_URL=$(gh release view "$TAG" --repo=zed-industries/zed --json url -q '.url')
            if [ "$UPLOAD_RESULT" == "failure" ]; then
                echo "❌ Release asset upload failed for $TAG: $RELEASE_URL"
            elif [ "$VALIDATE_RESULT" == "failure" ]; then
                echo "❌ Release asset validation failed for $TAG (missing assets): $RUN_URL"
            elif [ "$AUTO_RELEASE_RESULT" == "success" ]; then
                echo "✅ Release $TAG was auto-released successfully: $RELEASE_URL"
            elif [ "$AUTO_RELEASE_RESULT" == "failure" ]; then
                echo "❌ Auto release failed for $TAG: $RUN_URL"
            else
                echo "👀 Release $TAG sitting freshly baked in the oven and waiting to be published: $RELEASE_URL"
            fi
        fi
        )
        echo "message=$MESSAGE" >> "$GITHUB_OUTPUT"
      env:
        GH_TOKEN: ${{ github.token }}
    - name: release::send_slack_message
      run: |
        curl -X POST -H 'Content-type: application/json'\
         --data '{"text":"${{ steps.generate-webhook-message.outputs.message }}"}' "$SLACK_WEBHOOK"
      env:
        SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_WORKFLOW_FAILURES }}
concurrency:
  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
  cancel-in-progress: true
defaults:
  run:
    shell: bash -euxo pipefail {0}
