Skip to content

Commit

Permalink
Autoconfigure a Java runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Jan 2, 2022
1 parent 1be32a4 commit f4b19f6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
37 changes: 17 additions & 20 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ jobs:
# Configure build steps as you'd normally do
- name: Setup Java
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: 1.8
java-version: 11
distribution: 'zulu'
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
Expand All @@ -56,29 +57,23 @@ jobs:
git config user.email "${{ github.event.head_commit.committer.email }}"
mvn -B --file pom.xml release:prepare release:perform
# IMPORTANT!
- name: Setup Java for JReleaser
uses: actions/setup-java@v1
with:
java-version: 11
# Create a release
- name: Run JReleaser
uses: jreleaser/release-action@v1
uses: jreleaser/release-action@v2
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
----

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.
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. If your project already builds with Java 11+
then you can skip the second "setup" step.
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

Expand All @@ -88,14 +83,16 @@ Following inputs can be used as `step.with` keys

[%header,cols="<2,<,<2,<3",width="100%"]
|===
| Name | Type | Default | Description
| version | String | latest | The JReleaser version to use. +
| Name | Type | Default | Description
| version | String | latest | The JReleaser version to use. +
Should match any of the link:https://github.com/jreleaser/jreleaser/releases[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. +
| 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.
|===

== Environment Variables
Expand All @@ -122,7 +119,7 @@ If you create a secret named `GH_PAT`, the step will look like this
[source,yaml]
----
- name: Run JReleaser
uses: jreleaser/release-action@v1
uses: jreleaser/release-action@v2
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
----
Expand All @@ -133,7 +130,7 @@ you may apply the `GH_PAT` token as follows
[source,yaml]
----
- name: Run JReleaser
uses: jreleaser/release-action@v1
uses: jreleaser/release-action@v2
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_HOMEBREW_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
Expand Down
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@ inputs:
default: ${{ github.workspace }}
description: 'The directory to change into.'

setup-java:
required: false
default: 'true'
description: 'Setup internal Java runtime.'

runs:
using: 'composite'
steps:
- name: 'Setup Java'
uses: actions/setup-java@v2
if: ${{ inputs.setup-java }} == 'true'
with:
java-version: 17
distribution: 'zulu'

- name: 'Download JReleaser'
shell: bash
working-directory: ${{ inputs.working-directory }}
Expand Down

0 comments on commit f4b19f6

Please sign in to comment.