Add official Snap package for Linux (#66941)

## Summary

Closes #9922

Requires https://github.com/canonical/snapcraft/pull/6511. _Mostly_
reviewable but I am still doing QA.

The GHA pipeline is a proposal. Snap gets released to the `edge` risk on
every `main` commit, then any revision can be manually promoted to other
risks, including `stable`.

## Testing

```
snapcraft pack -v
sudo snap install ./zed...snap --dangerous --classic
```

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [ ] Tests cover the new or changed behavior.

Release Notes:

- Added an official Snap package for Linux

---------

Co-authored-by: Neel <neel@zed.dev>
This commit is contained in:
Juan Luis Cano Rodríguez
2026-11-18 17:12:40 +00:00
committed by GitHub
parent b840e80bf2
commit 8c514d28ed
11 changed files with 331 additions and 32 deletions
+42
View File
@@ -119,6 +119,46 @@ jobs:
release-tag: ${{ env.TAG_NAME }}
max-versions-to-keep: 5
token: ${{ secrets.WINGET_TOKEN }}
publish_snap_x86_64:
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
runs-on: ubuntu-24.04
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
clean: false
ref: ${{ env.TAG_NAME }}
- name: after_release::publish_snap::download_release_tarball
run: gh release download "$TAG_NAME" --repo="$GITHUB_REPOSITORY" --pattern="zed-linux-x86_64.tar.gz" --dir=target/release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: release::publish_snap::setup_snapcraft
uses: canonical/craft-actions/snapcraft/setup@d2add174925f9bca7b0a826010c8e1ce2a4bbc3d
- name: ./script/snap-build --publish
run: ./script/snap-build --publish
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
timeout-minutes: 60
publish_snap_aarch64:
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
runs-on: ubuntu-24.04-arm
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
clean: false
ref: ${{ env.TAG_NAME }}
- name: after_release::publish_snap::download_release_tarball
run: gh release download "$TAG_NAME" --repo="$GITHUB_REPOSITORY" --pattern="zed-linux-aarch64.tar.gz" --dir=target/release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: release::publish_snap::setup_snapcraft
uses: canonical/craft-actions/snapcraft/setup@d2add174925f9bca7b0a826010c8e1ce2a4bbc3d
- name: ./script/snap-build --publish
run: ./script/snap-build --publish
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
timeout-minutes: 60
create_sentry_release:
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
runs-on: namespace-profile-2x4-ubuntu-2404
@@ -140,6 +180,8 @@ jobs:
- rebuild_releases_page
- post_to_discord
- publish_winget
- publish_snap_x86_64
- publish_snap_aarch64
- create_sentry_release
- deploy_docs
if: failure()
+58
View File
@@ -661,6 +661,62 @@ jobs:
SENTRY_PROJECT: zed
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
timeout-minutes: 60
publish_snap_x86_64:
needs:
- update_nightly_tag
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
runs-on: ubuntu-24.04
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
clean: false
- name: run_bundling::set_release_channel_to_nightly
run: |
set -eu
version=$(git rev-parse --short HEAD)
echo "Publishing version: ${version} on release channel nightly"
echo "nightly" > crates/zed/RELEASE_CHANNEL
- name: release_nightly::release_nightly::download_nightly_tarball
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: zed-linux-x86_64.tar.gz
path: target/release
- name: release::publish_snap::setup_snapcraft
uses: canonical/craft-actions/snapcraft/setup@d2add174925f9bca7b0a826010c8e1ce2a4bbc3d
- name: ./script/snap-build --publish
run: ./script/snap-build --publish
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
timeout-minutes: 60
publish_snap_aarch64:
needs:
- update_nightly_tag
if: (github.repository_owner == 'zed-industries' || github.repository_owner == 'zed-extensions')
runs-on: ubuntu-24.04-arm
steps:
- name: steps::checkout_repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
clean: false
- name: run_bundling::set_release_channel_to_nightly
run: |
set -eu
version=$(git rev-parse --short HEAD)
echo "Publishing version: ${version} on release channel nightly"
echo "nightly" > crates/zed/RELEASE_CHANNEL
- name: release_nightly::release_nightly::download_nightly_tarball
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: zed-linux-aarch64.tar.gz
path: target/release
- name: release::publish_snap::setup_snapcraft
uses: canonical/craft-actions/snapcraft/setup@d2add174925f9bca7b0a826010c8e1ce2a4bbc3d
- name: ./script/snap-build --publish
run: ./script/snap-build --publish
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
timeout-minutes: 60
notify_on_failure:
needs:
- bundle_linux_aarch64
@@ -671,6 +727,8 @@ jobs:
- bundle_mac_x86_64
- bundle_windows_aarch64
- bundle_windows_x86_64
- publish_snap_x86_64
- publish_snap_aarch64
if: failure()
runs-on: namespace-profile-2x4-ubuntu-2404
steps:
+42 -5
View File
@@ -1,12 +1,12 @@
name: zed
title: Zed
base: core24
base: core26
version: "$RELEASE_VERSION"
summary: The editor for what's next
description: |
Zed is a modern open-source code editor, built from the ground up in Rust with
a GPU-accelerated renderer. We help you build software faster than ever before.
grade: stable
grade: "$SNAP_GRADE"
confinement: classic
compression: lzo
website: https://zed.dev/
@@ -17,12 +17,16 @@ contact: https://zed.dev/community-links#support-and-feedback
parts:
zed:
plugin: dump
source: "https://github.com/zed-industries/zed/releases/download/v$RELEASE_VERSION/zed-linux-x86_64.tar.gz"
source: "$ZED_TARBALL"
organize:
# These renames seem to not be necessary, but it's tidier.
bin: usr/bin
libexec: usr/libexec
# snapcraft's desktop-file lint resolves a bare Icon=zed against the
# hicolor theme only under usr/share/icons, so move the tarball's
# icons there.
share/icons: usr/share/icons
stage-packages:
- libasound2t64
@@ -32,18 +36,27 @@ parts:
# snapcraft has a lint that this is unused, but without it Zed exits with
# "NoWaylandLib" when run with Wayland.
- libwayland-client0
# Zed fails to start with "error while loading shared libraries:
# libX11-xcb.so.1" without this.
- libx11-xcb1
- libxcb1
- libxkbcommon-x11-0
- libxkbcommon0
# Mesa's Vulkan drivers (RADV, lavapipe, ...) so real AMD GPUs work
# even when the host drivers were built against a glibc newer than
# the base, and containers get a software fallback without relying
# on the host's Mesa.
- mesa-vulkan-drivers
build-attributes:
- enable-patchelf
prime:
# Omit unneeded files from the tarball
# Omit unneeded files from the tarball. The tarball's share/ stays: it
# holds the desktop entry and hicolor icons used for menu integration
# (see the app's desktop key below).
- -lib
- -licenses.md
- -share
# Omit unneeded files from stage-packages
- -etc
@@ -55,5 +68,29 @@ apps:
zed:
command: usr/bin/zed
common-id: dev.zed.Zed
# Menu integration: snapcraft copies this into meta/gui, rewrites Exec to
# the snap command and resolves the bare Icon=zed against the primed
# hicolor icons; snapd then exports it to /var/lib/snapd/desktop/
# applications on install. The tarball names its desktop entry after the
# release channel's app id.
desktop: share/applications/$APP_ID.desktop
environment:
ZED_BUNDLE_TYPE: snap
ZED_UPDATE_EXPLANATION: "Please use snap to update Zed."
# snapcraft sets DF_1_NODEFLIB on all ELFs of the snap, which makes the
# dynamic linker ignore /etc/ld.so.cache for them, and the Vulkan loader
# dlopens ICD libraries by bare soname. Bundled sonames still resolve
# through the RPATH snapcraft injects ($ORIGIN), but host ICD libraries
# not shipped in the snap (e.g. NVIDIA's) need these host directories.
LD_LIBRARY_PATH: $SNAP/usr/lib/$ARCH_TRIPLET:/usr/lib/$ARCH_TRIPLET:/lib/$ARCH_TRIPLET
# The Vulkan loader only discovers ICD manifests under the host's XDG
# paths, never $SNAP/usr/share/vulkan/icd.d, so without this the bundled
# Mesa ICDs would be invisible on hosts without Vulkan drivers (e.g.
# containers) and the software fallback would be lost. Listing the
# bundled manifests also keeps every Vulkan library resolving to the
# snap's own coherent Mesa build instead of the host's, which may not
# match the base runtime. Host Mesa manifests are omitted on purpose;
# they would only shadow the bundled ones. Missing files in the list
# are ignored, and both NVIDIA manifest locations are listed because
# the driver package may install either.
VK_DRIVER_FILES: $SNAP/usr/share/vulkan/icd.d/radeon_icd.json:$SNAP/usr/share/vulkan/icd.d/intel_icd.json:$SNAP/usr/share/vulkan/icd.d/intel_hasvk_icd.json:$SNAP/usr/share/vulkan/icd.d/nouveau_icd.json:$SNAP/usr/share/vulkan/icd.d/lvp_icd.json:/usr/share/vulkan/icd.d/nvidia_icd.json:/etc/vulkan/icd.d/nvidia_icd.json
+88 -12
View File
@@ -2,26 +2,102 @@
set -euxo pipefail
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <release_version>"
help_info() {
echo "
Usage: ${0##*/} [options]
Build zed.snap from the tarball produced by script/bundle-linux
(target/release/zed-linux-<arch>.tar.gz), for the channel in
crates/zed/RELEASE_CHANNEL.
Options:
-h, --help Display this help and exit.
--publish Upload the snap to the Snap Store channel matching the release
channel.
"
}
publish=false
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
help_info
exit 0
;;
--publish)
publish=true
shift
;;
*)
help_info
exit 1
;;
esac
done
channel=$(<crates/zed/RELEASE_CHANNEL)
version="$(script/get-crate-version zed)"
arch="$(uname -m)"
export ARCH_TRIPLET="$arch-linux-gnu"
export ZED_TARBALL="target/release/zed-linux-$arch.tar.gz"
if [[ ! -f "$ZED_TARBALL" ]]; then
echo "Missing $ZED_TARBALL, run script/bundle-linux first"
exit 1
fi
mkdir -p snap/gui
export SNAP_GRADE="stable"
store_channel=""
case "$channel" in
stable)
export APP_ID="dev.zed.Zed"
export RELEASE_VERSION="$version"
store_channel="latest/stable"
;;
preview)
export APP_ID="dev.zed.Zed-Preview"
export RELEASE_VERSION="$version-pre"
store_channel="latest/beta"
;;
nightly)
export APP_ID="dev.zed.Zed-Nightly"
# Snap versions are limited to 32 characters, so this uses a short sha
# rather than the full one in the version script/upload-nightly publishes.
export RELEASE_VERSION="$version+nightly.$(git rev-parse --short=7 HEAD)"
# The Snap Store only accepts grade `devel` on the edge and beta channels.
export SNAP_GRADE="devel"
store_channel="latest/edge"
;;
dev)
export APP_ID="dev.zed.Zed-Dev"
export RELEASE_VERSION="$version+dev.$(git rev-parse --short=7 HEAD)"
export SNAP_GRADE="devel"
;;
*)
echo "Unknown release channel: $channel"
exit 1
;;
esac
export DO_STARTUP_NOTIFY="true"
export APP_NAME="Zed"
export APP_CLI="zed"
export APP_ICON="\${SNAP}/meta/gui/zed.png"
export APP_ARGS="%U"
envsubst < "crates/zed/resources/zed.desktop.in" > "snap/gui/zed.desktop"
cp "crates/zed/resources/app-icon.png" "snap/gui/zed.png"
if [[ "$publish" == "true" && -z "$store_channel" ]]; then
echo "The $channel channel is not published to the Snap Store"
exit 1
fi
RELEASE_VERSION="$1" envsubst < crates/zed/resources/snap/snapcraft.yaml.in > snap/snapcraft.yaml
mkdir -p snap
# Only these variables are substituted, so that references the snap resolves at
# runtime (such as $SNAP) survive.
# shellcheck disable=SC2016
envsubst '$RELEASE_VERSION $SNAP_GRADE $ZED_TARBALL $APP_ID $ARCH_TRIPLET' < crates/zed/resources/snap/snapcraft.yaml.in > snap/snapcraft.yaml
# Clean seems to be needed to actually check that the snapcraft.yaml
# works. For example, when a `stage-package` is removed, it will
# still remain on rebuild.
snapcraft clean
snapcraft
snapcraft pack --output zed.snap
if [[ "$publish" == "true" ]]; then
snapcraft upload --release="$store_channel" zed.snap
fi
+3 -8
View File
@@ -2,24 +2,19 @@
# This script is intended to be run after `snap-build`.
#
# It expects a version to be passed as the first argument, and expects
# the built `.snap` for that version to be in the current directory.
# It expects the `zed.snap` built by `snap-build` to be in the current
# directory.
#
# This will uninstall the current `zed` snap, replacing it with a snap
# that directly uses the `snap/unpacked` directory.
set -euxo pipefail
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <release_version>"
exit 1
fi
# Rerun as root
[ "$UID" -eq 0 ] || exec sudo bash -e "$0" "$@"
snap remove zed || true
mkdir -p snap
rm -rf snap/unpacked
unsquashfs -dest snap/unpacked "zed_$1_amd64.snap"
unsquashfs -dest snap/unpacked zed.snap
snap try --classic snap/unpacked
@@ -3,9 +3,10 @@ use gh_workflow::*;
use crate::tasks::workflows::{
deploy_docs::deploy_docs_workflow_call,
release::{self, notify_on_failure},
runners,
runners::{self, Arch},
steps::{
CommonJobConditions, CommonPermissionSets, NamedJob, checkout_repo, dependant_job, named,
CommonJobConditions, CommonPermissionSets, FluentBuilder, NamedJob, checkout_repo,
dependant_job, named,
},
vars::{self, StepOutput, WorkflowInput},
};
@@ -26,12 +27,16 @@ pub fn after_release() -> Workflow {
let deploy_docs = deploy_docs_workflow_call(DOCS_CHANNEL, TAG_NAME_ENV);
let post_to_discord = post_to_discord(&[&refresh_zed_dev]);
let publish_winget = publish_winget();
let publish_snap = [Arch::X86_64, Arch::AARCH64].map(publish_snap);
let create_sentry_release = create_sentry_release();
let notify_on_failure = {
let [publish_snap_x86_64, publish_snap_aarch64] = &publish_snap;
let notify_on_failure = notify_on_failure(&[
&refresh_zed_dev,
&post_to_discord,
&publish_winget,
publish_snap_x86_64,
publish_snap_aarch64,
&create_sentry_release,
]);
NamedJob {
@@ -56,6 +61,11 @@ pub fn after_release() -> Workflow {
.add_job(deploy_docs.name, deploy_docs.job)
.add_job(post_to_discord.name, post_to_discord.job)
.add_job(publish_winget.name, publish_winget.job)
.map(|workflow| {
publish_snap.into_iter().fold(workflow, |workflow, job| {
workflow.add_job(job.name, job.job)
})
})
.add_job(create_sentry_release.name, create_sentry_release.job)
.add_job(notify_on_failure.name, notify_on_failure.job)
}
@@ -190,6 +200,20 @@ echo "PACKAGE_NAME=$PACKAGE_NAME" >> $env:GITHUB_OUTPUT
)
}
fn publish_snap(arch: Arch) -> NamedJob {
fn download_release_tarball(arch: Arch) -> Step<Run> {
named::bash(format!(
r#"gh release download "$TAG_NAME" --repo="$GITHUB_REPOSITORY" --pattern="zed-linux-{arch}.tar.gz" --dir=target/release"#
))
.add_env(("GITHUB_TOKEN", vars::GITHUB_TOKEN))
}
release::publish_snap(arch, &[], |job| {
job.add_step(checkout_repo().with_ref(TAG_NAME))
.add_step(download_release_tarball(arch))
})
}
fn create_sentry_release() -> NamedJob {
let job = Job::default()
.runs_on(runners::LINUX_SMALL)
+25 -1
View File
@@ -1,5 +1,5 @@
use gh_workflow::{
Event, Expression, Level, Permissions, Push, Run, Step, Use, Workflow, ctx::Context,
Event, Expression, Job, Level, Permissions, Push, Run, Step, Use, Workflow, ctx::Context,
};
use indoc::formatdoc;
@@ -184,6 +184,30 @@ pub(crate) fn create_sentry_release() -> Step<Use> {
.add_with(("environment", "production"))
}
pub(crate) fn publish_snap(
arch: Arch,
deps: &[&NamedJob],
fetch_tarball: impl FnOnce(Job) -> Job,
) -> NamedJob {
fn setup_snapcraft() -> Step<Use> {
named::uses(
"canonical",
"craft-actions/snapcraft/setup",
"d2add174925f9bca7b0a826010c8e1ce2a4bbc3d", // v1.0.0
)
}
NamedJob {
name: format!("publish_snap_{arch}"),
job: fetch_tarball(release_job(deps).runs_on(arch.linux_snap_builder()))
.add_step(setup_snapcraft())
.add_step(steps::script("./script/snap-build --publish").add_env((
"SNAPCRAFT_STORE_CREDENTIALS",
vars::SNAPCRAFT_STORE_CREDENTIALS,
))),
}
}
pub(crate) const COMPLIANCE_REPORT_PATH: &str = "compliance-report-${GITHUB_REF_NAME}.md";
pub(crate) const COMPLIANCE_REPORT_ARTIFACT_PATH: &str =
"compliance-report-${{ github.ref_name }}.md";
@@ -2,9 +2,11 @@ use crate::tasks::workflows::{
nix_build::build_nix,
release::{
ReleaseBundleJobs, create_sentry_release, download_workflow_artifacts, notify_on_failure,
prep_release_artifacts,
prep_release_artifacts, publish_snap,
},
run_bundling::{
build_static_bwrap, bundle_linux, bundle_mac, bundle_windows, set_release_channel,
},
run_bundling::{build_static_bwrap, bundle_linux, bundle_mac, bundle_windows},
run_tests::run_platform_tests_no_filter,
runners::{Arch, Platform, ReleaseChannel},
steps::{
@@ -44,7 +46,29 @@ pub fn release_nightly() -> Workflow {
let nix_linux_x86 = build_nix(Platform::Linux, Arch::X86_64, "default", None, &[&tests]);
let nix_mac_arm = build_nix(Platform::Mac, Arch::AARCH64, "default", None, &[&tests]);
let update_nightly_tag = update_nightly_tag_job(&bundle);
let notify_on_failure = notify_on_failure(&bundle.jobs());
fn download_nightly_tarball(arch: Arch) -> steps::DownloadArtifactStep {
steps::download_artifact()
.artifact_name(format!("zed-linux-{arch}.tar.gz"))
.path("target/release")
}
let publish_snap = [Arch::X86_64, Arch::AARCH64].map(|arch| {
publish_snap(arch, &[&update_nightly_tag], |job| {
job.add_step(steps::checkout_repo())
.add_step(set_release_channel(
Platform::Linux,
ReleaseChannel::Nightly,
))
.add_step(download_nightly_tarball(arch))
})
});
let notify_on_failure = notify_on_failure(
&bundle
.jobs()
.into_iter()
.chain(&publish_snap)
.collect::<Vec<_>>(),
);
named::workflow()
.with_minimal_permissions()
@@ -70,6 +94,11 @@ pub fn release_nightly() -> Workflow {
.add_job(nix_linux_x86.name, nix_linux_x86.job)
.add_job(nix_mac_arm.name, nix_mac_arm.job)
.add_job(update_nightly_tag.name, update_nightly_tag.job)
.map(|workflow| {
publish_snap.into_iter().fold(workflow, |workflow, job| {
workflow.add_job(job.name, job.job)
})
})
.add_job(notify_on_failure.name, notify_on_failure.job)
}
@@ -245,7 +245,10 @@ pub(crate) fn bundle_windows(
}
}
fn set_release_channel(platform: Platform, release_channel: ReleaseChannel) -> Step<Run> {
pub(crate) fn set_release_channel(
platform: Platform,
release_channel: ReleaseChannel,
) -> Step<Run> {
match release_channel {
ReleaseChannel::Nightly => set_release_channel_to_nightly(platform),
}
@@ -48,6 +48,16 @@ impl Arch {
Arch::AARCH64 => LINUX_ARM_BUNDLER,
}
}
// Snapcraft can only build a snap for the architecture of its host. These
// are GitHub-hosted because snapd needs systemd, which the Namespace runner
// images don't run.
pub fn linux_snap_builder(&self) -> Runner {
match self {
Arch::X86_64 => Runner("ubuntu-24.04"),
Arch::AARCH64 => Runner("ubuntu-24.04-arm"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -41,6 +41,7 @@ secret!(ZED_ZIPPY_APP_ID);
secret!(ZED_ZIPPY_APP_PRIVATE_KEY);
secret!(DISCORD_WEBHOOK_RELEASE_NOTES);
secret!(WINGET_TOKEN);
secret!(SNAPCRAFT_STORE_CREDENTIALS);
secret!(ZED_DEV_REVALIDATE_TOKEN);
secret!(SLACK_WEBHOOK_WORKFLOW_FAILURES);
secret!(R2_ACCOUNT_ID);