Snap

Snaps 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, with automatic and transactional updates.

You can read more about it in the snapcraft docs.

The following artifact extensions are supported by this packager:

  • .tbz2

  • .tgz

  • .txz

  • .tar.gz

  • .tar.xz

  • .tar.bz2

  • .tar

  • .jar

  • .deb

  • .rpm

Distribution Support

Distribution Supported

Binary

Flat Binary

Java Binary

Jlink

Native Image

Native Package

Single JAR

Publication of snapshots is not allowed.
Building local snaps requires snapcraft to be pre-installed. JReleaser will not install it nor its dependencies. If you rather package and push on CI then set remoteBuild to true.

Configuration

Legend:

  • required

  • optional

  • may use environment variable

  • accepts Name Templates

  • YAML

  • TOML

  • JSON

  • Maven

  • Gradle

# 
packagers:
  # 
  snap:
    # Enables or disables Snap.
    # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
    # Defaults to `NEVER`.
    #  
    active: ALWAYS

    # Let the release continue if the packager fails.
    # Defaults to `false`.
    # 
    continueOnError: true

    # Custom download URL.
    #  
    downloadUrl: https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}

    # Additional properties used when evaluating templates.
    #  
    extraProperties:
      # Key will be capitalized and prefixed with `snap`, i.e, `snapFoo`.
      foo: bar

    # Directory with file templates used to prepare the Snap distribution.
    # Defaults to `src/jreleaser/distributions/#{distribution.name}/snap`.
    # If specified, path must exist.
    # 
    templateDirectory: path/to/snap/templates

    # List of template files to be skipped.
    # Value may be an exact match or a regex.
    # 
    skipTemplates:
      - README.md.tpl

    # Git author used to commit to the repository.
    # 
    commitAuthor:
      # Name used when authoring commits.
      # Defaults to `jreleaserbot`.
      # 
      name: jreleaserbot

      # E-mail used when authoring commits.
      # Defaults to `jreleaser@kordamp.org`.
      # 
      email: jreleaser@kordamp.org

    # Git repository to push the manifest to.
    # Defaults are shown.
    # 
    repository:
      # Enables or disables the repository.
      # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      # Defaults to `RELEASE`.
      # 
      active: ALWAYS


      # The owner of the repository.
      # Defaults to the same owner as the release repository.
      # 
      owner: duke

      # The name of the repository.
      # Defaults to `app-snap`.
      # 
      name: app-snap

      # The tag associated with the manifest.
      # If left unspecified, will use `{{tagName}}`.
      #  
      tagName: '{{distributionName}}-{{tagName}}'

      # The target branch to pull from.
      # Defaults to the branch pointed by HEAD.
      #  
      branch: HEAD

      # The target branch to push to.
      # Defaults to the branch pointed by `#{branch}`.
      #   
      branchPush: '{{projectName}}-{{tagName}}'

      # Username used for authoring commits.
      # Must have write access to the repository.
      # Defaults to the same username as the release repository.
      #  
      username: duke

      # Password or OAuth token with write access to the repository.
      #  
      token: __USE_ENVIRONMENT_VARIABLE__

      # Message when committing to the repository.
      # If left unspecified, `{{distributionName}} {{tagName}}` will be used.
      #  
      commitMessage: '{{distributionName}} {{tagName}}'

      # Additional properties used when evaluating templates.
      #  
      extraProperties:
        # Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
        foo: bar

    # Name of the Snap package.
    # Defaults to `#{distribution.name}`.
    # 
    packageName: app

    # Exported snapcraft login credentials.
    # Will be sent to local snapcraft build with `snapcraft login --with #{exportedLogin}`.
    # Required if `remoteBuild` is set to `false`.
    exportedLogin: path/to/login/file

    # Whether to build the package on a remote server or locally.
    # If set to `true` then the package must be configured to be built
    # via https://snapcraft.io.
    # Review the docs at https://snapcraft.io/build.
    # Defaults to `false`.
    # 
    remoteBuild: false

    # A snap of type base to be used as the execution environment for this snap.
    # Supported values are:
    # * bare - Empty base snap;
    # * core - Ubuntu Core 16;
    # * core20 - Ubuntu Core 20.
    # Defaults to `core20`.
    # 
    base: core20

    # 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`
    # channels. More info about channels here:
    # https://snapcraft.io/docs/reference/channels.
    # Defaults to `stable`.
    # 
    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.
    # Defaults to `strict`.
    # 
    confinement: strict

    # List of plug names the application is associated with.
    # When a plug is connected to one of these slots, the application
    # will be granted the permissions specified for that interface.
    # If attributes are required, or the plug name does not match the
    # interface name, more details must be declared in the `plugs` field.
    # https://snapcraft.io/docs/reference/interfaces.
    # 
    localPlugs:
      - some_plug_name

    # List of slot names the application is associated with.
    # When a plug is connected to one of these slots, the application
    # will be granted the permissions specified for that interface.
    # If attributes are required, or the slot name does not match the
    # interface name, more details must be declared in the `slots` field.
    # https://snapcraft.io/docs/reference/interfaces.
    # 
    localSlots:
      - some_slot_name

    # Allows plugs to be configured.
    # 
    plugs:
      some_plug_name:
        key: value
        reads:
        - $HOME/.foo
        writes:
        - $HOME/.foo
        - $HOME/.foobar

    # Allows slots to be configured.
    # 
    slots:
      some_slot_name:
        key: value
        reads:
        - $HOME/.foo
        writes:
        - $HOME/.foo
        - $HOME/.foobar

    # Configures build/run architectures
    # More details can be found at https://snapcraft.io/docs/architectures
    # Default is empty
    # 
    architectures:
        # 
      - buildOn: [amd64]
        # 
        runOn: [am64]
        # 
        ignoreError: true
