Skip to content

Latest commit

 

History

History
461 lines (366 loc) · 14.3 KB

File metadata and controls

461 lines (366 loc) · 14.3 KB

Chocolatey

Publishes packages to https://chocolatey.org.

The following artifact extensions are supported by this packager:

  • .zip

  • .exe

  • .msi

Distribution Support

Distribution Supported

concepts:distributions/binary.adoc

{icon_req_y}

concepts:distributions/flat-binary.adoc

{icon_req_n}

concepts:distributions/java-binary.adoc

{icon_req_y}

concepts:distributions/jlink.adoc

{icon_req_y}

concepts:distributions/native-image.adoc

{icon_req_y}

concepts:distributions/native-package.adoc

{icon_req_y}

concepts:distributions/single-jar.adoc

{icon_req_n}

Local publication of packages requires running on Windows, have powershell and choco installed. If you rather package and push on CI then set remoteBuild to true.

Warning
Publication of snapshots is not allowed.
YAML
partial$packagers/yaml/common-head.adoc

partial$packagers/yaml/template-directory.adoc

partial$packagers/yaml/commitauthor.adoc

partial$packagers/yaml/tap.adoc

partial$packagers/yaml/package-name.adoc

    # Package version.
    # Defaults to `{{projectVersion}}`.
    # [dot circle] [file alt]
    packageVersion: 1.2.3

    # The username that can publish Chocolatey packages.
    # If left unspecified, the release owner will be used.
    # [exclamation triangle]
    username: duke

    # The ApiKey associated with the given account.
    # If left unspecified, the `JRELEASER_CHOCOLATEY_API_KEY`
    # environment variable must be defined.
    # [exclamation triangle] [eye slash]
    apiKey: __DO_NOT_SET_HERE__

    # The source to push the package to.
    # If left unspecified, will use `https://push.chocolatey.org/`.
    # [dot circle]
    source: https://push.chocolatey.org/

    # Whether to build the package on a remote server or locally.
    # Defaults to `false`.
    # [dot circle]
    remoteBuild: false

    # The title of the spec.
    # If left unspecified, will use `${project.name}`.
    # [dot circle]
    title: Duke

    # The icon's Url.
    # Refer to https://docs.chocolatey.org/en-us/create/create-packages#package-icon-guidelines
    # [dot circle] [file alt]
    iconUrl: https://rawcdn.githack.com/duke/app/0934fa1fa3f0bd09c0c8c39fbdeb5df2ce507457/icon.png
TOML
partial$packagers/toml/common-head.adoc

partial$packagers/toml/template-directory.adoc

partial$packagers/toml/commitauthor.adoc

partial$packagers/toml/tap.adoc

partial$packagers/toml/package-name.adoc

  # Package version.
  # Defaults to `{{projectVersion}}`.
  # [dot circle] [file alt]
  packageVersion = "1.2.3"

  # The username that can publish Chocolatey packages.
  # If left unspecified, the release owner will be used.
  # [exclamation triangle]
  username = "duke"

  # The ApiKey associated with the given account.
  # If left unspecified, the `JRELEASER_CHOCOLATEY_API_KEY`
  # environment variable must be defined.
  # [exclamation triangle] [eye slash]
  apiKey = "__DO_NOT_SET_HERE__"

  # The source to push the package to.
  # If left unspecified, will use `https://push.chocolatey.org/`.
  # [dot circle]
  source = "https://push.chocolatey.org/"

  # Whether to build the package on a remote server or locally.
  # Defaults to `false`.
  # [dot circle]
  remoteBuild = false

  # The title of the spec.
  # If left unspecified, will use `${project.name}`.
  # [dot circle]
  title = "Duke"

  # The icon's Url.
  # Refer to https://docs.chocolatey.org/en-us/create/create-packages#package-icon-guidelines
  # [dot circle] [file alt]
  iconUrl = "https://rawcdn.githack.com/duke/app/0934fa1fa3f0bd09c0c8c39fbdeb5df2ce507457/icon.png"
JSON
partial$packagers/json/common-head.adoc

partial$packagers/json/template-directory.adoc

partial$packagers/json/commitauthor.adoc

partial$packagers/json/tap.adoc

