2021-10-30 14:50:23 +02:00
# Snapcraft Packages (snaps)
2018-06-25 15:06:08 +02:00
GoReleaser can also generate `snap` packages.
[Snaps ](http://snapcraft.io/ ) are a new packaging format, that will let you
publish your project directly to the Ubuntu store.
From there it will be installable in all the
[supported Linux distros ](https://snapcraft.io/docs/core/install ), with
automatic and transactional updates.
You can read more about it in the [snapcraft docs ](https://snapcraft.io/docs/ ).
Available options:
2020-05-10 23:59:21 +02:00
```yaml
2021-12-23 02:52:01 +02:00
# .goreleaser.yaml
2019-05-27 17:47:05 +02:00
snapcrafts:
2023-06-12 14:10:39 +02:00
- #
2019-05-29 16:18:33 +02:00
# ID of the snapcraft config, must be unique.
2023-04-02 22:16:21 +02:00
#
# Default: 'default'
2019-05-29 14:13:52 +02:00
id: foo
2019-05-27 17:47:05 +02:00
# Build IDs for the builds you want to create snapcraft packages for.
builds:
2023-06-12 14:10:39 +02:00
- foo
- bar
2019-05-27 17:47:05 +02:00
# You can change the name of the package.
2023-04-02 22:16:21 +02:00
#
# Default: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
# Templates: allowed
2019-05-27 17:47:05 +02:00
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
# The name of the snap. This is optional.
2023-04-02 22:16:21 +02:00
#
# Default: ProjectName
2019-05-27 17:47:05 +02:00
name: drumroll
2023-06-12 14:10:39 +02:00
# The canonical title of the application, displayed in the software
# centre graphical frontends.
#
# Since: v1.19.
title: Drum Roll
# Path to icon image that represents the snap in the snapcraft.io store
# pages and other graphical store fronts.
#
# Since: v1.19.
icon: ./icon.png
2021-09-22 03:40:41 +02:00
# Whether to publish the snap to the snapcraft store.
2019-05-27 17:47:05 +02:00
# Remember you need to `snapcraft login` first.
publish: true
# Single-line elevator pitch for your amazing snap.
# 79 char long at most.
summary: Software to create fast and easy drum rolls.
# This the description of your snap. You have a paragraph or two to tell the
# most important story about your snap. Keep it under 100 words though,
# we live in tweetspace and your description wants to look good in the snap
# store.
description: This is the best drum roll application out there. Install it and awe!
2021-07-24 05:23:59 +02:00
# Channels in store where snap will be pushed.
2023-04-02 22:16:21 +02:00
#
2021-07-24 05:23:59 +02:00
# More info about channels here:
# https://snapcraft.io/docs/reference/channels
2023-01-24 03:05:24 +02:00
#
2023-04-02 22:16:21 +02:00
# Default:
# grade is 'stable': ["edge", "beta", "candidate", "stable"]
# grade is 'devel': ["edge", "beta"]
# Templates: allowed (since v1.15)
2021-07-24 05:23:59 +02:00
channel_templates:
- edge
- beta
- candidate
- stable
2023-06-12 14:10:39 +02:00
- "{{ .Major }}.{{ .Minor }}/edge"
- "{{ .Major }}.{{ .Minor }}/beta"
- "{{ .Major }}.{{ .Minor }}/candidate"
- "{{ .Major }}.{{ .Minor }}/stable"
2021-07-24 05:23:59 +02:00
2019-05-27 17:47:05 +02:00
# A guardrail to prevent you from releasing a snap to all your users before
# it is ready.
# `devel` will let you release only to the `edge` and `beta` channels in the
# store. `stable` will let you release also to the `candidate` and `stable`
2021-07-24 05:23:59 +02:00
# channels.
2019-05-27 17:47:05 +02:00
grade: stable
# Snaps can be setup to follow three different confinement policies:
# `strict` , `devmode` and `classic` . A strict confinement where the snap
# can only read and write in its own namespace is recommended. Extra
# permissions for strict snaps can be declared as `plugs` for the app, which
# are explained later. More info about confinement here:
# https://snapcraft.io/docs/reference/confinement
confinement: strict
2022-09-17 05:13:09 +02:00
# Your app's license, based on SPDX license expressions:
# https://spdx.org/licenses
2019-05-27 17:47:05 +02:00
license: MIT
# A snap of type base to be used as the execution environment for this snap.
# Valid values are:
# * bare - Empty base snap;
# * core - Ubuntu Core 16;
# * core18 - Ubuntu Core 18.
base: core18
2023-06-12 14:10:39 +02:00
# A list of features that must be supported by the core in order for
# this snap to install.
#
# Since: v1.19.
assumes:
- snapd2.38
# his top-level keyword to define a hook with a plug to access more
# privileges.
#
# Since: v1.19.
hooks:
install:
- network
2020-06-06 20:07:18 +02:00
# Add extra files on the resulting snap. Useful for including wrapper
# scripts or other useful static files. Source filenames are relative to the
# project directory. Destination filenames are relative to the snap prime
# directory.
extra_files:
- source: drumroll.wrapper
destination: bin/drumroll.wrapper
mode: 0755
2023-03-30 03:23:53 +02:00
# Additional templated extra files to add to the package.
# Those files will have their contents pass through the template engine,
# and its results will be added to the package.
#
# Since: v1.17 (pro)
2023-03-30 18:26:03 +02:00
# This feature is only available in GoReleaser Pro.
2023-04-02 22:16:21 +02:00
# Templates: allowed
2023-03-30 03:23:53 +02:00
templated_extra_files:
- source: LICENSE.tpl
destination: LICENSE.txt
mode: 0644
2021-03-17 15:18:56 +02:00
# With layouts, you can make elements in $SNAP, $SNAP_DATA, $SNAP_COMMON
2022-09-17 05:13:09 +02:00
# accessible from locations such as /usr, /var and /etc. This helps when
# using pre-compiled binaries and libraries that expect to find files and
2021-03-17 15:18:56 +02:00
# directories outside of locations referenced by $SNAP or $SNAP_DATA.
# About snap environment variables:
# * HOME: set to SNAP_USER_DATA for all commands
# * SNAP: read-only install directory
# * SNAP_ARCH: the architecture of device (eg, amd64, arm64, armhf, i386, etc)
# * SNAP_DATA: writable area for a particular revision of the snap
# * SNAP_COMMON: writable area common across all revisions of the snap
# * SNAP_LIBRARY_PATH: additional directories which should be added to LD_LIBRARY_PATH
# * SNAP_NAME: snap name
# * SNAP_INSTANCE_NAME: snap instance name incl. instance key if one is set (snapd 2.36+)
# * SNAP_INSTANCE_KEY: instance key if any (snapd 2.36+)
# * SNAP_REVISION: store revision of the snap
# * SNAP_USER_DATA: per-user writable area for a particular revision of the snap
# * SNAP_USER_COMMON: per-user writable area common across all revisions of the snap
# * SNAP_VERSION: snap version (from snap.yaml)
# More info about layout here:
# https://snapcraft.io/docs/snap-layouts
layout:
# The path you want to access in sandbox.
/etc/drumroll:
# Which outside file or directory you want to map to sandbox.
# Valid keys are:
# * bind - Bind-mount a directory.
# * bind_file - Bind-mount a file.
# * symlink - Create a symbolic link.
# * type - Mount a private temporary in-memory filesystem.
bind: $SNAP_DATA/etc
2019-05-27 17:47:05 +02:00
# Each binary built by GoReleaser is an app inside the snap. In this section
# you can declare extra details for those binaries. It is optional.
2022-03-06 04:16:43 +02:00
# See: https://snapcraft.io/docs/snapcraft-app-and-service-metadata
2019-05-27 17:47:05 +02:00
apps:
# The name of the app must be the same name as the binary built or the snapcraft name.
drumroll:
# If you any to pass args to your binary, you can add them with the
# args option.
args: --foo
2019-06-23 03:37:55 +02:00
2022-03-06 04:16:43 +02:00
# The kind of wrapper to generate for the given command.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
adapter: none
# List of applications that are ordered to be started after the current
# one.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
after: ["postdrum"]
# Aliases for the app command.
# https://snapcraft.io/docs/commands-and-aliases#heading--aliases
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
aliases: ["droll"]
# Defines the name of the .desktop file used to start an application
# with the desktop session.
# https://snapcraft.io/docs/snap-format#heading--autostart
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
autostart: drumroll.desktop
# List of applications that are ordered to be started before the current
# one.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
before: ["predrum"]
# D-Bus name this service is reachable as. Mandatory if daemon=dbus.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
bus_name: drumbus
# A list of commands to be executed in order before the command of this
# app.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
command_chain: ["foo", "bar", "baz"]
# An identifier to a desktop-id within an external appstream file.
# https://snapcraft.io/docs/using-external-metadata
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
common_id: "com.example.drumroll"
2019-06-23 03:37:55 +02:00
# Bash completion snippet. More information about completion here:
# https://docs.snapcraft.io/tab-completion-for-snaps.
completer: drumroll-completion.bash
2020-06-06 20:07:18 +02:00
# You can override the command name.
2023-04-02 22:16:21 +02:00
#
# Default: AppName
2020-06-06 20:07:18 +02:00
command: bin/drumroll.wrapper
2022-03-06 04:16:43 +02:00
# If you want your app to be autostarted and to always run in the
# background, you can make it a simple daemon.
daemon: simple
# Location of the .desktop file.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
desktop: usr/share/applications/drumroll.desktop
# A set of key-value pairs specifying environment variables.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
environment:
foo: bar
baz: quo
# A list of Snapcraft extensions this app depends on.
# https://snapcraft.io/docs/snapcraft-extensions
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
extensions: ["gnome-3-38"]
# Defines whether a freshly installed daemon is started automatically,
# or whether startup control is deferred to the snap.
2022-09-11 21:54:51 +02:00
# Requires `daemon` to be set.
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
install_mode: "disable"
# A set of key-value attributes passed through to snap.yaml without
# snapcraft validation.
# https://snapcraft.io/docs/using-in-development-features
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
passthrough:
foo: bar
# If your app requires extra permissions to work outside of its default
# confined space, declare them here.
# You can read the documentation about the available plugs and the
# things they allow:
2023-02-13 19:51:48 +02:00
# https://snapcraft.io/docs/supported-interfaces.
2022-03-06 04:16:43 +02:00
plugs: ["home", "network", "personal-files"]
# Sets a command to run from inside the snap after a service stops.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
post_stop_command: foo
# Controls whether the daemon should be restarted during a snap refresh.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
refresh_mode: endure
# Command to use to ask the service to reload its configuration.
2022-09-11 21:54:51 +02:00
# Requires `daemon` to be set.
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
reload_command: foo
2020-10-06 15:59:53 +02:00
# Restart condition of the snap.
# https://snapcraft.io/docs/snapcraft-yaml-reference
restart_condition: "always"
2022-03-06 04:16:43 +02:00
# List of slots for interfaces to connect to.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
slots: ["foo", "bar", "baz"]
# Maps a daemon’s sockets to services and activates them.
2022-09-11 21:54:51 +02:00
# Requires `plugs` to contain `network-bind` .
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
sockets:
sock:
listen-stream: $SNAP_COMMON/socket
socket-group: socket-group
socket-mode: 416
# Time to wait for daemon to start.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
start_timeout: 42ms
# Command to use to stop the service.
2022-09-11 21:54:51 +02:00
# Requires `daemon` to be set.
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
stop_command: foo
# Controls how the daemon should be stopped.
2022-09-11 21:54:51 +02:00
# Requires `daemon` to be set.
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
stop_mode: sigterm
# Time to wait for daemon to stop.
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
stop_timeout: 42ms
# Schedules when, or how often, to run a service or command.
2022-09-11 21:54:51 +02:00
# Requires `daemon` to be set.
2022-03-06 04:16:43 +02:00
# https://snapcraft.io/docs/services-and-daemons
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
timer: "00:00-24:00/24"
# Declares the service watchdog timeout.
2022-09-11 21:54:51 +02:00
# Requires `plugs` to contain `daemon-notify` .
#
2023-04-02 22:16:21 +02:00
# Since: v1.6
2022-03-06 04:16:43 +02:00
watchdog_timeout: 42ms
2019-05-27 17:47:05 +02:00
# Allows plugs to be configured. Plugs like system-files and personal-files
# require this.
plugs:
personal-files:
read:
2023-06-12 14:10:39 +02:00
- $HOME/.foo
2019-05-27 17:47:05 +02:00
write:
2023-06-12 14:10:39 +02:00
- $HOME/.foo
- $HOME/.foobar
2018-06-25 15:06:08 +02:00
```
2020-05-10 23:59:21 +02:00
!!! tip
2023-06-12 14:10:39 +02:00
2020-11-19 22:31:26 +02:00
Learn more about the [name template engine ](/customization/templates/ ).
2018-07-09 08:57:46 +02:00
2020-05-11 14:35:58 +02:00
!!! note
2023-06-12 14:10:39 +02:00
2020-05-11 14:35:58 +02:00
GoReleaser will not install `snapcraft` nor any of its dependencies for you.