diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fac8924863..9b1657f1d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,12 +152,12 @@ jobs: - name: Build Zed run: cargo build -p zed - bundle: - name: Bundle macOS app + bundle-mac: + name: Create a macOS bundle runs-on: - self-hosted - bundle - if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }} + if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }} needs: [macos_tests] env: MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} @@ -212,12 +212,12 @@ jobs: - name: Generate license file run: script/generate-licenses - - name: Create app bundle - run: script/bundle + - name: Create macOS app bundle + run: script/bundle-mac - name: Upload app bundle to workflow run if main branch or specific label - uses: actions/upload-artifact@v3 - if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-build-dmg') }} + uses: actions/upload-artifact@v4 + if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }} with: name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.dmg path: target/release/Zed.dmg @@ -232,3 +232,81 @@ jobs: body: "" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + bundle-deb: + name: Create a *.deb Linux bundle + runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues + if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }} + needs: [linux_tests] + env: + ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }} + DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }} + DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + clean: false + submodules: "recursive" + + - name: Cache dependencies + uses: swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} + + - name: Configure linux + shell: bash -euxo pipefail {0} + run: script/linux + + - name: Determine version and release channel + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + set -eu + + version=$(script/get-crate-version zed) + channel=$(cat crates/zed/RELEASE_CHANNEL) + echo "Publishing version: ${version} on release channel ${channel}" + echo "RELEASE_CHANNEL=${channel}" >> $GITHUB_ENV + + expected_tag_name="" + case ${channel} in + stable) + expected_tag_name="v${version}";; + preview) + expected_tag_name="v${version}-pre";; + nightly) + expected_tag_name="v${version}-nightly";; + *) + echo "can't publish a release on channel ${channel}" + exit 1;; + esac + if [[ $GITHUB_REF_NAME != $expected_tag_name ]]; then + echo "invalid release tag ${GITHUB_REF_NAME}. expected ${expected_tag_name}" + exit 1 + fi + + # TODO linux : Find a way to add licenses to the final bundle + # - name: Generate license file + # run: script/generate-licenses + + - name: Create Linux *.deb bundle + run: script/bundle-linux + + - name: Upload app bundle to workflow run if main branch or specific label + uses: actions/upload-artifact@v4 + if: ${{ github.ref == 'refs/heads/main' }} || contains(github.event.pull_request.labels.*.name, 'run-bundling') }} + with: + name: Zed_${{ github.event.pull_request.head.sha || github.sha }}.deb + path: target/release/*.deb + + # TODO linux : make it stable enough to be uploaded as a release + # - uses: softprops/action-gh-release@v1 + # name: Upload app bundle to release + # if: ${{ env.RELEASE_CHANNEL == 'preview' || env.RELEASE_CHANNEL == 'stable' }} + # with: + # draft: true + # prerelease: ${{ env.RELEASE_CHANNEL == 'preview' }} + # files: target/release/Zed.dmg + # body: "" + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index 6e34e859b5..5a625c448a 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -50,8 +50,8 @@ jobs: - name: Run tests uses: ./.github/actions/run_tests - bundle: - name: Bundle app + bundle-mac: + name: Create a macOS bundle if: github.repository_owner == 'zed-industries' runs-on: - self-hosted @@ -77,9 +77,6 @@ jobs: clean: false submodules: "recursive" - - name: Limit target directory size - run: script/clear-target-dir-if-larger-than 100 - - name: Set release channel to nightly run: | set -eu @@ -90,8 +87,50 @@ jobs: - name: Generate license file run: script/generate-licenses - - name: Create app bundle - run: script/bundle + - name: Create macOS app bundle + run: script/bundle-mac - name: Upload Zed Nightly - run: script/upload-nightly + run: script/upload-nightly macos + + bundle-deb: + name: Create a *.deb Linux bundle + if: github.repository_owner == 'zed-industries' + runs-on: ubuntu-22.04 # keep the version fixed to avoid libc and dynamic linked library issues + needs: tests + env: + DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }} + DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }} + ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + clean: false + submodules: "recursive" + + - name: Cache dependencies + uses: swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} + + - name: Configure linux + shell: bash -euxo pipefail {0} + run: script/linux + + - name: Set release channel to nightly + run: | + set -euo pipefail + version=$(git rev-parse --short HEAD) + echo "Publishing version: ${version} on release channel nightly" + echo "nightly" > crates/zed/RELEASE_CHANNEL + + # TODO linux : find a way to add licenses to the final bundle + # - name: Generate license file + # run: script/generate-licenses + + - name: Create Linux *.deb bundle + run: script/bundle-linux + + - name: Upload Zed Nightly + run: script/upload-nightly linux-deb diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index 2a7b8bfb2e..c19cc72451 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/crates/gpui/src/platform/linux/platform.rs @@ -324,7 +324,7 @@ impl Platform for LinuxPlatform { }) } - //todo!(linux) + //TODO linux fn app_path(&self) -> Result { Err(anyhow::Error::msg( "Platform::app_path is not implemented yet", @@ -338,7 +338,7 @@ impl Platform for LinuxPlatform { UtcOffset::UTC } - //todo!(linux) + //TODO linux fn path_for_auxiliary_executable(&self, name: &str) -> Result { Err(anyhow::Error::msg( "Platform::path_for_auxiliary_executable is not implemented yet", @@ -390,7 +390,7 @@ impl Platform for LinuxPlatform { }) } - //todo!(linux): add trait methods for accessing the primary selection + //TODO linux: add trait methods for accessing the primary selection fn read_credentials(&self, url: &str) -> Task)>>> { let url = url.to_string(); diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 123a6e5f9b..637e30dc00 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -281,7 +281,7 @@ impl Client for WaylandClient { CursorStyle::ResizeUp => "n-resize".to_string(), CursorStyle::ResizeDown => "s-resize".to_string(), CursorStyle::ResizeUpDown => "ns-resize".to_string(), - CursorStyle::DisappearingItem => "grabbing".to_string(), // todo!(linux) - couldn't find equivalent icon in linux + CursorStyle::DisappearingItem => "grabbing".to_string(), // TODO linux - couldn't find equivalent icon in linux CursorStyle::IBeamCursorForVerticalLayout => "vertical-text".to_string(), CursorStyle::OperationNotAllowed => "not-allowed".to_string(), CursorStyle::DragLink => "dnd-link".to_string(), diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 53fbc8747f..f50d3fd6ea 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -361,7 +361,7 @@ impl Client for X11Client { Box::new(X11Window(window_ptr)) } - //todo!(linux) + // TODO linux fn set_cursor_style(&self, _style: CursorStyle) {} fn get_clipboard(&self) -> Rc> { diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 8fc02db412..b46dd7f1bd 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -5,6 +5,7 @@ name = "zed" version = "0.127.0" publish = false license = "GPL-3.0-or-later" +authors = ["Zed Team "] [lints] workspace = true diff --git a/script/bundle-linux b/script/bundle-linux new file mode 100755 index 0000000000..6f964b7a0b --- /dev/null +++ b/script/bundle-linux @@ -0,0 +1,106 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +build_flag="--release" +target_dir="release" +bundle_name="" +zed_crate="zed" + + +help_info() { + echo " +Usage: ${0##*/} [options] [bundle_name] +Build the application bundle for Linux. + +Options: + -d Compile in debug mode + -h Display this help and exit + " +} + +while getopts 'dh' flag +do + case "${flag}" in + d) + export CARGO_INCREMENTAL=true + export CARGO_BUNDLE_SKIP_BUILD=true + build_flag=""; + target_dir="debug" + ;; + h) + help_info + exit 0 + ;; + esac +done + +shift $((OPTIND-1)) + +if [[ $# -gt 0 ]]; then + if [ "$1" ]; then + bundle_name=$1 + fi +fi + +export ZED_BUNDLE=true + +cargo_bundle_version=$(cargo -q bundle --help 2>&1 | head -n 1 || echo "") +if [ "$cargo_bundle_version" != "cargo-bundle v0.6.0-zed" ]; then + cargo install cargo-bundle --git https://github.com/zed-industries/cargo-bundle.git --branch zed-deploy +fi + +echo "Compiling zed binaries" +cargo build ${build_flag} --package ${zed_crate} --package cli + +echo "Creating application bundle" +# TODO linux +# Here, hacks to make `cargo bundle` run work, but macOS does not need these +# Most probably, needs https://github.com/zed-industries/cargo-bundle/commit/9e185bd44d968d8039192220603494555afdbb4f from the upstream. +cp "target/${target_dir}/Zed" "target/${target_dir}/zed" +pushd crates/${zed_crate} + channel=$(/dev/null || true + dpkg-deb -x "${bundle_path}" bundle/ + dpkg-deb --control "${bundle_path}" bundle/DEBIAN + mkdir -p bundle/usr/local/bin/ + mv bundle/usr/bin/zed "bundle/usr/local/bin/zed-$channel" + cp "${target_dir}/cli" "bundle/usr/local/bin/cli-$channel" + ln -s "/usr/local/bin/cli-$channel" "bundle/usr/local/bin/zed" + rm -rf bundle/usr/bin/ + dpkg-deb -b bundle/ "${target_dir}/${bundle_name}" + bundle_path="${PWD}/${target_dir}/${bundle_name}" +popd +echo "Bundled ${bundle_path}" diff --git a/script/bundle b/script/bundle-mac similarity index 97% rename from script/bundle rename to script/bundle-mac index d90ed2a014..863c1960c3 100755 --- a/script/bundle +++ b/script/bundle-mac @@ -1,6 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash -set -e +set -euxo pipefail build_flag="--release" target_dir="release" @@ -19,7 +19,7 @@ APPLE_NOTORIZATION_TEAM="MQ55VZLNZQ" help_info() { echo " Usage: ${0##*/} [options] [bundle_name] -Build the application bundle. +Build the application bundle for macOS. Options: -d Compile in debug mode @@ -81,8 +81,10 @@ done shift $((OPTIND-1)) -if [ "$1" ]; then - bundle_name=$1 +if [[ $# -gt 0 ]]; then + if [ "$1" ]; then + bundle_name=$1 + fi fi export ZED_BUNDLE=true @@ -93,8 +95,6 @@ if [ "$cargo_bundle_version" != "cargo-bundle v0.6.0-zed" ]; then cargo install cargo-bundle --git https://github.com/zed-industries/cargo-bundle.git --branch zed-deploy fi -rustup target add wasm32-wasi - # Deal with versions of macOS that don't include libstdc++ headers export CXXFLAGS="-stdlib=libc++" @@ -208,7 +208,7 @@ else echo "====== WARNING ======" # NOTE: if you need to test universal links you have a few paths forward: - # - create a PR and tag it with the `run-build-dmg` label, and download the .dmg file from there. + # - create a PR and tag it with the `run-bundling` label, and download the .dmg file from there. # - get a signing key for the MQ55VZLNZQ team from Nathan. # - create your own signing key, and update references to MQ55VZLNZQ to your own team ID # then comment out this line. diff --git a/script/upload-nightly b/script/upload-nightly index f03b2f7fd8..ba36961994 100755 --- a/script/upload-nightly +++ b/script/upload-nightly @@ -1,7 +1,32 @@ -#!/bin/bash +#!/usr/bin/env bash # Based on the template in: https://docs.digitalocean.com/reference/api/spaces-api/ -set -ux +bash -euo pipefail + +allowed_targets=("linux-deb" "macos") +is_allowed_target() { + for val in "${allowed_targets[@]}"; do + if [[ "$1" == "$val" ]]; then + return 0 + fi + done + return 1 +} + +if [[ -n "${1:-}" ]]; then + if is_allowed_target "$1"; then + target="$1" + else + echo "Error: Target '$1' is not allowed" + echo "Usage: $0 [${allowed_targets[@]}]" + exit 1 + fi +else +echo "Error: Target is not specified" +echo "Usage: $0 [${allowed_targets[@]}]" +exit 1 +fi +echo "Uploading nightly for target: $target" # Step 1: Define the parameters for the Space you want to upload to. SPACE="zed-nightly-host" # Find your endpoint in the control panel, under Settings. @@ -32,6 +57,19 @@ function uploadToSpaces sha=$(git rev-parse HEAD) echo ${sha} > target/latest-sha - -uploadToSpaces "target/release/Zed.dmg" "Zed.dmg" -uploadToSpaces "target/latest-sha" "latest-sha" +case "$target" in + macos) + uploadToSpaces "target/release/Zed.dmg" "Zed.dmg" + uploadToSpaces "target/latest-sha" "latest-sha" + ;; + linux-deb) + find target/release -type f -name "*.deb" -print0 | while IFS= read -r -d '' bundle_file; do + uploadToSpaces "$bundle_file" "$(basename "$bundle_file")" + done + uploadToSpaces "target/latest-sha" "latest-sha-linux-deb" + ;; + *) + echo "Error: Unknown target '$target'" + exit 1 + ;; +esac