partial$packagers/json/package-name.adoc

      // Package version.
      // Defaults to `{{projectVersion}}`.
      // [dot circle] [file alt]
      "packageVersion": "1.2.3",

      // The username that can publish Chocolatey packages.
      // If left unspecified, the release owner will be used.
      // [exclamation triangle]
      "username": "duke",

      // The ApiKey associated with the given account.
      // If left unspecified, the `JRELEASER_CHOCOLATEY_API_KEY`
      // environment variable must be defined.
      // [exclamation triangle] [eye slash]
      "apiKey": "__DO_NOT_SET_HERE__",

      // The source to push the package to.
      // If left unspecified, will use `https://push.chocolatey.org/`.
      // [dot circle]
      "source": "https://push.chocolatey.org/",

      // Whether to build the package on a remote server or locally.
      // Defaults to `false`.
      // [dot circle]
      "remoteBuild": false,

      // The title of the spec.
      // If left unspecified, will use `${project.name}`.
      // [dot circle]
      "title": "Duke",

      // The icon's Url.
      // Refer to https://docs.chocolatey.org/en-us/create/create-packages#package-icon-guidelines
      // [dot circle] [file alt]
      "iconUrl": "https://rawcdn.githack.com/duke/app/0934fa1fa3f0bd09c0c8c39fbdeb5df2ce507457/icon.png"
partial$packagers/json/common-footer.adoc
Maven
partial$packagers/maven/common-head.adoc

partial$packagers/maven/template-directory.adoc

partial$packagers/maven/commitauthor.adoc

partial$packagers/maven/tap.adoc

partial$packagers/maven/package-name.adoc

      <!--
        Package version.
        Defaults to `{{projectVersion}}`.
        [dot circle] [file alt]
      -->
      <packageVersion>1.2.3</packageVersion>

      <!--
        The username that can publish Chocolatey packages.
        If left unspecified, the release owner will be used.
        [exclamation triangle]
      -->
      <username>duke</username>

      <!--
        The ApiKey associated with the given account.
        If left unspecified, the `JRELEASER_CHOCOLATEY_API_KEY`
        environment variable must be defined.
        [exclamation triangle] [eye slash]
      -->
      <apiKey>__DO_NOT_SET_HERE__</apiKey>

      <!--
        The source to push the package to.
        If left unspecified, will use `https://push.chocolatey.org/`.
        [dot circle]
      -->
      <source>https://push.chocolatey.org/</source>;

      <!--
        Whether to build the package on a remote server or locally.
        Defaults to `false`.
        [dot circle]
      -->
      <remoteBuild>false</remoteBuild>

      <!--
        The title of the spec.
        If left unspecified, will use `${project.name}`.
        [dot circle]
      -->
      <title>Duke</title>

      <!--
        The icon's Url.
        Refer to https://docs.chocolatey.org/en-us/create/create-packages#package-icon-guidelines
        [dot circle] [file alt]
      -->
      <iconUrl>https://rawcdn.githack.com/duke/app/0934fa1fa3f0bd09c0c8c39fbdeb5df2ce507457/icon.png</iconUrl>;
partial$packagers/maven/common-footer.adoc
Gradle
partial$packagers/gradle/common-head.adoc

partial$packagers/gradle/template-directory.adoc

partial$packagers/gradle/commitauthor.adoc

partial$packagers/gradle/tap.adoc

partial$packagers/gradle/package-name.adoc

      // Package version.
      // Defaults to `{{projectVersion}}`.
      // [dot circle] [file alt]
      packageVersion = '1.2.3'

      // The username that can publish Chocolatey packages.
      // If left unspecified, the release owner will be used.
      // [exclamation triangle]
      username = 'duke'

      // The ApiKey associated with the given account.
      // If left unspecified, the `JRELEASER_CHOCOLATEY_API_KEY`
      // environment variable must be defined.
      // [exclamation triangle] [eye slash]
      apiKey = '__DO_NOT_SET_HERE__'

      // The source to push the package to.
      // If left unspecified, will use `https://push.chocolatey.org/`.
      // [dot circle]
      source = 'https://push.chocolatey.org/'

      // Whether to build the package on a remote server or locally.
      // Defaults to `false`.
      // [dot circle]
      remoteBuild = false

      // The title of the spec.
      // If left unspecified, will use `${project.name}`.
      // [dot circle]
      title = 'Duke'

      // The icon's Url.
      // Refer to https://docs.chocolatey.org/en-us/create/create-packages#package-icon-guidelines
      // [dot circle] [file alt]
      iconUrl = 'https://rawcdn.githack.com/duke/app/0934fa1fa3f0bd09c0c8c39fbdeb5df2ce507457/icon.png'
