From f4b19f681fa6af6484112125481e5ace7806d35b Mon Sep 17 00:00:00 2001 From: Andres Almiray Date: Sun, 2 Jan 2022 18:49:24 +0100 Subject: [PATCH] Autoconfigure a Java runtime --- README.adoc | 37 +++++++++++++++++-------------------- action.yml | 12 ++++++++++++ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/README.adoc b/README.adoc index 215d7ba..50f2a87 100644 --- a/README.adoc +++ b/README.adoc @@ -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 @@ -56,17 +57,10 @@ 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 }} ---- @@ -74,11 +68,12 @@ jobs: 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 @@ -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 @@ -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 }} ---- @@ -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 }} diff --git a/action.yml b/action.yml index 83ae787..98f4cce 100644 --- a/action.yml +++ b/action.yml @@ -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 }}