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

Publication of snapshots is not allowed.
Building local snaps requires snapcraft to be pre-installed. JReleaser will not install it nor its dependencies.

Legend:

  • required

  • optional

  • may use environment variable

  • accepts Name Templates

  • YAML

  • TOML

  • JSON

  • Maven

  • Gradle

# 
packagers:
  # 
  snap:
    # Enables or disables Snap.
    # Valid 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

    # 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.
    # 
    snap:
      # Enables or disables the snap.
      # Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      # Defaults to `RELEASE`.
      # 
      active: ALWAYS


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

      # The name of the snap.
      # 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 use.
      # May define a `JRELEASER_SNAP_${GIT}_BRANCH` environment variable instead.
      # Defaults to the branch pointed by HEAD.
      #  
      branch: HEAD

      # Username used for authoring commits. Must have write access to the snap.
      # If left unspecified, the `JRELEASER_SNAP_${GIT}_USERNAME`
      # environment variable must be defined.
      # Defaults to the same username as the release repository.
      #  
      username: duke

      # Password or OAuth token with write access to the snap.
      # If left unspecified, the `JRELEASER_SNAP_${GIT}_TOKEN`
      # environment variable must be defined.
      #  
      token: __DO_NOT_SET_HERE__

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

    # 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.
    # Valid 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

    # Allows slots to be configured.
    # 
    slots:
      some_slot_name:
        key: value
        read:
        - $HOME/.foo
        write:
        - $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.
  # Valid 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"

  # 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 snap.
  # Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `RELEASE`.
  # 
  snap.active = "ALWAYS"


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

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

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

  # The target branch to use.
  # May define a `JRELEASER_SNAP_${GIT}_BRANCH` environment variable instead.
  # Defaults to the branch pointed by HEAD.
  #  
  snap.branch = "HEAD"

  # Username used for authoring commits. Must have write access to the snap.
  # If left unspecified, the `JRELEASER_SNAP_${GIT}_USERNAME`
  # environment variable must be defined.
  # Defaults to the same username as the release repository.
  #  
  snap.username = "duke"

  # Password or OAuth token with write access to the snap.
  # If left unspecified, the `JRELEASER_SNAP_${GIT}_TOKEN`
  # environment variable must be defined.
  #  
  snap.token = "__DO_NOT_SET_HERE__"

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

  # 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.
  # Valid 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"

  # Allows slots to be configured.
  # 
  [packagers.snap.slots]
    some_slot_name.key = "value"
    some_slot_name.read = ["$HOME/.foo"]
    some_slot_name.write = ["$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.
      // Valid 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",

      // 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.
      // 
      "snap": {
        // Enables or disables the snap.
        // Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `RELEASE`.
        // 
        "active": "ALWAYS",


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

        // The name of the snap.
        // 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 use.
        // May define a `JRELEASER_SNAP_${GIT}_BRANCH` environment variable instead.
        // Defaults to the branch pointed by HEAD.
        //  
        "branch": "HEAD",

        // Username used for authoring commits. Must have write access to the snap.
        // If left unspecified, the `JRELEASER_SNAP_${GIT}_USERNAME`
        // environment variable must be defined.
        // Defaults to the same username as the release repository.
        //  
        "username": "duke",

        // Password or OAuth token with write access to the snap.
        // If left unspecified, the `JRELEASER_SNAP_${GIT}_TOKEN`
        // environment variable must be defined.
        //  
        "token": "__DO_NOT_SET_HERE__",

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

      // 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.
      // Valid 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"
          }
        }
      ],

      // Allows slots to be configured.
      // 
      "slots": [
        {
          "some_slot_name": {
            "key": "value",
            "read": [
              "$HOME/.foo"
            ],
            "write": [
              "$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.
        Valid 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>

      <!--
        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.
        
      -->
      <snap>
        <!--
          Enables or disables the snap.
          Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
          Defaults to `RELEASE`.
          
        -->
        <active>ALWAYS</active>


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

        <!--
          The name of the snap.
          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 use.
          May define a `JRELEASER_SNAP_${GIT}_BRANCH`` environment variable instead.
          Defaults to the branch pointed by HEAD.
           
        -->
        <branch>HEAD</branch>

        <!--
          Username used for authoring commits. Must have write access to the snap.
          If left unspecified, the `JRELEASER_SNAP_${GIT}_USERNAME`
          environment variable must be defined.
          Defaults to the same username as the release repository.
           
        -->
        <username>duke</username>

        <!--
          Password or OAuth token with write access to the snap.
          If left unspecified, the `JRELEASER_SNAP_${GIT}_TOKEN`
          environment variable must be defined.
           
        -->
        <token>__DO_NOT_SET_HERE__</token>

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

      <!--
        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.
        Valid 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>
        </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.
      // Valid 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'

      // 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.
      // 
      snap {
        // Enables or disables the snap.
        // Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `RELEASE`.
        // 
        active = 'ALWAYS'


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

        // The name of the snap.
        // 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 use.
        // May define a `JRELEASER_BRANCH` environment variable instead.
        // Defaults to the branch pointed by HEAD.
        //  
        branch = 'HEAD'

        // Username used for authoring commits. Must have write access to the snap.
        // If left unspecified, the `JRELEASER_SNAP_${GIT}_USERNAME`
        // environment variable must be defined.
        // Defaults to the same username as the release repository.
        //  
        username = 'duke'

        // Password or OAuth token with write access to the snap.
        // If left unspecified, the `JRELEASER_SNAP_${GIT}_TOKEN`
        // environment variable must be defined.
        //  
        token = '__DO_NOT_SET_HERE__'

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

      // 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.
      // Valid 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.
      // 
      addLocalPlug('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.
      // 
      addLocalSlots('some_slot_name')

      // Allows plugs to be configured.
      // 
      plugs {
        some_plug_name {
          addAttribute('key', 'value')
        }
      }

      // Allows slots to be configured.
      // 
      slots {
        some_slot_name {
          addAttribute('key', 'value')
          addRead('$HOME/.foo')
          addWrite('$HOME/.foo')
          addWrite('$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
      }
    }
  }
}

Tokens

The snap token environment variable must match with the chosen Release service that is, it must be one of:
  • JRELEASER_SNAP_GITHUB_TOKEN

  • JRELEASER_SNAP_GITLAB_TOKEN

  • JRELEASER_SNAP_GITEA_TOKEN

  • JRELEASER_SNAP_CODEBERG_TOKEN

If a matching token is not found then the releaser’s token will be used instead:

  • JRELEASER_GITHUB_TOKEN

  • JRELEASER_GITLAB_TOKEN

  • JRELEASER_GITEA_TOKEN

  • JRELEASER_CODEBERG_TOKEN

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 instead.

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.${git}.skipRelease is false then use the releaser’s downloadUrl.

  7. if releaser.${git}.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

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.

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