partial$packagers/gradle/common-footer.adoc

Example

Assuming the current version is 1.2.3, and a distribution named app, the above configuration will generate the following files which will be published to duke/chocolatey-bucket/app

app.nuspec
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
  <metadata>
    <!-- required -->
    <id>app</id>
    <version>1.2.3</version>
    <authors>Duke</authors>
    <description>Sample app</description>
    <!-- optional -->
    <title>app</title>
    <projectUrl>https://acme.com/app</projectUrl>
    <copyright>2021 Duke</copyright>
    <licenseUrl>https://github.com/duke/app/blob/main/LICENSE</licenseUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <tags>app</tags>
    <summary>Sample app</summary>
    <projectSourceUrl>https://github.com/duke/app</projectSourceUrl>
    <packageSourceUrl>https://github.com/duke/chocolatey-bucket</packageSourceUrl>
    <docsUrl>https://acme.com/app</docsUrl>
    <bugTrackerUrl>https://github.com/duke/app/issues</bugTrackerUrl>
    <iconUrl>https://rawcdn.githack.com/duke/app/0934fa1fa3f0bd09c0c8c39fbdeb5df2ce507457/icon.png</iconUrl>
    <releaseNotes>https://github.com/duke/app/releases/tag/v1.2.3</releaseNotes>
  </metadata>
  <files>
    <file src="tools\**" target="tools" />
  </files>
</package>
tools/chocolateyinstall.ps1
$tools = Split-Path $MyInvocation.MyCommand.Definition
$package = Split-Path $tools
$app_home = Join-Path $package 'app-1.2.3'
$app_bat = Join-Path $app_home 'bin/app.bat'

Install-ChocolateyZipPackage `
    -PackageName 'app' `
    -Url 'https://github.com/duke/app/releases/download/v1.2.3/app-1.2.3.zip' `
    -Checksum '812121a64bbd3f49286f7b0be3c9209068f71fcf9541f313708979602e8de466' `
    -ChecksumType 'sha256' `
    -UnzipLocation $package

Install-BinFile -Name 'app' -Path $app_bat
tools/chocolateyuninstall.ps1
$tools = Split-Path $MyInvocation.MyCommand.Definition
$package = Split-Path $tools
$app_home = Join-Path $package 'app-1.2.3'
$app_bat = Join-Path $app_home 'bin/app.bat'

Uninstall-BinFile -Name 'app' -Path $app_bat

Package Version

Be aware that Chocolatey imposes certain rules on package versions such as:

  • Up to 3 numeric elements separated by .

  • An optional tag separated by - from the numeric elements

  • If a 4th element is present separated by . it must be an integer or a number following the yyyyMMdd format.

Some examples of valid package versions are

  • 1

  • 1.2

  • 1.2.3

  • 1.2.3.4

  • 1.2.3.20220731

  • 1-ALPHA1

  • 1.2-RC1

  • 1.2.3-BETA

Skip Artifacts

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

Remote Build

It’s expected that you take care of creating a nuget package and publish it to the desired location if remoteBuild is set to true. Templates for GitHub Actions will be available when the chosen releaser is reference:release/github.adoc.

The Push workflow triggers whenever a new tag is pushed to the bucket repository.
The Trigger workflow is triggered manually, use for the first publication or if the automatic workflow fails for some reason.

Templates

The default location for templates is:

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

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

  • binary.nuspec.tpl

  • tools/chocolateyinstall.ps1.tpl

  • tools/chocolateyuninstall.ps1.tpl

  • .github/workflows/push.yml.tpl

  • .github/workflows/trigger.yml.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.adoc substitution will take place.

Templates may be initialized using the template command

{icon_cli_s} template, {icon_maven_s} jreleaser:template, {icon_gradle_s} jreleaserTemplate, {icon_ant_s} jreleaser-template

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