Snapcraft
1. 安装 snap
sudo apt install snapdsudo pacman -S --needed git base-develgit clone https://aur.archlinux.org/snapd.gitcd snapdmakepkg -sisudo systemctl enable --now snapd.socketsudo systemctl start snapd.socketsudo systemctl enable --now snapd.apparmor.servicesudo dnf install snapd# Enable classic snap supportsudo ln -s /var/lib/snapd/snap /snap安装后重启系统。
2. 安装基础 snap (base snap)
sudo snap install core223. 安装 snapcraft
sudo snap install snapcraft --classic- 创建一个 UbuntuOne 账户。
- 前往 Snapcraft 网站并注册一个应用名称。
- 在你的项目根目录下创建一个 snapcraft.yaml 文件。
- 调整 snapcraft.yaml 文件中的名称。
name: appnamebase: core22version: '0.1.0'summary: Your summary # 79 char long summarydescription: | Your description
grade: stableconfinement: strict
layout: /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.1: bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.1
apps: appname: command: usr/bin/appname desktop: usr/share/applications/appname.desktop extensions: [gnome] #plugs: # - network # Add whatever plugs you need here, see https://snapcraft.io/docs/snapcraft-interfaces for more info. # The gnome extension already includes [ desktop, desktop-legacy, gsettings, opengl, wayland, x11, mount-observe, calendar-service ] # - single-instance-plug # add this if you're using the single-instance plugin #slots: # Add the slots you need to expose to other snaps # - single-instance-plug # add this if you're using the single-instance plugin
# Add these lines only if you're using the single-instance plugin# Check https://v2.tauri.org.cn/plugin/single-instance/ for details#slots:# single-instance:# interface: dbus# bus: session# name: org.net_mydomain_MyApp.SingleInstance # Remember to change net_mydomain_MyApp to your app ID with "_" instead of "." and "-"##plugs:# single-instance-plug:# interface: dbus# bus: session# name: org.net_mydomain_MyApp.SingleInstance # Remember to change net_mydomain_MyApp to your app ID with "_" instead of "." and "-"
package-repositories: - type: apt components: [main] suites: [noble] key-id: 78E1918602959B9C59103100F1831DDAFC42E99D url: http://ppa.launchpad.net/snappy-dev/snapcraft-daily/ubuntu
parts: build-app: plugin: dump build-snaps: - node/20/stable - rustup/latest/stable build-packages: - libwebkit2gtk-4.1-dev - build-essential - curl - wget - file - libxdo-dev - libssl-dev - libayatana-appindicator3-dev - librsvg2-dev - dpkg stage-packages: - libwebkit2gtk-4.1-0 - libayatana-appindicator3-1 source: . override-build: | set -eu npm install npm run tauri build -- --bundles deb dpkg -x src-tauri/target/release/bundle/deb/*.deb $SNAPCRAFT_PART_INSTALL/ sed -i -e "s|Icon=appname|Icon=/usr/share/icons/hicolor/32x32/apps/appname.png|g" $SNAPCRAFT_PART_INSTALL/usr/share/applications/appname.desktopname变量定义了你的应用名称,且必须设置为你之前注册过的名称。base变量定义了你所使用的核心 (core)。version变量定义了版本号,每当源码仓库发生变更时都应更新该版本号。apps部分允许你暴露桌面文件和二进制文件,以便用户可以运行你的应用。package-repositories部分允许你添加包仓库,以帮助满足你的依赖项需求。build-packages/build-snaps定义了 snap 的构建依赖。stage-packages/stage-snaps定义了 snap 的运行时依赖。override-build部分会在拉取源码后运行一系列命令。
sudo snapcraftsnap run your-appsnapcraft login # Login with your UbuntuOne credentialssnapcraft upload --release=stable mysnap_latest_amd64.snap- 在你的应用开发者页面,点击
builds选项卡。 - 点击
login with github(使用 GitHub 登录)。 - 输入你的仓库详细信息。
© 2026 Tauri 贡献者。CC-BY / MIT