github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/www/docs/customization/nfpm.md (about)

     1  ---
     2  title: NFPM
     3  ---
     4  
     5  GoReleaser can be wired to [nfpm](https://github.com/goreleaser/nfpm) to
     6  generate and publish `.deb`, `.rpm` and `.apk` packages.
     7  
     8  Available options:
     9  
    10  ```yaml
    11  # .goreleaser.yml
    12  nfpms:
    13    # note that this is an array of nfpm configs
    14    -
    15      # ID of the nfpm config, must be unique.
    16      # Defaults to "default".
    17      id: foo
    18  
    19      # Name of the package.
    20      # Defaults to `ProjectName`.
    21      package_name: foo
    22  
    23      # You can change the file name of the package.
    24      # Default: `{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}`
    25      file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
    26  
    27      # Build IDs for the builds you want to create NFPM packages for.
    28      # Defaults to all builds.
    29      builds:
    30        - foo
    31        - bar
    32  
    33      # Replacements for GOOS and GOARCH in the package name.
    34      # Keys should be valid GOOSs or GOARCHs.
    35      # Values are the respective replacements.
    36      # Default is empty.
    37      replacements:
    38        amd64: 64-bit
    39        386: 32-bit
    40        darwin: macOS
    41        linux: Tux
    42  
    43      # Your app's vendor.
    44      # Default is empty.
    45      vendor: Drum Roll Inc.
    46  
    47      # Template to your app's homepage.
    48      # Default is empty.
    49      homepage: https://example.com/
    50  
    51      # Your app's maintainer (probably you).
    52      # Default is empty.
    53      maintainer: Drummer <drum-roll@example.com>
    54  
    55      # Template to your app's description.
    56      # Default is empty.
    57      description: Software to create fast and easy drum rolls.
    58  
    59      # Your app's license.
    60      # Default is empty.
    61      license: Apache 2.0
    62  
    63      # Formats to be generated.
    64      formats:
    65        - apk
    66        - deb
    67        - rpm
    68  
    69      # Packages your package depends on.
    70      dependencies:
    71        - git
    72        - zsh
    73  
    74      # Packages your package recommends installing.
    75      recommends:
    76        - bzr
    77        - gtk
    78  
    79      # Packages your package suggests installing.
    80      suggests:
    81        - cvs
    82        - ksh
    83  
    84      # Packages that conflict with your package.
    85      conflicts:
    86        - svn
    87        - bash
    88  
    89      # Packages it replaces.
    90      replaces:
    91        - fish
    92  
    93      # Template to the path that the binaries should be installed.
    94      # Defaults to `/usr/local/bin`.
    95      bindir: /usr/bin
    96  
    97      # Version Epoch.
    98      # Default is extracted from `version` if it is semver compatible.
    99      epoch: 2
   100  
   101      # Version Prerelease.
   102      # Default is extracted from `version` if it is semver compatible.
   103      prerelease: beta1
   104  
   105      # Version Metadata (previously deb.metadata).
   106      # Default is extracted from `version` if it is semver compatible.
   107      # Setting metadata might interfere with version comparisons depending on the packager.
   108      version_metadata: git
   109  
   110      # Version Release.
   111      release: 1
   112  
   113      # Section.
   114      section: default
   115  
   116      # Priority.
   117      priority: extra
   118  
   119      # Makes a meta package - an empty package that contains only supporting files and dependencies.
   120      # When set to `true`, the `builds` option is ignored.
   121      # Defaults to false.
   122      meta: true
   123  
   124      # Empty folders that should be created and managed by the packager
   125      # implementation.
   126      # Default is empty.
   127      empty_folders:
   128        - /var/log/foobar
   129  
   130      # Contents to add to the package.
   131      # GoReleaser will automatically add the binaries.
   132      contents:
   133        # Basic file that applies to all packagers
   134        - src: path/to/local/foo
   135          dst: /usr/local/bin/foo
   136  
   137        # Simple config file
   138        - src: path/to/local/foo.conf
   139          dst: /etc/foo.conf
   140          type: config
   141  
   142        # Simple symlink.
   143        # Corresponds to `ln -s /sbin/foo /usr/local/bin/foo`
   144        - src: /sbin/foo
   145          dst: /usr/local/bin/foo
   146          type: "symlink"
   147  
   148        # Corresponds to `%config(noreplace)` if the packager is rpm, otherwise it is just a config file
   149        - src: path/to/local/bar.conf
   150          dst: /etc/bar.conf
   151          type: "config|noreplace"
   152  
   153        # The src and dst attributes also supports name templates
   154        - src: path/{{ .Os }}-{{ .Arch }}/bar.conf
   155          dst: /etc/foo/bar-{{ .ProjectName }}.conf
   156  
   157        # These files are not actually present in the package, but the file names
   158        # are added to the package header. From the RPM directives documentation:
   159        #
   160        # "There are times when a file should be owned by the package but not
   161        # installed - log files and state files are good examples of cases you might
   162        # desire this to happen."
   163        #
   164        # "The way to achieve this, is to use the %ghost directive. By adding this
   165        # directive to the line containing a file, RPM will know about the ghosted
   166        # file, but will not add it to the package."
   167        #
   168        # For non rpm packages ghost files are ignored at this time.
   169        - dst: /etc/casper.conf
   170          type: ghost
   171        - dst: /var/log/boo.log
   172          type: ghost
   173  
   174        # You can user the packager field to add files that are unique to a specific packager
   175        - src: path/to/rpm/file.conf
   176          dst: /etc/file.conf
   177          type: "config|noreplace"
   178          packager: rpm
   179        - src: path/to/deb/file.conf
   180          dst: /etc/file.conf
   181          type: "config|noreplace"
   182          packager: deb
   183        - src: path/to/apk/file.conf
   184          dst: /etc/file.conf
   185          type: "config|noreplace"
   186          packager: apk
   187  
   188        # Sometimes it is important to be able to set the mtime, mode, owner, or group for a file
   189        # that differs from what is on the local build system at build time.
   190        - src: path/to/foo
   191          dst: /usr/local/foo
   192          file_info:
   193            mode: 0644
   194            mtime: 2008-01-02T15:04:05Z
   195            owner: notRoot
   196            group: notRoot
   197  
   198      # Scripts to execute during the installation of the package.
   199      # Keys are the possible targets during the installation process
   200      # Values are the paths to the scripts which will be executed
   201      scripts:
   202        preinstall: "scripts/preinstall.sh"
   203        postinstall: "scripts/postinstall.sh"
   204        preremove: "scripts/preremove.sh"
   205        postremove: "scripts/postremove.sh"
   206  
   207      # Some attributes can be overridden per package format.
   208      overrides:
   209        deb:
   210          conflicts:
   211            - subversion
   212          dependencies:
   213            - git
   214          suggests:
   215            - gitk
   216          recommends:
   217            - tig
   218          replaces:
   219            - bash
   220          empty_folders:
   221            - /var/log/bar
   222        rpm:
   223          replacements:
   224            amd64: x86_64
   225          file_name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Arch }}"
   226          files:
   227            "tmp/man.gz": "/usr/share/man/man8/app.8.gz"
   228          config_files:
   229            "tmp/app_generated.conf": "/etc/app-rpm.conf"
   230          scripts:
   231            preinstall: "scripts/preinstall-rpm.sh"
   232  
   233      # Custom configuration applied only to the RPM packager.
   234      rpm:
   235        # RPM specific scripts.
   236        scripts:
   237          # The pretrans script runs before all RPM package transactions / stages.
   238          pretrans: ./scripts/pretrans.sh
   239          # The posttrans script runs after all RPM package transactions / stages.
   240          posttrans: ./scripts/posttrans.sh
   241  
   242        # The package summary.
   243        # Defaults to the first line of the description.
   244        summary: Explicit Summary for Sample Package
   245  
   246        # The package group. This option is deprecated by most distros
   247        # but required by old distros like CentOS 5 / EL 5 and earlier.
   248        group: Unspecified
   249  
   250        # Compression algorithm.
   251        compression: lzma
   252  
   253        # These config files will not be replaced by new versions if they were
   254        # changed by the user. Corresponds to %config(noreplace).
   255        config_noreplace_files:
   256          path/to/local/bar.con: /etc/bar.conf
   257  
   258        # These files are not actually present in the package, but the file names
   259        # are added to the package header. From the RPM directives documentation:
   260        #
   261        # "There are times when a file should be owned by the package but not
   262        # installed - log files and state files are good examples of cases you might
   263        # desire this to happen."
   264        #
   265        # "The way to achieve this, is to use the %ghost directive. By adding this
   266        # directive to the line containing a file, RPM will know about the ghosted
   267        # file, but will not add it to the package."
   268        ghost_files:
   269          - /etc/casper.conf
   270          - /var/log/boo.log
   271  
   272        # The package is signed if a key_file is set
   273        signature:
   274          # Template to the PGP secret key file path (can also be ASCII-armored).
   275          # The passphrase is taken from the environment variable
   276          # `$NFPM_ID_RPM_PASSPHRASE` with a fallback to `$NFPM_ID_PASSPHRASE`,
   277          # where ID is the id of the current nfpm config.
   278          # The id will be transformed to uppercase.
   279          # E.g. If your nfpm id is 'default' then the rpm-specific passphrase
   280          # should be set as `$NFPM_DEFAULT_RPM_PASSPHRASE`
   281          key_file: '{{ .Env.GPG_KEY_PATH }}'
   282  
   283      # Custom configuration applied only to the Deb packager.
   284      deb:
   285        # Custom deb special files.
   286        scripts:
   287          # Deb rules script.
   288          rules: foo.sh
   289          # Deb templates file, when using debconf.
   290          templates: templates
   291  
   292        # Custom deb triggers
   293        triggers:
   294          # register interrest on a trigger activated by another package
   295          # (also available: interest_await, interest_noawait)
   296          interest:
   297            - some-trigger-name
   298          # activate a trigger for another package
   299          # (also available: activate_await, activate_noawait)
   300          activate:
   301            - another-trigger-name
   302  
   303        # Packages which would break if this package would be installed.
   304        # The installation of this package is blocked if `some-package`
   305        # is already installed.
   306        breaks:
   307          - some-package
   308  
   309        # The package is signed if a key_file is set
   310        signature:
   311          # Template to the PGP secret key file path (can also be ASCII-armored).
   312          # The passphrase is taken from the environment variable
   313          # `$NFPM_ID_DEB_PASSPHRASE` with a fallback to `$NFPM_ID_PASSPHRASE`,
   314          # where ID is the id of the current nfpm config.
   315          # The id will be transformed to uppercase.
   316          # E.g. If your nfpm id is 'default' then the deb-specific passphrase
   317          # should be set as `$NFPM_DEFAULT_DEB_PASSPHRASE`
   318          key_file: '{{ .Env.GPG_KEY_PATH }}'
   319  
   320          # The type describes the signers role, possible values are "origin",
   321          # "maint" and "archive". If unset, the type defaults to "origin".
   322          type: origin
   323  
   324      apk:
   325        # APK specific scripts.
   326        scripts:
   327          # The preupgrade script runs before APK upgrade.
   328          preupgrade: ./scripts/preupgrade.sh
   329          # The postupgrade script runs after APK.
   330          postupgrade: ./scripts/postupgrade.sh
   331  
   332        # The package is signed if a key_file is set
   333        signature:
   334          # Template to the PGP secret key file path (can also be ASCII-armored).
   335          # The passphrase is taken from the environment variable
   336          # `$NFPM_ID_APK_PASSPHRASE` with a fallback to `$NFPM_ID_PASSPHRASE`,
   337          # where ID is the id of the current nfpm config.
   338          # The id will be transformed to uppercase.
   339          # E.g. If your nfpm id is 'default' then the apk-specific passphrase
   340          # should be set as `$NFPM_DEFAULT_APK_PASSPHRASE`
   341          key_file: '{{ .Env.GPG_KEY_PATH }}'
   342  
   343  
   344          # The name of the signing key. When verifying a package, the signature
   345          # is matched to the public key store in /etc/apk/keys/<key_name>.rsa.pub.
   346          # If unset, it defaults to the maintainer email address.
   347          key_name: origin
   348  ```
   349  
   350  !!! tip
   351      Learn more about the [name template engine](/customization/templates/).