跳到内容
Tauri

Snapcraft

1. 安装 snap

终端窗口
sudo apt install snapd

2. 安装基础 snap

终端窗口
sudo snap install core22

3. 安装 snapcraft

终端窗口
sudo snap install snapcraft --classic
  1. 创建一个 UbuntuOne 账户。
  2. 前往 Snapcraft 网站并注册一个应用程序名称。
  3. 在您的项目根目录中创建 snapcraft.yaml 文件。
  4. 调整 snapcraft.yaml 文件中的名称。
name: appname
base: core22
version: '0.1.0'
summary: Your summary # 79 char long summary
description: |
Your description
grade: stable
confinement: 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.desktop
  • name 变量定义了应用程序的名称,并且必须设置为您之前注册的名称。
  • base 变量定义了您正在使用的核心。
  • version 变量定义了版本,并且应随源代码存储库的每次更改而更新。
  • apps 部分允许您公开桌面和二进制文件,以允许用户运行您的应用程序。
  • package-repositories 部分允许您添加包存储库以帮助您满足依赖关系。
  • build-packages/build-snaps 定义了您的 snap 的构建依赖项。
  • stage-packages/stage-snaps 定义了您的 snap 的运行时依赖项。
  • override-pull 部分在拉取源文件之前运行一系列命令。
  • craftctl default 执行默认的拉取命令。
  • organize 部分将您的文件移动到适当的目录,以便二进制文件和桌面文件可以暴露给 apps 部分。
终端窗口
sudo snapcraft
终端窗口
snap run your-app
终端窗口
snapcraft login # Login with your UbuntuOne credentials
snapcraft upload --release=stable mysnap_latest_amd64.snap
  1. 在您的应用程序开发者页面上点击 builds 选项卡。
  2. 点击 login with github
  3. 输入您的存储库详细信息。

© 2025 Tauri 贡献者。CC-BY / MIT