# 
[packagers.snap]
  # Enables or disables Snap.
  # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `NEVER`.
  #  
  active = "ALWAYS"

  # Let the release continue if the packager fails.
  # Defaults to `false`.
  # 
  continueOnError = true

  # Custom download URL.
  #  
  downloadUrl = "https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}"

  # Additional properties used when evaluating templates.
  #  
  extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `snap`, i.e, `snapFoo`.

  # Directory with file templates used to prepare the Snap distribution.
  # Defaults to `src/jreleaser/distributions/#{distribution.name}/snap`.
  # If specified, path must exist.
  # 
  templateDirectory = "path/to/snap/templates"

  # List of template files to be skipped.
  # Value may be an exact match or a regex.
  # 
  skipTemplates = [ "README.md.tpl" ]

  # Git author used to commit to the repository.

  # Name used when authoring commits.
  # Defaults to `jreleaserbot`.
  # 
  commitAuthor.name = "jreleaserbot"

  # E-mail used when authoring commits.
  # Defaults to `jreleaser@kordamp.org`.
  # 
  commitAuthor.email = "jreleaser@kordamp.org"

  # Git repository to push the manifest to.
  # Defaults are shown.

  # Enables or disables the repository.
  # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `RELEASE`.
  # 
  repository.active = "ALWAYS"


  # The owner of the repository.
  # Defaults to the same owner as the release repository.
  # 
  repository.owner = "duke"

  # The name of the repository.
  # Defaults to `app-snap`.
  # 
  repository.name = "app-snap"

  # The tag associated with the manifest.
  # If left unspecified, will use `{{tagName}}`.
  #  
  repository.tagName = "{{distributionName}}-{{tagName}}"

  # The target branch to pull from.
  # Defaults to the branch pointed by HEAD.
  #  
  repository.branch = "HEAD"

  # The target branch to push to.
  # Defaults to the branch pointed by `#{branch}`.
  #    
  repository.branchPush = "{{projectName}}-{{tagName}}"

  # Username used for authoring commits.
  # Must have write access to the repository.
  # Defaults to the same username as the release repository.
  #  
  repository.username = "duke"

  # Password or OAuth token with write access to the repository.
  #  
  repository.token = "__USE_ENVIRONMENT_VARIABLE__"

  # Message when committing to the repository.
  # If left unspecified, `{{distributionName}} {{tagName}}` will be used.
  #  
  repository.commitMessage = "{{distributionName}} {{tagName}}"

  # Additional properties used when evaluating templates.
  #  
  repository.extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.

  # Name of the Snap package.
  # Defaults to `#{distribution.name}`.
  # 
  packageName = "app"

  # Exported snapcraft login credentials.
  # Will be sent to local snapcraft build with `snapcraft login --with #{exportedLogin}`.
  # Required if `remoteBuild` is set to `false`.
  exportedLogin = "path/to/login/file"

  # Whether to build the package on a remote server or locally.
  # If set to `true` then the package must be configured to be built
  # via https://snapcraft.io.
  # Review the docs at https://snapcraft.io/build.
  # Defaults to `false`.
  # 
  remoteBuild = false

  # A snap of type base to be used as the execution environment for this snap.
  # Supported values are:
  # * bare - Empty base snap;
  # * core - Ubuntu Core 16;
  # * core20 - Ubuntu Core 20.
  # Defaults to `core20`.
  # 
  base = "core20"

  # 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`
  # channels. More info about channels here:
  # https://snapcraft.io/docs/reference/channels.
  # Defaults to `stable`.
  # 
  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.
  # Defaults to `strict`.
  # 
  confinement = "strict"

  # List of plug names the application is associated with.
  # When a plug is connected to one of these slots, the application
  # will be granted the permissions specified for that interface.
  # If attributes are required, or the plug name does not match the
  # interface name, more details must be declared in the `plugs` field.
  # https://snapcraft.io/docs/reference/interfaces.
  # 
  localPlugs = ["some_plug_name"]

  # List of slot names the application is associated with.
  # When a plug is connected to one of these slots, the application
  # will be granted the permissions specified for that interface.
  # If attributes are required, or the slot name does not match the
  # interface name, more details must be declared in the `slots` field.
  # https://snapcraft.io/docs/reference/interfaces.
  # 
  localSlots = ["some_slot_name"]

  # Allows plugs to be configured.
  # 
  [packagers.snap.plugs]
    some_plug_name.key = "value"
    some_plug_name.reads = ["$HOME/.foo"]
    some_plug_name.writes = ["$HOME/.foo", "$HOME/.foobar"]

  # Allows slots to be configured.
  # 
  [packagers.snap.slots]
    some_slot_name.key = "value"
    some_slot_name.reads = ["$HOME/.foo"]
    some_slot_name.writes = ["$HOME/.foo", "$HOME/.foobar"]

  # Configures build/run architectures
  # More details can be found at https://snapcraft.io/docs/architectures
  # Default is empty
  # 
  [[packagers.snap.architectures]]
    # 
    buildOn = ["amd64"]
    # 
    runOn = ["am64"]
    # 
    ignoreError = true
{
  // 
  "packagers": {
    // 
    "snap": {
      // Enables or disables Snap.
      // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      // Defaults to `NEVER`.
      //  
      "active": "ALWAYS",

      // Let the release continue if the packager fails.
      // Defaults to `false`.
      // 
      "continueOnError": true,

      // Custom download URL.
      //  
      "downloadUrl": "https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}",

      // Additional properties used when evaluating templates.
      //  
      "extraProperties": {
        // Key will be capitalized and prefixed with `snap`, i.e, `snapFoo`.
        "foo": "bar"
      },

      // Directory with file templates used to prepare the Snap distribution.
      // Defaults to `src/jreleaser/distributions/#{distribution.name}/snap`.
      // If specified, path must exist.
      // 
      "templateDirectory": "path/to/snap/templates",

      // List of template files to be skipped.
      // Value may be an exact match or a regex.
      // 
      "skipTemplates": [
        "README.md.tpl"
      ],

      // Git author used to commit to the repository.
      // 
      "commitAuthor": {
        // Name used when authoring commits.
        // Defaults to `jreleaserbot`.
        // 
        "name": "jreleaserbot",

        // E-mail used when authoring commits.
        // Defaults to `jreleaser@kordamp.org`.
        // 
        "email": "jreleaser@kordamp.org"
      },

      // Git repository to push the manifest to.
      // Defaults are shown.
      // 
      "repository": {
        // Enables or disables the repository.
        // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `RELEASE`.
        // 
        "active": "ALWAYS",


        // The owner of the repository.
        // Defaults to the same owner as the release repository.
        // 
        "owner": "duke",

        // The name of the repository.
        // Defaults to `app-snap`.
        // 
        "name": "app-snap",

        // The tag associated with the manifest.
        // If left unspecified, will use `{{tagName}}`.
        //  
        "tagName": "{{distributionName}}-{{tagName}}",

        // The target branch to pull from.
        // Defaults to the branch pointed by HEAD.
        //  
        "branch": "HEAD",

        // The target branch to push to.
        // Defaults to the branch pointed by `#{branch}`.
        //   
        "branchPush": "{{projectName}}-{{tagName}}",

        // Username used for authoring commits.
        // Must have write access to the repository.
        // Defaults to the same username as the release repository.
        //  
        "username": "duke",

        // Password or OAuth token with write access to the repository.
        //  
        "token": "__USE_ENVIRONMENT_VARIABLE__",

        // Message when committing to the repository.
        // If left unspecified, `{{distributionName}} {{tagName}}` will be used.
        //  
        "commitMessage": "{{distributionName}} {{tagName}}",

        // Additional properties used when evaluating templates.
        //  
        "extraProperties": {
          // Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
          "foo": "bar"
        }
      },

      // Name of the Snap package.
      // Defaults to `#{distribution.name}`.
      // 
      "packageName": "app",

      // Exported snapcraft login credentials.
      // Will be sent to local snapcraft build with `snapcraft login --with #{exportedLogin}`.
      // Required if `remoteBuild` is set to `false`.
      "exportedLogin": "path/to/login/file",

      // Whether to build the package on a remote server or locally.
      // If set to `true` then the package must be configured to be built
      // via https://snapcraft.io.
      // Review the docs at https://snapcraft.io/build.
      // Defaults to `false`.
      // 
      "remoteBuild": false,

      // A snap of type base to be used as the execution environment for this snap.
      // Supported values are:
      // * bare - Empty base snap;
      // * core - Ubuntu Core 16;
      // * core20 - Ubuntu Core 20.
      // Defaults to `core20`.
      // 
      "base": "core20",

      // 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`
      // channels. More info about channels here:
      // https://snapcraft.io/docs/reference/channels.
      // Defaults to `stable`.
      // 
      "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.
      // Defaults to `strict`.
      // 
      "confinement": "strict",

      // List of plug names the application is associated with.
      // When a plug is connected to one of these slots, the application
      // will be granted the permissions specified for that interface.
      // If attributes are required, or the plug name does not match the
      // interface name, more details must be declared in the `plugs` field.
      // https://snapcraft.io/docs/reference/interfaces.
      // 
      "localPlugs" [
        "some_plug_name"
      ],

      // List of slot names the application is associated with.
      // When a plug is connected to one of these slots, the application
      // will be granted the permissions specified for that interface.
      // If attributes are required, or the slot name does not match the
      // interface name, more details must be declared in the `slots` field.
      // https://snapcraft.io/docs/reference/interfaces.
      // 
      "localSlots" [
        "some_slot_name"
      ],

      // Allows plugs to be configured.
      // 
      "plugs": [
        {
          "some_plug_name": {
            "key": "value",
            "reads": [
              "$HOME/.foo"
            ],
            "writes": [
              "$HOME/.foo",
              "$HOME/.foobar"
            ]
          }
        }
      ],

      // Allows slots to be configured.
      // 
      "slots": [
        {
          "some_slot_name": {
            "key": "value",
            "reads": [
              "$HOME/.foo"
            ],
            "writes": [
              "$HOME/.foo",
              "$HOME/.foobar"
            ]
          }
        }
      ],

      // Configures build/run architectures
      // More details can be found at https://snapcraft.io/docs/architectures
      // Default is empty
      // 
      "architectures": [
        {
          // 
          "buildOn": ["amd64"],
          // 
          "runOn": ["am64"],
          // 
          "ignoreError": true
        }
      ]
    }
  }
}
<jreleaser>
  <!--
    
  -->
  <packagers>
    <!--
      
    -->
    <snap>
      <!--
        Enables or disables Snap.
        Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        Defaults to `NEVER`.
         
      -->
      <active>ALWAYS</active>

      <!--
        Let the release continue if the packager fails.
        Defaults to `false`.
        
      -->
      <continueOnError>true</continueOnError>

      <!--
        Custom download URL.
         
      -->
      <downloadUrl>https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}</downloadUrl>

      <!--
        Additional properties used when evaluating templates.
         
      -->
      <extraProperties>
        <!--
          Key will be capitalized and prefixed with `snap`, i.e, `snapFoo`.
        -->
        <foo>bar</foo>
      </extraProperties>

      <!--
        Directory with file templates used to prepare the Snap distribution.
        Defaults to `src/jreleaser/distributions/#{distribution.name}/snap`.
        If specified, path must exist.
        
      -->
      <templateDirectory>path/to/snap/templates</templateDirectory>

      <!--
        List of template files to be skipped.
        Value may be an exact match or a regex.
        
      -->
      <skipTemplates>
        <skipTemplate>README.md.tpl</skipTemplate>
      </skipTemplates>

      <!--
        Git author used to commit to the repository.
        
      -->
      <commitAuthor>

        <!--
           Name used when authoring commits.
          Defaults to `jreleaserbot`.
          
        -->
        <name>jreleaserbot</name>

        <!--
          E-mail used when authoring commits.
          Defaults to `jreleaser@kordamp.org`.
          
        -->
        <email>jreleaser@kordamp.org</email>
      </commitAuthor>

      <!--
        Git repository to push the manifest to.
        Defaults are shown.
        
      -->
      <repository>
        <!--
          Enables or disables the repository.
          Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
          Defaults to `RELEASE`.
          
        -->
        <active>ALWAYS</active>


        <!--
          The owner of the repository.
          Defaults to the same owner as the release repository.
          
        -->
        <owner>duke</owner>

        <!--
          The name of the repository.
          Defaults to `app-snap`.
          
        -->
        <name>app-snap</name>

        <!--
          The tag associated with the manifest.
          If left unspecified, will use `{{tagName}}`.
           
        -->
        <tagName>{{distributionName}}-{{tagName}}</tagName>

        <!--
          The target branch to pull from.
          Defaults to the branch pointed by HEAD.
           
        -->
        <branch>HEAD</branch>

        <!--
          The target branch to push to.
          Defaults to the branch pointed by `#{branch}`.
            
        -->
        <branchPush>{{projectName}}-{{tagName}}</branchPush>

        <!--
          Username used for authoring commits.
          Must have write access to the repository.
          Defaults to the same username as the release repository.
           
        -->
        <username>duke</username>

        <!--
          Password or OAuth token with write access to the repository.
           
        -->
        <token>__USE_ENVIRONMENT_VARIABLE__</token>

        <!--
          Message when committing to the repository.
          If left unspecified, `{{distributionName}} {{tagName}}` will be used.
           
        -->
        <commitMessage>{{distributionName}} {{tagName}}</commitMessage>

        <!--
          Additional properties used when evaluating templates.
           
        -->
        <extraProperties>
          <!--
            Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
          -->
          <foo>bar</foo>
        </extraProperties>
      </repository>

      <!--
        Name of the Snap package.
        Defaults to `#{distribution.name}`.
        
      -->
      <packageName>app</packageName>

      <!--
        Exported snapcraft login credentials.
        Will be sent to local snapcraft build with `snapcraft login --with #{exportedLogin}`.
        Required if `remoteBuild` is set to `false`.
      -->
      <exportedLogin>path/to/login/file</exportedLogin>

      <!--
        Whether to build the package on a remote server or locally.
        If set to `true` then the package must be configured to be built
        via https://snapcraft.io.
        Review the docs at https://snapcraft.io/build.
        Defaults to `false`.
        
      -->
      <remoteBuild>false</remoteBuild>

      <!--
        A snap of type base to be used as the execution environment for this snap.
        Supported values are:
        * bare - Empty base snap;
        * core - Ubuntu Core 16;
        * core20 - Ubuntu Core 20.
        Defaults to `core20`.
        
      -->
      <base>core20</base>

      <!--
        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`
        channels. More info about channels here:
        https://snapcraft.io/docs/reference/channels.
        Defaults to `stable`.
        
      -->
      <grade>stable</grade>

      <!--
        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.
        Defaults to `strict`.
        
      -->
      <confinement>strict</confinement>

      <!--
        List of plug names the application is associated with.
        When a plug is connected to one of these slots, the application
        will be granted the permissions specified for that interface.
        If attributes are required, or the plug name does not match the
        interface name, more details must be declared in the `plugs` field.
        https://snapcraft.io/docs/reference/interfaces.
        
      -->
      <localPlugs>
        <localPlug>some_plug_name</localPlug>
      </localPlugs>

      <!--
        List of slot names the application is associated with.
        When a plug is connected to one of these slots, the application
        will be granted the permissions specified for that interface.
        If attributes are required, or the slot name does not match the
        interface name, more details must be declared in the `slots` field.
        https://snapcraft.io/docs/reference/interfaces.
        
      -->
      <localSlots>
        <localSlot>some_slot_name</localSlot>
      </localSlots>

      <!--
        Allows plugs to be configured.
        
      -->
      <plugs>
        <plug>
          <name>some_plug_name</name>
          <attributes>
            <key>value</key>
          </attributes>
          <reads>
            <read>$HOME/.foo</read>
          </reads>
          <writes>
            <write>$HOME/.foo</write>
            <write>$HOME/.foobar</write>
          </writes>
        </plug>
      </plugs>

      <!--
        Allows slots to be configured.
        
      -->
      <slots>
        <slot>
          <name>some_slot_name</name>
          <attributes>
            <key>value</key>
          </attributes>
          <reads>
            <read>$HOME/.foo</read>
          </reads>
          <writes>
            <write>$HOME/.foo</write>
            <write>$HOME/.foobar</write>
          </writes>
        </slot>
      </slots>

      <!--
       // Configures build/run architectures
        More details can be found at https://snapcraft.io/docs/architectures
        Default is empty
        
      -->
      <architectures>
        <architecture>
          <!--
            
          -->
          <buildOn>amd64</buildOn>
          <!--
            
          -->
          <runOn>am64</runOn>
          <!--
            
          -->
          <ignoreError>true</ignoreError>
        </architecture>
      </architectures>
    </snap>
  </packagers>
</jreleaser>
jreleaser {
  // 
  packagers {
    // 
    snap {
      // Enables or disables Snap.
      // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      // Defaults to `NEVER`.
      //  
      active = 'ALWAYS'

      // Let the release continue if the packager fails.
      // Defaults to `false`.
      // 
      continueOnError = true

      // Custom download URL.
      //  
      downloadUrl = 'https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFile}}'

      // Additional properties used when evaluating templates.
      // Key will be capitalized and prefixed with `snap`, i.e, `snapFoo`.
      //  
      extraProperties.put('foo', 'bar')

      // Directory with file templates used to prepare the Snap distribution.
      // Defaults to `src/jreleaser/distributions/#{distribution.name}/snap`.
      // If specified, path must exist.
      // 
      templateDirectory = 'path/to/snap/templates'

      // List of template files to be skipped.
      // Value may be an exact match or a regex.
      // 
      skipTemplate('README.md.tpl')

      // Git author used to commit to the repository.
      // 
      commitAuthor {
        // Name used when authoring commits.
        // Defaults to `jreleaserbot`.
        // 
        name = 'jreleaserbot'

        // E-mail used when authoring commits.
        // Defaults to `jreleaser@kordamp.org`.
        // 
        email = 'jreleaser@kordamp.org'
      }

      // Git repository to push the manifest to.
      // Defaults are shown.
      // 
      repository {
        // Enables or disables the repository.
        // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `RELEASE`.
        // 
        active = 'ALWAYS'


        // The owner of the repository.
        // Defaults to the same owner as the release repository.
        // 
        repoOwner = 'duke'

        // The name of the repository.
        // Defaults to `app-snap`.
        // 
        name = 'app-snap'

        // The tag associated with the manifest.
        // If left unspecified, will use `{{tagName}}`.
        //  
        tagName = '{{distributionName}}-{{tagName}}'

        // The target branch to pull from.
        // Defaults to the branch pointed by HEAD.
        //  
        branch = 'HEAD'

        // The target branch to push to.
        // Defaults to the branch pointed by `#{branch}`.
        //   
        branchPush = '{{projectName}}-{{tagName}}'

        // Username used for authoring commits.
        // Must have write access to the repository.
        // Defaults to the same username as the release repository.
        //  
        username = 'duke'

        // Password or OAuth token with write access to the repository.
        //  
        token = '__USE_ENVIRONMENT_VARIABLE__'

        // Message when committing to the repository.
        // If left unspecified, `{{distributionName}} {{tagName}}` will be used.
        //  
        commitMessage = '{{distributionName}} {{tagName}}'

        // Additional properties used when evaluating templates.
        // Key will be capitalized and prefixed with `repository`, i.e, `repositoryFoo`.
        //  
        extraProperties.put('foo', 'bar')
      }

      // Name of the Snap package.
      // Defaults to `#{distribution.name}`.
      // 
      packageName = 'app'

      // Exported snapcraft login credentials.
      // Will be sent to local snapcraft build with `snapcraft login --with #{exportedLogin}`.
      // Required if `remoteBuild` is set to `false`.
      exportedLogin = 'path/to/login/file'

      // Whether to build the package on a remote server or locally.
      // If set to `true` then the package must be configured to be built
      // via https://snapcraft.io.
      // Review the docs at https://snapcraft.io/build.
      // Defaults to `false`.
      // 
      remoteBuild = false

      // A snap of type base to be used as the execution environment for this snap.
      // Supported values are:
      // * bare - Empty base snap;
      // * core - Ubuntu Core 16;
      // * core20 - Ubuntu Core 20.
      // Defaults to `core20`.
      // 
      base = 'core20'

      // 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`
      // channels. More info about channels here:
      // https://snapcraft.io/docs/reference/channels.
      // Defaults to `stable`.
      // 
      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.
      // Defaults to `strict`.
      // 
      confinement = 'strict'

      // List of plug names the application is associated with.
      // When a plug is connected to one of these slots, the application
      // will be granted the permissions specified for that interface.
      // If attributes are required, or the plug name does not match the
      // interface name, more details must be declared in the `plugs` field.
      // https://snapcraft.io/docs/reference/interfaces.
      // 
      localPlug('some_plug_name')

      // List of slot names the application is associated with.
      // When a plug is connected to one of these slots, the application
      // will be granted the permissions specified for that interface.
      // If attributes are required, or the slot name does not match the
      // interface name, more details must be declared in the `slots` field.
      // https://snapcraft.io/docs/reference/interfaces.
      // 
      localSlot('some_slot_name')

      // Allows plugs to be configured.
      // 
      plugs {
        some_plug_name {
          attribute('key', 'value')
          read('$HOME/.foo')
          write('$HOME/.foo')
          write('$HOME/.foobar')
        }
      }

      // Allows slots to be configured.
      // 
      slots {
        some_slot_name {
          attribute('key', 'value')
          read('$HOME/.foo')
          write('$HOME/.foo')
          write('$HOME/.foobar')
        }
      }

      // Configures build/run architectures
      // More details can be found at https://snapcraft.io/docs/architectures
      // Default is empty
      // 
      architecture {
        // 
        buildOn = ['amd64']
        // 
        runOn = ['am64']
        // 
        ignoreError = true
      }
    }
  }
}

