Skip to content
Tauri

Snapcraft

Prerequisites

1. Install snap

Terminal window
sudo apt install snapd

2. Install a base snap

Terminal window
sudo snap install core22

3. Install snapcraft

Terminal window
sudo snap install snapcraft --classic

Configuration

  1. Create an UbuntuOne account.
  2. Go to the Snapcraft website and register an App name.
  3. Create a snapcraft.yaml file in your projects root.
  4. Adjust the names in the snapcraft.yaml file.
name: app
base: core22
version: '2.0.4'
summary: Your summary # 79 char long summary
description: |
Your Description
grade: stable
confinement: strict
apps:
app:
command: bin/app
desktop: usr/share/applications/app.desktop
package-repositories:
- type: apt
components: [main]
suites: [noble]
key-id: 78E1918602959B9C59103100F1831DDAFC42E99D
url: http://ppa.launchpad.net/snappy-dev/snapcraft-daily/ubuntu
parts:
prep:
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
- libglu1-mesa
- libsoup-3.0-0
- freeglut3
source: .
override-pull: |
set -eu
craftctl default
rustup default nightly
npm install
npm run tauri build -- --bundles deb
dpkg -x src-tauri/target/release/bundle/deb/*.deb here
sed -i -e "s|Icon=app|Icon=/usr/share/icons/hicolor/32x32/apps/app.png|g" here/usr/share/applications/app.desktop
cp -r here/* .
organize:
usr/bin/app: bin/app

Explanation

  • The name variable defines the name of your app and is required to be set to the name that you have registered earlier.
  • The basevariable defines which core you are using.
  • The Version variable defines the version, and should be updated with each change to the source repository.
  • The apps section allows you to expose the desktop and binary files to allow the user to run your app.
  • The package-repositories section allows you to add a package repository to help you satisfy your dependencies.
  • build-packages/build-snaps defines the build dependencies for your snap.
  • stage-packages/stage-snaps defines the runtime dependencies for your snap.
  • The override-pull section runs a series of commands before the sources are pulled.
  • craftctl default performs the default pull commands.
  • The organize section moves your files to the proper directories so that the binary and desktop file can be exposed to the apps sections.

Building

Terminal window
sudo snapcraft

Testing

Terminal window
snap run your-app

Releasing Manually

Terminal window
snapcraft login # Login with your UbuntuOne credentials
snapcraft upload --release=stable mysnap_latest_amd64.snap

Building automatically

  1. On your apps developer page click on the builds tab.
  2. Click login with github.
  3. Enter in your repository’s details.

© 2024 Tauri Contributors. CC-BY / MIT