Skip to content

jreleaser/release-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JReleaser

Build Status GitHub release Twitter Follow

This action executes a JReleaser workflow.

Usage

Workflow

name: release

on:
  workflow_dispatch:

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      # Configure build steps as you'd normally do

      - name: Setup Java
        uses: actions/setup-java@v4
        with:
          java-version: 21
          distribution: 'zulu'
          server-id: central
          server-username: MAVEN_USERNAME
          server-password: MAVEN_CENTRAL_TOKEN
          gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
          gpg-passphrase: MAVEN_GPG_PASSPHRASE
          cache: maven

      # Post JARs to Maven Central

      - name: Release to Maven Central
        env:
          MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
          MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
          MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
        run: |
          export GPG_TTY=$(tty)
          git config user.name "${{ github.event.head_commit.committer.name }}"
          git config user.email "${{ github.event.head_commit.committer.email }}"
          mvn -B --file pom.xml release:prepare release:perform

      # Create a release

      - name: Run JReleaser
        uses: jreleaser/release-action@v2
        env:
          JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # Persist logs

      - name: JReleaser release output
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: jreleaser-release
          path: |
            out/jreleaser/trace.log
            out/jreleaser/output.properties
Warning
Note the fetch-depth: 0 option on the Checkout workflow step. It is required for JReleaser to work properly. Without that, JReleaser might fail or behave incorrectly.

The last step executes a full-release with the default jreleaser.yml configuration that’s expected to be located at the root of the repository.

Important
This action requires Java 11+ to download and execute JReleaser. The action will setup a suitable Java runtime automatically. If you would like to use a different Java version/distribution then set the value of setup-java to false and make sure you have a previous step with actions/setup-java setup as needed.

Customizing

Inputs

Following inputs can be used as step.with keys

Name Type Default Description

version

String

latest

The JReleaser version to use.
Should match any of the published releases.
You may use latest to pull the latest stable release or
early-access to pull the latest snapshot.

arguments

String

full-release

The JReleaser command to run.

working-directory

String

${{ github.workspace }}

The directory to change into.
Defaults to the directory the calling workflow runs in.

setup-java

boolean

true

Automatically setup a Java runtime.
Java runtime defaults to Zulu 17.

java-opts

boolean

Additional JVM parameters for running JReleaser

Environment Variables

Following environment variables can be used as step.env keys

Name Description

JRELEASER_GITHUB_TOKEN

GITHUB_TOKEN as provided by secrets

Caution

The default GITHUB_TOKEN from secrets is limited to the repository that contains your workflow.

Pushing to other repositories such as Homebrew tap requires additional permissions, you must create a custom Personal Access Token with repo permissions and add it as a secret in the repository. If you create a secret named GH_PAT, the step will look like this

      - name: Run JReleaser
        uses: jreleaser/release-action@v2
        env:
          JRELEASER_GITHUB_TOKEN: ${{ secrets.GH_PAT }}

If you’d rather have separate tokens for each additional repository and keep the original GITHUB_TOKEN intact then you may apply the GH_PAT token as follows

      - name: Run JReleaser
        uses: jreleaser/release-action@v2
        env:
          JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.GH_PAT }}

Additional environment variables may be needed depending on your specific setup, such as those needed for signing files with GPG or announcing a release via Twitter. Review the docs at https://jreleaser.org to find more about these variables and how to set them up.