Environment

When not explicitly set, the value of the following properties may be resolved from an environment variable or a system property as shown in the table. The system property takes precedence over the environment variable.

Inside packagers section

System Property Environment Variable

active

jreleaser.packagers.snap.active

JRELEASER_PACKAGERS_SNAP_ACTIVE

Inside distributions section

System Property Environment Variable

active

jreleaser.distributions.${name}.snap.active

JRELEASER_DISTRIBUTIONS_${name}_SNAP_ACTIVE

repository.active

jreleaser.distributions.${name}.snap.repository.active

JRELEASER_DISTRIBUTIONS_${name}_SNAP_REPOSITORY_ACTIVE

repository.username

jreleaser.distributions.${name}.snap.repository.username
jreleaser.snap.github.username
jreleaser.snap.gitlab.username
jreleaser.snap.gitea.username
jreleaser.snap.codeberg.username
jreleaser.github.username
jreleaser.gitlab.username
jreleaser.gitea.username
jreleaser.codeberg.username

JRELEASER_DISTRIBUTIONS_${name}_SNAP_REPOSITORY_USERNAME
JRELEASER_SNAP_GITHUB_USERNAME
JRELEASER_SNAP_GITLAB_USERNAME
JRELEASER_SNAP_GITEA_USERNAME
JRELEASER_SNAP_CODEBERG_USERNAME
JRELEASER_GITHUB_USERNAME
JRELEASER_GITLAB_USERNAME
JRELEASER_GITEA_USERNAME
JRELEASER_CODEBERG_USERNAME

