2021-10-30 09:50:23 -03:00
# Linux packages (via nFPM)
2017-09-10 17:07:28 -03:00
2018-02-18 20:37:59 -03:00
GoReleaser can be wired to [nfpm ](https://github.com/goreleaser/nfpm ) to
2022-11-02 18:30:06 +00:00
generate and publish `.deb` , `.rpm` , `.apk` , and Archlinux packages.
2018-02-18 20:37:59 -03:00
Available options:
2020-05-10 18:59:21 -03:00
```yaml
2021-12-23 01:52:01 +01:00
# .goreleaser.yaml
2019-05-07 06:59:53 -03:00
nfpms:
# note that this is an array of nfpm configs
2023-06-22 09:08:31 -03:00
- #
2020-05-10 18:59:21 -03:00
# ID of the nfpm config, must be unique.
2023-04-02 17:16:21 -03:00
#
# Default: 'default'
2019-05-07 07:18:35 -03:00
id: foo
2019-11-15 16:00:48 -03:00
# Name of the package.
2023-04-02 17:16:21 -03:00
# Default: ProjectName
2023-07-18 00:44:11 +00:00
# Templates: allowed. (since v1.18)
2019-11-15 16:00:48 -03:00
package_name: foo
# You can change the file name of the package.
2021-11-12 09:07:59 -03:00
#
2023-04-02 17:16:21 -03:00
# Default: '{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
2023-07-18 00:44:11 +00:00
# Templates: allowed.
2021-11-12 09:07:59 -03:00
file_name_template: "{{ .ConventionalFileName }}"
2019-05-07 06:59:53 -03:00
# Build IDs for the builds you want to create NFPM packages for.
2022-04-11 23:59:52 -03:00
# Defaults empty, which means no filtering.
2019-05-07 06:59:53 -03:00
builds:
2020-02-26 19:59:52 +08:00
- foo
- bar
2019-05-07 06:59:53 -03:00
# Your app's vendor.
vendor: Drum Roll Inc.
2021-05-31 21:59:46 -03:00
2023-04-02 17:16:21 -03:00
# Your app's homepage.
2019-05-07 06:59:53 -03:00
homepage: https://example.com/
# Your app's maintainer (probably you).
maintainer: Drummer < drum-roll @example .com >
2023-04-02 17:16:21 -03:00
# Your app's description.
2022-01-31 15:13:07 -03:00
description: |-
2022-01-31 18:42:45 +01:00
Drum rolls installer package.
Software to create fast and easy drum rolls.
2019-05-07 06:59:53 -03:00
# Your app's license.
license: Apache 2.0
# Formats to be generated.
formats:
2020-08-22 19:00:14 -03:00
- apk
2019-05-07 06:59:53 -03:00
- deb
- rpm
2023-04-02 17:16:21 -03:00
- termux.deb # Since: v1.11
2023-06-22 09:08:31 -03:00
- archlinux # Since: v1.13
# Umask to be used on files without explicit mode set. (overridable)
#
# Default: 0o002 (will remove world-writable permissions)
# Since: v1.19
umask: 0o002
2019-05-07 06:59:53 -03:00
2022-08-07 12:13:20 -03:00
# Packages your package depends on. (overridable)
2019-05-07 06:59:53 -03:00
dependencies:
- git
- zsh
2022-08-07 12:13:20 -03:00
# Packages it provides. (overridable)
2023-04-02 17:16:21 -03:00
#
# Since: v1.11
2022-08-07 12:13:20 -03:00
provides:
- bar
# Packages your package recommends installing. (overridable)
2019-05-07 06:59:53 -03:00
recommends:
- bzr
- gtk
2022-08-07 12:13:20 -03:00
# Packages your package suggests installing. (overridable)
2019-05-07 06:59:53 -03:00
suggests:
- cvs
- ksh
2022-08-07 12:13:20 -03:00
# Packages that conflict with your package. (overridable)
2019-05-07 06:59:53 -03:00
conflicts:
- svn
- bash
2022-08-07 12:13:20 -03:00
# Packages it replaces. (overridable)
2020-11-06 15:17:08 -03:00
replaces:
- fish
2023-04-02 17:16:21 -03:00
# Path that the binaries should be installed.
# Default: '/usr/bin'
2019-05-07 06:59:53 -03:00
bindir: /usr/bin
2020-12-28 14:40:23 -03:00
# Version Epoch.
2023-04-02 17:16:21 -03:00
# Default: extracted from `version` if it is semver compatible
2020-12-28 14:40:23 -03:00
epoch: 2
2019-06-29 12:26:01 -03:00
2020-12-28 14:40:23 -03:00
# Version Prerelease.
2023-04-02 17:16:21 -03:00
# Default: extracted from `version` if it is semver compatible
2020-12-28 14:40:23 -03:00
prerelease: beta1
# Version Metadata (previously deb.metadata).
2022-09-17 00:13:09 -03:00
# Setting metadata might interfere with version comparisons depending on the
# packager.
2023-04-02 17:16:21 -03:00
#
# Default: extracted from `version` if it is semver compatible
2020-12-28 14:40:23 -03:00
version_metadata: git
# Version Release.
2020-02-26 19:59:52 +08:00
release: 1
2021-01-05 22:55:16 -03:00
# Section.
section: default
# Priority.
priority: extra
2022-09-17 00:13:09 -03:00
# Makes a meta package - an empty package that contains only supporting
# files and dependencies.
2020-06-19 22:04:10 +08:00
# When set to `true` , the `builds` option is ignored.
meta: true
2022-08-16 02:05:46 -03:00
# Changelog YAML file, see: https://github.com/goreleaser/chglog
#
# You can use goreleaser/chglog to create the changelog for your project,
# pass that changelog yaml file to GoReleaser,
# and it should in turn setup it accordingly for the given available
# formats (deb and rpm at the moment).
#
# Experimental.
2023-04-02 17:16:21 -03:00
# Since: v1.11
2022-08-16 02:05:46 -03:00
changelog: ./foo.yml
2020-12-23 23:07:48 -03:00
# Contents to add to the package.
# GoReleaser will automatically add the binaries.
contents:
# Basic file that applies to all packagers
2022-12-31 12:17:38 -03:00
- src: path/to/foo
dst: /usr/bin/foo
2020-12-23 23:07:48 -03:00
2023-03-19 23:19:22 -03:00
# This will add all files in some/directory or in subdirectories at the
# same level under the directory /etc. This means the tree structure in
# some/directory will not be replicated.
- src: some/directory/
dst: /etc
# This will replicate the directory structure under some/directory at
# /etc, using the "tree" type.
#
2023-04-02 17:16:21 -03:00
# Since: v1.17
2023-07-18 00:44:11 +00:00
# Templates: allowed.
2023-03-19 23:19:22 -03:00
- src: some/directory/
dst: /etc
type: tree
2020-12-23 23:07:48 -03:00
# Simple config file
2022-12-31 12:17:38 -03:00
- src: path/to/foo.conf
2020-12-23 23:07:48 -03:00
dst: /etc/foo.conf
type: config
2020-12-30 15:49:44 -03:00
# Simple symlink.
# Corresponds to `ln -s /sbin/foo /usr/local/bin/foo`
- src: /sbin/foo
2022-12-31 12:17:38 -03:00
dst: /usr/bin/foo
2020-12-23 23:07:48 -03:00
type: "symlink"
2022-09-17 00:13:09 -03:00
# Corresponds to `%config(noreplace)` if the packager is rpm, otherwise it
# is just a config file
2020-12-23 23:07:48 -03:00
- src: path/to/local/bar.conf
dst: /etc/bar.conf
type: "config|noreplace"
2021-05-31 00:28:11 -03:00
# The src and dst attributes also supports name templates
2021-05-20 19:21:48 +02:00
- src: path/{{ .Os }}-{{ .Arch }}/bar.conf
2021-05-31 00:28:11 -03:00
dst: /etc/foo/bar-{{ .ProjectName }}.conf
2021-05-20 19:21:48 +02:00
2023-03-29 22:23:53 -03:00
# Additional templated contents to add to the archive.
# 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 13:26:03 -03:00
# This feature is only available in GoReleaser Pro.
2023-07-18 00:44:11 +00:00
# Templates: allowed.
2023-07-06 16:51:23 +00:00
templated_contents:
2023-03-29 22:23:53 -03:00
# a more complete example, check the globbing deep dive below
2023-06-22 09:08:31 -03:00
- src: "LICENSE.md.tpl"
2023-03-29 22:23:53 -03:00
dst: LICENSE.md
2020-12-23 23:07:48 -03:00
# These files are not actually present in the package, but the file names
# are added to the package header. From the RPM directives documentation:
#
# "There are times when a file should be owned by the package but not
2022-09-17 00:13:09 -03:00
# installed - log files and state files are good examples of cases you
# might desire this to happen."
2020-12-23 23:07:48 -03:00
#
# "The way to achieve this, is to use the %ghost directive. By adding this
# directive to the line containing a file, RPM will know about the ghosted
# file, but will not add it to the package."
#
# For non rpm packages ghost files are ignored at this time.
- dst: /etc/casper.conf
type: ghost
- dst: /var/log/boo.log
type: ghost
2022-09-17 00:13:09 -03:00
# You can use the packager field to add files that are unique to a
# specific packager
2020-12-23 23:07:48 -03:00
- src: path/to/rpm/file.conf
dst: /etc/file.conf
type: "config|noreplace"
packager: rpm
- src: path/to/deb/file.conf
dst: /etc/file.conf
type: "config|noreplace"
packager: deb
- src: path/to/apk/file.conf
dst: /etc/file.conf
type: "config|noreplace"
packager: apk
2022-09-17 00:13:09 -03:00
# Sometimes it is important to be able to set the mtime, mode, owner, or
# group for a file that differs from what is on the local build system at
# build time.
2020-12-23 23:07:48 -03:00
- src: path/to/foo
dst: /usr/local/foo
file_info:
mode: 0644
mtime: 2008-01-02T15:04:05Z
owner: notRoot
group: notRoot
2020-11-26 23:45:17 -03:00
2022-11-20 14:22:19 -03:00
# If `dst` ends with a `/` , it'll create the given path and copy the given
# `src` into it, the same way `cp` works with and without trailing `/` .
- src: ./foo/bar/*
dst: /usr/local/myapp/
2022-09-17 00:13:09 -03:00
# Using the type 'dir', empty directories can be created. When building
# RPMs, however, this type has another important purpose: Claiming
# ownership of that folder. This is important because when upgrading or
# removing an RPM package, only the directories for which it has claimed
2022-09-24 22:42:30 -03:00
# ownership are removed. However, you should not claim ownership of a
# folder that is created by the OS or a dependency of your package.
#
2022-09-17 00:13:09 -03:00
# A directory in the build environment can optionally be provided in the
# 'src' field in order copy mtime and mode from that directory without
# having to specify it manually.
2021-11-13 22:23:11 -03:00
- dst: /some/dir
type: dir
file_info:
mode: 0700
2022-09-24 22:42:30 -03:00
# Scripts to execute during the installation of the package. (overridable)
#
2019-05-07 06:59:53 -03:00
# Keys are the possible targets during the installation process
2022-09-24 22:42:30 -03:00
# Values are the paths to the scripts which will be executed.
2023-07-18 00:44:11 +00:00
#
2023-09-04 14:12:01 +00:00
# Templates: allowed (since v1.20)
2019-05-07 06:59:53 -03:00
scripts:
preinstall: "scripts/preinstall.sh"
postinstall: "scripts/postinstall.sh"
preremove: "scripts/preremove.sh"
postremove: "scripts/postremove.sh"
2023-07-18 00:44:11 +00:00
# Templated scripts to execute during the installation of the package. (overridable)
#
# Keys are the possible targets during the installation process
# Values are the paths to the scripts which will be executed.
#
# Since: v1.20 (pro)
# This feature is only available in GoReleaser Pro.
# Templates: allowed.
templated_scripts:
preinstall: "scripts/preinstall.sh"
postinstall: "scripts/postinstall.sh"
preremove: "scripts/preremove.sh"
postremove: "scripts/postremove.sh"
2022-09-24 22:42:30 -03:00
# All fields above marked as `overridable` can be overridden for a given
# package format in this section.
2019-05-07 06:59:53 -03:00
overrides:
2023-01-27 21:45:58 -03:00
# The dependencies override can for example be used to provide version
2022-09-24 22:42:30 -03:00
# constraints for dependencies where different package formats use
# different versions or for dependencies that are named differently.
2019-05-07 06:59:53 -03:00
deb:
2023-01-27 21:45:58 -03:00
dependencies:
2022-09-24 22:42:30 -03:00
- baz (>= 1.2.3-0)
- some-lib-dev
# ...
2019-05-07 06:59:53 -03:00
rpm:
2023-01-27 21:45:58 -03:00
dependencies:
2022-09-24 22:42:30 -03:00
- baz >= 1.2.3-0
- some-lib-devel
# ...
apk:
# ...
2020-11-05 21:47:55 +00:00
2021-04-28 16:01:03 +03:00
# Custom configuration applied only to the RPM packager.
2020-11-05 21:47:55 +00:00
rpm:
2021-04-28 16:01:03 +03:00
# RPM specific scripts.
scripts:
# The pretrans script runs before all RPM package transactions / stages.
pretrans: ./scripts/pretrans.sh
# The posttrans script runs after all RPM package transactions / stages.
posttrans: ./scripts/posttrans.sh
2023-04-02 17:16:21 -03:00
# The package summary.
#
# Default: first line of the description
2020-11-12 10:46:55 -03:00
summary: Explicit Summary for Sample Package
2023-04-02 17:16:21 -03:00
# The package group.
# This option is deprecated by most distros but required by old distros
# like CentOS 5 / EL 5 and earlier.
2020-11-05 21:47:55 +00:00
group: Unspecified
2022-09-24 22:42:30 -03:00
# The packager is used to identify the organization that actually packaged
# the software, as opposed to the author of the software.
# `maintainer` will be used as fallback if not specified.
# This will expand any env var you set in the field, eg packager: ${PACKAGER}
packager: GoReleaser < staff @goreleaser .com >
2020-11-05 21:47:55 +00:00
2022-09-24 22:42:30 -03:00
# Compression algorithm (gzip (default), lzma or xz).
compression: lzma
2020-11-12 10:46:55 -03:00
2023-07-14 01:55:47 +00:00
# Prefixes for relocatable packages.
#
# Since: v1.20.
prefixes:
- /usr/bin
2020-11-05 21:47:55 +00:00
# The package is signed if a key_file is set
signature:
2023-04-02 17:16:21 -03:00
# PGP secret key file path (can also be ASCII-armored).
2021-09-01 10:27:08 -03:00
# The passphrase is taken from the environment variable
# `$NFPM_ID_RPM_PASSPHRASE` with a fallback to `$NFPM_ID_PASSPHRASE` ,
# where ID is the id of the current nfpm config.
2020-11-05 21:47:55 +00:00
# The id will be transformed to uppercase.
# E.g. If your nfpm id is 'default' then the rpm-specific passphrase
2021-09-01 10:27:08 -03:00
# should be set as `$NFPM_DEFAULT_RPM_PASSPHRASE`
2023-04-02 17:16:21 -03:00
#
2023-07-18 00:44:11 +00:00
# Templates: allowed.
2023-06-22 09:08:31 -03:00
key_file: "{{ .Env.GPG_KEY_PATH }}"
2020-11-05 21:47:55 +00:00
# Custom configuration applied only to the Deb packager.
deb:
2022-02-09 11:40:51 -03:00
# Lintian overrides
lintian_overrides:
- statically-linked-binary
- changelog-file-missing-in-native-package
2020-11-18 13:55:14 +01:00
# Custom deb special files.
2020-11-05 21:47:55 +00:00
scripts:
2020-11-18 13:55:14 +01:00
# Deb rules script.
2020-11-05 21:47:55 +00:00
rules: foo.sh
# Deb templates file, when using debconf.
templates: templates
# Custom deb triggers
triggers:
2022-06-26 03:30:10 +03:00
# register interest on a trigger activated by another package
2020-11-05 21:47:55 +00:00
# (also available: interest_await, interest_noawait)
interest:
- some-trigger-name
# activate a trigger for another package
# (also available: activate_await, activate_noawait)
activate:
- another-trigger-name
# Packages which would break if this package would be installed.
# The installation of this package is blocked if `some-package`
# is already installed.
breaks:
- some-package
# The package is signed if a key_file is set
signature:
2023-04-02 17:16:21 -03:00
# PGP secret key file path (can also be ASCII-armored).
2021-09-01 10:27:08 -03:00
# The passphrase is taken from the environment variable
# `$NFPM_ID_DEB_PASSPHRASE` with a fallback to `$NFPM_ID_PASSPHRASE` ,
# where ID is the id of the current nfpm config.
2020-11-05 21:47:55 +00:00
# The id will be transformed to uppercase.
# E.g. If your nfpm id is 'default' then the deb-specific passphrase
2021-09-01 10:27:08 -03:00
# should be set as `$NFPM_DEFAULT_DEB_PASSPHRASE`
2023-04-02 17:16:21 -03:00
#
2023-07-18 00:44:11 +00:00
# Templates: allowed.
2023-06-22 09:08:31 -03:00
key_file: "{{ .Env.GPG_KEY_PATH }}"
2021-09-01 10:27:08 -03:00
2020-11-05 21:47:55 +00:00
# The type describes the signers role, possible values are "origin",
2023-04-02 17:16:21 -03:00
# "maint" and "archive".
#
# Default: 'origin'
2020-11-05 21:47:55 +00:00
type: origin
apk:
2021-06-20 19:34:09 +02:00
# APK specific scripts.
scripts:
# The preupgrade script runs before APK upgrade.
preupgrade: ./scripts/preupgrade.sh
# The postupgrade script runs after APK.
postupgrade: ./scripts/postupgrade.sh
2020-11-05 21:47:55 +00:00
# The package is signed if a key_file is set
signature:
2023-04-02 17:16:21 -03:00
# PGP secret key file path (can also be ASCII-armored).
2021-09-01 10:27:08 -03:00
# The passphrase is taken from the environment variable
# `$NFPM_ID_APK_PASSPHRASE` with a fallback to `$NFPM_ID_PASSPHRASE` ,
# where ID is the id of the current nfpm config.
2020-11-05 21:47:55 +00:00
# The id will be transformed to uppercase.
2021-09-01 10:27:08 -03:00
# E.g. If your nfpm id is 'default' then the apk-specific passphrase
# should be set as `$NFPM_DEFAULT_APK_PASSPHRASE`
2023-04-02 17:16:21 -03:00
#
2023-07-18 00:44:11 +00:00
# Templates: allowed.
2023-06-22 09:08:31 -03:00
key_file: "{{ .Env.GPG_KEY_PATH }}"
2021-09-01 10:27:08 -03:00
2020-11-05 21:47:55 +00:00
# The name of the signing key. When verifying a package, the signature
# is matched to the public key store in /etc/apk/keys/< key_name > .rsa.pub.
2023-01-11 09:13:38 -03:00
#
2023-04-02 17:16:21 -03:00
# Default: maintainer's email address
2023-07-18 00:44:11 +00:00
# Templates: allowed. (since v1.15)
2020-11-05 21:47:55 +00:00
key_name: origin
2023-01-11 09:13:38 -03:00
2022-11-02 18:30:06 +00:00
archlinux:
# Archlinux-specific scripts
scripts:
# The preupgrade script runs before pacman upgrades the package.
preupgrade: ./scripts/preupgrade.sh
# The postupgrade script runs after pacman upgrades the package.
postupgrade: ./scripts/postupgrade.sh
2022-11-16 09:32:54 -03:00
2022-11-02 18:30:06 +00:00
# The pkgbase can be used to explicitly specify the name to be used to refer
# to a group of packages. See: https://wiki.archlinux.org/title/PKGBUILD#pkgbase .
pkgbase: foo
# The packager refers to the organization packaging the software, not to be confused
# with the maintainer, which is the person who maintains the software.
packager: GoReleaser < staff @goreleaser .com >
2018-02-18 20:37:59 -03:00
```
2020-05-10 18:59:21 -03:00
!!! tip
2023-06-22 09:08:31 -03:00
2020-11-19 12:31:26 -08:00
Learn more about the [name template engine ](/customization/templates/ ).
2022-08-07 12:13:20 -03:00
!!! info
2023-06-22 09:08:31 -03:00
2023-06-05 19:08:57 +03:00
Fields marked with "overridable" can be overridden for any format.
2022-08-22 09:29:55 -03:00
## A note about Termux
Termux is the same format as `deb` , the differences are:
2023-06-22 09:08:31 -03:00
2022-08-22 09:29:55 -03:00
- it uses a different `bindir` (prefixed with `/data/data/com.termux/files/` )
- it uses slightly different architecture names than Debian
2023-11-02 12:32:31 +00:00
## Conventional file names, Debian, and ARMv6
On Debian, both ARMv6 and ARMv7 have the same architecture name: `armhf` .
If you use `{{.ConventionalFileName}}` , and build for both architectures, you'll
get duplicated file names.
You can go around that with something like this:
```yaml
# .goreleaser.yaml
nfpms:
-
# ...
file_name_template: >-
{{- trimsuffix .ConventionalFileName .ConventionalExtension -}}
{{- if and (eq .Arm "6") (eq .ConventionalExtension ".deb") }}6{{ end -}}
{{- if not (eq .Amd64 "v1")}}{{ .Amd64 }}{{ end -}}
{{- .ConventionalExtension -}}
# ...
```