= JReleaser's Release

It should be no surprise that JReleaser relies on itself to create its releases.

The following link:https://raw.githubusercontent.com/jreleaser/jreleaser/main/jreleaser.yml[configuration file]
is used to create both release and snapshot releases:

[source,yaml]
[subs="verbatim"]
.jreleaser.yml
----
# Define properties we'll use later in this file
environment:
  properties:
    jdkPathPrefix: 'apps/jreleaser/build/jdks/zulu11.48.21-ca-jdk11.0.11'

# General information about this project
project:
  name: jreleaser
  description: Release Java projects quickly and easily with JReleaser
  longDescription: |
    JReleaser is a release automation tool for Java projects. Its goal is to simplify creating releases
    and publishing artifacts to multiple package managers while providing customizable options.

    JReleaser takes inputs from popular builds tools (Ant, Maven, Gradle) such as JAR files, binary
    distributions (.zip, .tar), JLink images, or any other file that you’d like to publish as a Git
    release on popular Git services such as Github or Gitlab. Distribution files can additionally be
    published to be consumed by popular package managers as Homebrew, Snapcraft, or get ready to be
    launched via JBang. Releases may be announced in a variety of channels such as Twitter, Zulip, or SdkMan!

  website: https://jreleaser.org
  authors:
    - Andres Almiray
  license: Apache-2.0
  java:
    groupId: org.jreleaser
    version: 8
  extraProperties:
    inceptionYear: 2020

# The repository is hosted at https://github.com/jreleaser/jreleaser
# which means the default username would be `jreleaser` however a
# different username is required in this case
release:
  github:
    username: aalmiray
    overwrite: true
    sign: true
    changelog:
      formatted: ALWAYS
      change: '- {{commitShortHash}} {{commitTitle}}'
      # Label commits by matching their first line
      labelers:
        - label: 'feature'
          title: 'Resolves #'
          body: 'Resolves #'
        - label: 'issue'
          title: 'Fixes #'
          body: 'Fixes #'
        - label: 'issue'
          title: 'Relates to #'
          body: 'Relates to #'
        - label: 'task'
          title: '[chore]'
        - label: 'dependencies'
          title: '[deps]'
      # Categorize commits by labels
      categories:
        - title: '🚀 Features'
          labels:
            - 'feature'
        - title: '✅ Issues'
          labels:
            - 'issue'
        - title: '🧰 Tasks'
          labels:
            - 'task'
        - title: '⚙️  Dependencies'
          labels:
            - 'dependencies'
      replacers:
        # Remove `[chore] ` from the commit message
        - search: '\[chore\] '
        # Remove `[deps] ` from the commit message
        - search: '\[deps\] '

# File signing is always active
signing:
  active: always
  armored: true

# Announcing a release only occurs whn it's not snapshot
announce:
  twitter:
    active: release
  sdkman:
    active: release

# Configure a cross-platform Jlink assembly
assemble:
  jlinks:
    jreleaser-standalone:
      active: always
      extraProperties:
        sdkmanSkip: true
      java:
        version: 11
        mainClass: 'org.jreleaser.cli.Main'
      imageName: '{{distributionName}}-{{projectEffectiveVersion}}'
      executable: 'jreleaser'
      moduleNames:
        - java.base
        - java.desktop
        - java.management
        - java.naming
        - java.rmi
        - java.security.jgss
        - java.security.sasl
        - java.sql
        - jdk.crypto.ec
        - jdk.crypto.cryptoki
        - jdk.security.auth
        - jdk.security.jgss
        - org.openjsse
      targetJdks:
        - path: '{{jdkPathPrefix}}-macosx_x64/zulu-11.jdk/Contents/Home'
          platform: 'osx'
        - path: '{{jdkPathPrefix}}-linux_x64'
          platform: 'linux'
        - path: '{{jdkPathPrefix}}-linux_musl_x64'
          platform: 'linux_musl'
        - path: '{{jdkPathPrefix}}-win_x64'
          platform: 'windows'
      mainJar:
        path: 'apps/jreleaser/build/libs/jreleaser-{{projectVersion}}.jar'
      jars:
        - directory: 'apps/jreleaser/build/dependencies/flat'
          include: '*.jar'

# Configure 4 distributions
distributions:
  # Distribution 1 is of type JAVA_BINARY
  jreleaser:
    java:
      mainClass: org.jreleaser.cli.Main
    brew:
      # Active only on release
      active: release
    scoop:
      # Active only on release
      active: release
    snap:
      # Active only on release
      active: release
      remoteBuild: true
      base: core18
      localPlugs:
        - network
        - home
    jbang:
      # Always active
      active: always
    artifacts:
      # Transform the artifact name
      - path: apps/{{distributionName}}/build/distributions/{{distributionName}}-{{projectVersion}}.zip
        transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.zip'
      - path: apps/{{distributionName}}/build/distributions/{{distributionName}}-{{projectVersion}}.tar
        transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.tar'

  # Distribution 2 is of type JAVA_BINARY
  jreleaser-ant-tasks:
    extraProperties:
      # Do not consider its artifacts for publication via SdkMan
      sdkmanSkip: true
    artifacts:
      # Transform the artifact name
      - path: plugins/{{distributionName}}/build/distributions/{{distributionName}}-{{projectVersion}}.zip
        transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.zip'

  # Distribution 3 is of type SINGLE_JAR
  jreleaser-tool-provider:
    type: SINGLE_JAR
    artifacts:
      # Transform the artifact name
      - path: apps/{{distributionName}}/build/libs/{{distributionName}}-{{projectVersion}}.jar
        transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.jar'

  # Distribution 4 is of type JLINK
  # Name matches the assembled Jlink distribution
  jreleaser-standalone:
    docker:
      # inherited by specs
      active: always
      # inherited by specs
      registries:
        - serverName: DEFAULT
          username: jreleaser
      # inherited by specs
      labels:
        'org.opencontainers.image.title': 'jreleaser'
      # inherited by specs
      postCommands:
        - 'VOLUME /workspace'
      # configure 2 specs
      specs:
        slim:
          imageNames:
            - 'jreleaser/jreleaser-{{dockerSpecName}}:{{tagName}}'
            - 'jreleaser/jreleaser-{{dockerSpecName}}:latest'
          # match by platform
          matchers:
            platform: 'linux'
          preCommands:
            - 'RUN apt-get update -y'
            - 'RUN apt-get install unzip'
        alpine:
          imageNames:
            - 'jreleaser/jreleaser-{{dockerSpecName}}:{{tagName}}'
            - 'jreleaser/jreleaser-{{dockerSpecName}}:latest'
          # match by platform
          matchers:
            platform: 'linux_musl'
          preCommands:
            - 'RUN apk add unzip'

files:
  artifacts:
    - path: VERSION
----

Which will create and tag a prerelease on GitHub when the project is snapshot, and a regular release when
the project is not snapshot.