repository.token

jreleaser.distributions.${name}.snap.repository.token
jreleaser.snap.github.token
jreleaser.snap.gitlab.token
jreleaser.snap.gitea.token
jreleaser.snap.codeberg.token
jreleaser.github.token
jreleaser.gitlab.token
jreleaser.gitea.token
jreleaser.codeberg.token

JRELEASER_DISTRIBUTIONS_${name}_SNAP_REPOSITORY_TOKEN
JRELEASER_SNAP_GITHUB_TOKEN
JRELEASER_SNAP_GITLAB_TOKEN
JRELEASER_SNAP_GITEA_TOKEN
JRELEASER_SNAP_CODEBERG_TOKEN
JRELEASER_GITHUB_TOKEN
JRELEASER_GITLAB_TOKEN
JRELEASER_GITEA_TOKEN
JRELEASER_CODEBERG_TOKEN

repository.branch

jreleaser.distributions.${name}.snap.repository.branch
jreleaser.snap.github.branch
jreleaser.snap.gitlab.branch
jreleaser.snap.gitea.branch
jreleaser.snap.codeberg.branch
jreleaser.github.branch
jreleaser.gitlab.branch
jreleaser.gitea.branch
jreleaser.codeberg.branch

JRELEASER_DISTRIBUTIONS_${name}_SNAP_REPOSITORY_BRANCH
JRELEASER_SNAP_GITHUB_BRANCH
JRELEASER_SNAP_GITLAB_BRANCH
JRELEASER_SNAP_GITEA_BRANCH
JRELEASER_SNAP_CODEBERG_BRANCH
JRELEASER_GITHUB_BRANCH
JRELEASER_GITLAB_BRANCH
JRELEASER_GITEA_BRANCH
JRELEASER_CODEBERG_BRANCH

repository.branchPush

jreleaser.distributions.${name}.snap.repository.branch.push
jreleaser.snap.github.branch.push
jreleaser.snap.gitlab.branch.push
jreleaser.snap.gitea.branch.push
jreleaser.snap.codeberg.branch.push
jreleaser.github.branch.push
jreleaser.gitlab.branch.push
jreleaser.gitea.branch.push
jreleaser.codeberg.branch.push

JRELEASER_DISTRIBUTIONS_${name}_SNAP_REPOSITORY_BRANCH_PUSH
JRELEASER_SNAP_GITHUB_BRANCH_PUSH
JRELEASER_SNAP_GITLAB_BRANCH_PUSH
JRELEASER_SNAP_GITEA_BRANCH_PUSH
JRELEASER_SNAP_CODEBERG_BRANCH_PUSH
JRELEASER_GITHUB_BRANCH_PUSH
JRELEASER_GITLAB_BRANCH_PUSH
JRELEASER_GITEA_BRANCH_PUSH
JRELEASER_CODEBERG_BRANCH_PUSH

Substitute ${name} for the value of the named instance.

Space (' '), underscore (_), and dash (-) will be replaced by dot (.) to separate tokens in the System property. Space (' '), dash (-), and dot (.) will be replaced by underscore (_) to separate tokens in the environment variable, such that:

${name} System Property Environment Variable

foobar

foobar

FOOBAR

fooBar

foobar

FOOBAR

foo bar

foo.bar

FOO_BAR

foo-bar

foo.bar

FOO_BAR

foo_bar

foo.bar

FOO_BAR

foo.bar

foo.bar

FOO_BAR

Tokens

The repository token environment variable must match with the chosen Release service.

On GitHub, you can’t use the default secrets.GITHUB_TOKEN as this token only works for the repository that’s running the workflow. You must configure a Personal Access Token (PAT) instead. It is recommended that you use "fine-grained" PATs, rather than "classic" ones. The token must have:

  • Access to your tap repository; if this repository is part of a GitHub organization, make sure to choose that organization as the resource owner; if that organization doesn’t show up in the "resource owner" drop-down, contact your organization adminstrator and ask them to enable PAT access for that repository

  • The "Contents read and write" repository permission

DownloadURL

JReleaser follows these rules to find the download URL to use for a given artifact:

  1. if artifact.extraProperties.snapDownloadUrl exists, use it.

  2. if artifact.extraProperties.downloadUrl exists, use it.

  3. if explicit downloadUrl is set on snap, use it.

  4. if distribution.extraProperties.snapDownloadUrl exists, use it.

  5. if distribution.extraProperties.downloadUrl exists, use it.

  6. if releaser.${release}.skipRelease is false then use the releaser’s downloadUrl.

  7. if releaser.${release}.skipRelease is true then look for a matching uploader given an extraProperty named downloadUrlFrom on artifact, distribution, `snap (in that order). The value must be <uploaderType>:<uploaderName> such as "artifactory:app" or "s3:uploads".

  8. fail if no suitable URL is found.

With no extra configuration from your side rule 6. will be chosen which is the suitable default that most projects need.

Example

Assuming the current version is 1.2.3, and a distribution named app, the above configuration will generate a snapcraft.yaml file which may be published to app-snap

snapcraft.yaml
name: app
version: 1.2.3
summary: Sample app
description: Sample app

grade: stable
confinement: strict
base: core20
type: app

apps:
  app:
    command: $SNAP/bin/app
    environment:
      JAVA_HOME: "$SNAP/usr/lib/jvm/java/jre/"
      PATH: "$SNAP/bin:$PATH:$SNAP/usr/lib/jvm/java/jre/bin"

parts:
  app:
    plugin: dump
    source: https://github.com/duke/app/releases/download/v1.2.3/app-1.2.3.tar.gz
    source-checksum: sha256/8e74020ca5e7d01d25c34cf1bd53adcf78c77adf7b53530ae5e0baeb841cb43e
    stage-packages:
      - openjdk-8-jre
      - ca-certificates
      - ca-certificates-java
    organize:
      'usr/lib/jvm/java-8-openjdk*': usr/lib/jvm/java
    prime:
      - -usr/lib/jvm/java/lib/security/cacerts
      - -usr/lib/jvm/java/jre/lib/security/cacerts

Templates

The default location for templates is:

src/jreleaser/distributions/<distribution-name>/snap

The following list shows the filenames that may be used to override default templates:

  • snap/snapcraft.yaml.tpl

  • .gitignore

  • README.md.tpl

Any additional files found in the template directories will be copied as is unless their filename ends with .tpl in which case Name Templates substitution will take place.

Templates may be initialized using the template command

Skip Templates

You may skip any template files by defining a set of skip rules in the skipTemplates property. For example, you may use any of these expressions to skip a template named README.md.tpl:

  • README.md.tpl: matches the full template name

  • README.md: matches the transformed template name

  • README.*: matches using a regex

Skip Artifacts

If there is more than one matching artifact in a given distribution you may add a skipSnap extra property to the target artifact to mark it as skipped for packaging with snap.

Skip License

If there’s a matching LICENSE file available at the root of the project it will be copied to the repository by default. You may set an extra property named skipLicenseFile on snap to skip this behavior.

Repository

The repository section allows setting extra properties that may be used to provide additional hints when interacting with the git repository that holds packager files.

GitLab

Define a projectIdentifier property to directly locate the project associated with the repository, such as

  • YAML

  • TOML

  • JSON

  • Maven

  • Gradle

packagers:
  snap:
    repository:
      extraProperties:
        projectIdentifier: 12345678
[packagers.snap]
  repository.extraProperties.projectIdentifier = "12345678"
{
  "packagers": {
    "snap": {
      "repository": {
        "extraProperties": {
          "projectIdentifier": "12345678"
        }
      }
    }
  }
}
<jreleaser>
  <packagers>
    <snap>
      <repository>
        <extraProperties>
          <projectIdentifier>12345678</projectIdentifier>
        </extraProperties>
      </repository>
    </snap>
  </packagers>
</jreleaser>
jreleaser {
  packagers {
    snap {
      repository {
        extraProperties.put("projectIdentifier", "12345678")
      }
    }
  }
}