docs: fix YAML example indentation

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 190c65c4-f5aa-4595-8e2e-26266fbcb37f
This commit is contained in:
Bruno Borges 2026-07-16 13:04:28 -04:00
parent 00a21a9f20
commit fa6ba7f9bc
3 changed files with 379 additions and 379 deletions

112
README.md
View File

@ -93,23 +93,23 @@ For more details, see the full release notes on the [releases page](https://git
#### Eclipse Temurin #### Eclipse Temurin
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' # See 'Supported distributions' for available options distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '25' java-version: '25'
- run: java --version - run: java --version
``` ```
#### Azul Zulu OpenJDK #### Azul Zulu OpenJDK
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'zulu' # See 'Supported distributions' for available options distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '25' java-version: '25'
- run: java --version - run: java --version
``` ```
#### Supported version syntax #### Supported version syntax
@ -180,16 +180,16 @@ The cache input is optional, and caching is turned off by default.
#### Caching gradle dependencies #### Caching gradle dependencies
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
cache: 'gradle' cache: 'gradle'
cache-dependency-path: | # optional cache-dependency-path: | # optional
sub-project/*.gradle* sub-project/*.gradle*
sub-project/**/gradle-wrapper.properties sub-project/**/gradle-wrapper.properties
- run: ./gradlew build --no-daemon - run: ./gradlew build --no-daemon
``` ```
Using the `cache: gradle` provides a simple and effective way to cache Gradle dependencies with minimal configuration. Using the `cache: gradle` provides a simple and effective way to cache Gradle dependencies with minimal configuration.
@ -202,15 +202,15 @@ For setup details and a comprehensive overview of all available features, visit
#### Caching maven dependencies #### Caching maven dependencies
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
cache: 'maven' cache: 'maven'
cache-dependency-path: 'sub-project/pom.xml' # optional cache-dependency-path: 'sub-project/pom.xml' # optional
- name: Build with Maven - name: Build with Maven
run: mvn package --file pom.xml run: mvn package --file pom.xml
``` ```
> [!NOTE] > [!NOTE]
@ -223,17 +223,17 @@ steps:
#### Caching sbt dependencies #### Caching sbt dependencies
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
cache: 'sbt' cache: 'sbt'
cache-dependency-path: | # optional cache-dependency-path: | # optional
sub-project/build.sbt sub-project/build.sbt
sub-project/project/build.properties sub-project/project/build.properties
- name: Build with SBT - name: Build with SBT
run: sbt package run: sbt package
``` ```
#### Cache segment restore timeout #### Cache segment restore timeout
@ -243,13 +243,13 @@ Usually, cache gets downloaded in multiple segments of fixed sizes. Sometimes, a
env: env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5' SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
cache: 'gradle' cache: 'gradle'
- run: ./gradlew build --no-daemon - run: ./gradlew build --no-daemon
``` ```
### Check latest ### Check latest
@ -263,13 +263,13 @@ For Java distributions that are not cached on Hosted images, `check-latest` alwa
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
check-latest: true check-latest: true
- run: java --version - run: java --version
``` ```
### Testing against different Java versions ### Testing against different Java versions

View File

@ -39,12 +39,12 @@ Inputs `java-version` and `distribution` are mandatory and needs to be provided.
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
- run: java --version - run: java --version
``` ```
### Adopt ### Adopt
@ -52,38 +52,38 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'adopt-hotspot' distribution: 'adopt-hotspot'
java-version: '11' java-version: '11'
- run: java --version - run: java --version
``` ```
### Zulu ### Zulu
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'zulu' distribution: 'zulu'
java-version: '25' java-version: '25'
java-package: jdk # optional (jdk, jre, jdk+fx, jre+fx, jdk+crac, or jre+crac) - defaults to jdk java-package: jdk # optional (jdk, jre, jdk+fx, jre+fx, jdk+crac, or jre+crac) - defaults to jdk
- run: java --version - run: java --version
``` ```
### Liberica ### Liberica
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'liberica' distribution: 'liberica'
java-version: '25' java-version: '25'
java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx) - defaults to jdk java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx) - defaults to jdk
- run: java --version - run: java --version
``` ```
### Liberica Native Image Kit ### Liberica Native Image Kit
@ -91,25 +91,25 @@ Liberica Native Image Kit (NIK) is a GraalVM-based distribution. `java-version`
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'liberica-nik' distribution: 'liberica-nik'
java-version: '25' java-version: '25'
java-package: jdk # optional (jdk or jdk+fx) - defaults to jdk java-package: jdk # optional (jdk or jdk+fx) - defaults to jdk
- run: native-image --version - run: native-image --version
``` ```
### Microsoft ### Microsoft
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'microsoft' distribution: 'microsoft'
java-version: '25' java-version: '25'
- run: java --version - run: java --version
``` ```
### Using Microsoft distribution on GHES ### Using Microsoft distribution on GHES
@ -133,12 +133,12 @@ If the runner is not able to access github.com, any Java versions requested duri
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'corretto' distribution: 'corretto'
java-version: '25' java-version: '25'
- run: java --version - run: java --version
``` ```
### Oracle ### Oracle
@ -146,12 +146,12 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'oracle' distribution: 'oracle'
java-version: '25' java-version: '25'
- run: java --version - run: java --version
``` ```
### Alibaba Dragonwell ### Alibaba Dragonwell
@ -159,24 +159,24 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'dragonwell' distribution: 'dragonwell'
java-version: '8' java-version: '8'
- run: java --version - run: java --version
``` ```
### SapMachine ### SapMachine
**NOTE:** An OpenJDK release maintained and supported by SAP **NOTE:** An OpenJDK release maintained and supported by SAP
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'sapmachine' distribution: 'sapmachine'
java-version: '25' java-version: '25'
- run: java --version - run: java --version
``` ```
### GraalVM ### GraalVM
@ -184,14 +184,14 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'graalvm' distribution: 'graalvm'
java-version: '25' java-version: '25'
- run: | - run: |
java --version java --version
native-image --version native-image --version
``` ```
### GraalVM Community ### GraalVM Community
@ -199,14 +199,14 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'graalvm-community' distribution: 'graalvm-community'
java-version: '21' java-version: '21'
- run: | - run: |
java --version java --version
native-image --version native-image --version
``` ```
### JetBrains ### JetBrains
@ -218,12 +218,12 @@ For example, `11.0.24` is not available but `11.0.16` is.
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'jetbrains' distribution: 'jetbrains'
java-version: '11' java-version: '11'
- run: java --version - run: java --version
``` ```
The JetBrains installer uses the GitHub API to fetch the latest version. If you believe your project is going to be running into rate limits, you can provide a The JetBrains installer uses the GitHub API to fetch the latest version. If you believe your project is going to be running into rate limits, you can provide a
@ -231,15 +231,15 @@ GitHub token to the action to increase the rate limit. Set the `GITHUB_TOKEN` en
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'jetbrains' distribution: 'jetbrains'
java-version: '17' java-version: '17'
java-package: 'jdk' # optional (jdk, jre, jdk+jcef, jre+jcef, jdk+ft, or jre+ft) - defaults to jdk java-package: 'jdk' # optional (jdk, jre, jdk+jcef, jre+jcef, jdk+ft, or jre+ft) - defaults to jdk
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: java --version - run: java --version
``` ```
You can specify your package type (as shown in the [releases page](https://github.com/JetBrains/JetBrainsRuntime/releases/)) in the `java-package` parameter. You can specify your package type (as shown in the [releases page](https://github.com/JetBrains/JetBrainsRuntime/releases/)) in the `java-package` parameter.
@ -257,24 +257,24 @@ The available package types are:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'kona' distribution: 'kona'
java-version: '21' java-version: '21'
- run: java --version - run: java --version
``` ```
## Installing custom Java package type ## Installing custom Java package type
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '25' java-version: '25'
java-package: jdk # optional (jdk or jre) - defaults to jdk java-package: jdk # optional (jdk or jre) - defaults to jdk
- run: java --version - run: java --version
``` ```
### JavaFX Maven project ### JavaFX Maven project
@ -283,15 +283,15 @@ For JavaFX projects that use Maven, use `jdk+fx` (or `jre+fx`) as the `java-pack
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'zulu' distribution: 'zulu'
java-version: '25' java-version: '25'
java-package: jdk+fx java-package: jdk+fx
cache: maven cache: maven
- name: Build with Maven - name: Build with Maven
run: mvn --no-transfer-progress compile run: mvn --no-transfer-progress compile
``` ```
To run the JavaFX application in CI: To run the JavaFX application in CI:
@ -348,16 +348,16 @@ the full set):
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
cache: 'maven' cache: 'maven'
- name: Seed the Maven cache - name: Seed the Maven cache
run: mvn dependency:go-offline dependency:resolve-plugins run: mvn dependency:go-offline dependency:resolve-plugins
- name: Build with Maven - name: Build with Maven
run: mvn verify --file pom.xml run: mvn verify --file pom.xml
``` ```
Separate seed job — useful for a matrix where different legs run different goals Separate seed job — useful for a matrix where different legs run different goals
@ -371,14 +371,14 @@ jobs:
seed-cache: seed-cache:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
cache: 'maven' cache: 'maven'
- name: Seed the Maven cache - name: Seed the Maven cache
run: mvn dependency:go-offline dependency:resolve-plugins run: mvn dependency:go-offline dependency:resolve-plugins
build: build:
needs: seed-cache needs: seed-cache
@ -387,14 +387,14 @@ jobs:
matrix: matrix:
goal: ['test', 'verify', 'test -Pprofile1'] goal: ['test', 'verify', 'test -Pprofile1']
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '25' java-version: '25'
cache: 'maven' cache: 'maven'
- name: Build - name: Build
run: mvn ${{ matrix.goal }} --file pom.xml run: mvn ${{ matrix.goal }} --file pom.xml
``` ```
### Caveats ### Caveats
@ -428,13 +428,13 @@ jobs:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '25' java-version: '25'
architecture: x86 # optional - default value derived from the runner machine architecture: x86 # optional - default value derived from the runner machine
- run: java --version - run: java --version
``` ```
## Installing JDK without setting as default ## Installing JDK without setting as default
@ -443,22 +443,22 @@ When installing multiple JDKs, the last one installed becomes the default (`JAVA
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '17' java-version: '17'
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
id: setup-java-21 id: setup-java-21
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '21' java-version: '21'
set-default: false set-default: false
- run: | - run: |
echo "Default java:" echo "Default java:"
java -version java -version
echo "Java 21 home: $JAVA_HOME_21_X64" echo "Java 21 home: $JAVA_HOME_21_X64"
echo "Java 21 path from output: ${{ steps.setup-java-21.outputs.path }}" echo "Java 21 path from output: ${{ steps.setup-java-21.outputs.path }}"
``` ```
In this example, `JAVA_HOME` and `java` on `PATH` point to Java 17, while Java 21 is available via `JAVA_HOME_21_X64` or the step output `path`. In this example, `JAVA_HOME` and `java` on `PATH` point to Java 17, while Java 21 is available via `JAVA_HOME_21_X64` or the step output `path`.
@ -473,59 +473,59 @@ If your use-case requires a custom distribution or a version that is not provide
```yaml ```yaml
steps: steps:
- run: | - run: |
download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz" download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdk-file: ${{ runner.temp }}/java_package.tar.gz jdk-file: ${{ runner.temp }}/java_package.tar.gz
java-version: '11.0.0' java-version: '11.0.0'
architecture: x64 architecture: x64
- run: java --version - run: java --version
``` ```
For example, to use an **Early Access** build from [jdk.java.net](https://jdk.java.net/), download the archive for your runner OS/architecture and install it via `distribution: 'jdkfile'` (example below assumes Linux x64): For example, to use an **Early Access** build from [jdk.java.net](https://jdk.java.net/), download the archive for your runner OS/architecture and install it via `distribution: 'jdkfile'` (example below assumes Linux x64):
```yaml ```yaml
steps: steps:
- run: | - run: |
download_url="https://download.java.net/java/early_access/jdk25/36/GPL/openjdk-25-ea+36_linux-x64_bin.tar.gz" download_url="https://download.java.net/java/early_access/jdk25/36/GPL/openjdk-25-ea+36_linux-x64_bin.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdk-file: ${{ runner.temp }}/java_package.tar.gz jdk-file: ${{ runner.temp }}/java_package.tar.gz
java-version: '25.0.0-ea.36' java-version: '25.0.0-ea.36'
architecture: x64 architecture: x64
- run: java --version - run: java --version
``` ```
If your use-case requires a custom distribution (in the example, alpine-linux is used) or a version that is not provided by setup-java and you want to always install the latest version during runtime, then you can use the following code to auto-download the latest JDK, determine the semver needed for setup-java, and setup-java will take care of the installation and caching on the VM: If your use-case requires a custom distribution (in the example, alpine-linux is used) or a version that is not provided by setup-java and you want to always install the latest version during runtime, then you can use the following code to auto-download the latest JDK, determine the semver needed for setup-java, and setup-java will take care of the installation and caching on the VM:
```yaml ```yaml
steps: steps:
- name: fetch latest temurin JDK - name: fetch latest temurin JDK
id: fetch_latest_jdk id: fetch_latest_jdk
run: | run: |
major_version={{ env.JAVA_VERSION }} # Example 16 or 21 or 22 major_version={{ env.JAVA_VERSION }} # Example 16 or 21 or 22
cd $RUNNER_TEMP cd $RUNNER_TEMP
response=$(curl -s "https://api.github.com/repos/adoptium/temurin${major_version}-binaries/releases") response=$(curl -s "https://api.github.com/repos/adoptium/temurin${major_version}-binaries/releases")
latest_jdk_download_url=$(echo "$response" | jq -r '.[0].assets[] | select(.name | contains("jdk_x64_alpine-linux") and endswith(".tar.gz")) | .browser_download_url') latest_jdk_download_url=$(echo "$response" | jq -r '.[0].assets[] | select(.name | contains("jdk_x64_alpine-linux") and endswith(".tar.gz")) | .browser_download_url')
curl -Ls "$latest_jdk_download_url" -o java_package.tar.gz curl -Ls "$latest_jdk_download_url" -o java_package.tar.gz
latest_jdk_json_url=$(jdk_download_url "$response" | jq -r '.[0].assets[] | select(.name | contains("jdk_x64_alpine-linux") and endswith(".tar.gz.json")) | .browser_download_url') latest_jdk_json_url=$(jdk_download_url "$response" | jq -r '.[0].assets[] | select(.name | contains("jdk_x64_alpine-linux") and endswith(".tar.gz.json")) | .browser_download_url')
latest_semver_version=$(curl -sL $latest_jdk_json_url | jq -r 'version.semver') latest_semver_version=$(curl -sL $latest_jdk_json_url | jq -r 'version.semver')
echo "java_version=$latest_semver_version" >> "$GITHUB_OUTPUT" echo "java_version=$latest_semver_version" >> "$GITHUB_OUTPUT"
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdk-file: ${{ runner.temp }}/java_package.tar.gz jdk-file: ${{ runner.temp }}/java_package.tar.gz
java-version: {{ steps.fetch_latest_jdk.outputs.java_version }} java-version: {{ steps.fetch_latest_jdk.outputs.java_version }}
architecture: x64 architecture: x64
- run: java --version - run: java --version
``` ```
## Testing against different Java distributions ## Testing against different Java distributions
@ -577,37 +577,37 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v6 uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
- name: Build with Maven - name: Build with Maven
run: mvn package --file pom.xml run: mvn package --file pom.xml
- name: Publish to GitHub Packages Apache Maven - name: Publish to GitHub Packages Apache Maven
run: mvn deploy run: mvn deploy
env: env:
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
- name: Set up Apache Maven Central - name: Set up Apache Maven Central
uses: actions/setup-java@v6 uses: actions/setup-java@v6
with: # running setup-java again overwrites the settings.xml with: # running setup-java again overwrites the settings.xml
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '11'
server-id: maven # Value of the distributionManagement/repository/id field of the pom.xml server-id: maven # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
- name: Publish to Apache Maven Central - name: Publish to Apache Maven Central
run: mvn deploy -Dgpg.signer=bc # requires maven-gpg-plugin >= 3.2.0 (bc signer support) run: mvn deploy -Dgpg.signer=bc # requires maven-gpg-plugin >= 3.2.0 (bc signer support)
env: env:
MAVEN_USERNAME: maven_username123 MAVEN_USERNAME: maven_username123
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # ASCII-armored secret key (TSK), e.g. from `gpg --armor --export-secret-keys YOUR_ID` MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # ASCII-armored secret key (TSK), e.g. from `gpg --armor --export-secret-keys YOUR_ID`
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
``` ```
The two `settings.xml` files created from the above example look like the following. The two `settings.xml` files created from the above example look like the following.
@ -733,22 +733,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- name: Set up JDK 11 for Shared Runner - name: Set up JDK 11 for Shared Runner
uses: actions/setup-java@v6 uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Maven - name: Build with Maven
run: mvn package --file pom.xml run: mvn package --file pom.xml
- name: Publish to GitHub Packages Apache Maven - name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env: env:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}
``` ```
## Maven transfer progress (download logs) ## Maven transfer progress (download logs)
@ -765,15 +765,15 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '21' java-version: '21'
show-download-progress: true # keep Maven download/transfer progress in the logs show-download-progress: true # keep Maven download/transfer progress in the logs
- name: Build with Maven - name: Build with Maven
run: mvn package --file pom.xml run: mvn package --file pom.xml
``` ```
***NOTES***: ***NOTES***:
@ -801,15 +801,15 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '21' java-version: '21'
problem-matcher: false problem-matcher: false
- name: Build with Maven - name: Build with Maven
run: mvn package --file pom.xml run: mvn package --file pom.xml
``` ```
Disabling the matcher only stops annotations from being created. Compiler output remains in the log, and compilation errors still fail the build step. Disabling the matcher only stops annotations from being created. Compiler output remains in the log, and compilation errors still fail the build step.
@ -822,22 +822,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v6 uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
- name: Build with Gradle - name: Build with Gradle
run: gradle build run: gradle build
- name: Publish to GitHub Packages - name: Publish to GitHub Packages
run: gradle publish run: gradle publish
env: env:
USERNAME: ${{ github.actor }} USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }} PASSWORD: ${{ secrets.GITHUB_TOKEN }}
``` ```
***NOTE: The `USERNAME` and `PASSWORD` need to correspond to the credentials environment variables used in the publishing section of your `build.gradle`.*** ***NOTE: The `USERNAME` and `PASSWORD` need to correspond to the credentials environment variables used in the publishing section of your `build.gradle`.***
@ -861,17 +861,17 @@ Toolchain entries are always merged non-destructively: existing JDK, custom, and
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: | java-version: |
8 8
11 11
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '15' java-version: '15'
``` ```
The result is a Toolchain with entries for JDKs 8, 11 and 15. You can even combine this with custom JDKs of arbitrary versions: The result is a Toolchain with entries for JDKs 8, 11 and 15. You can even combine this with custom JDKs of arbitrary versions:
@ -912,13 +912,13 @@ In case you install multiple versions of Java at once with multi-line `java-vers
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: | java-version: |
8 8
11 11
mvn-toolchain-vendor: Eclipse Temurin mvn-toolchain-vendor: Eclipse Temurin
``` ```
### Modifying The Toolchain ID For JDKs ### Modifying The Toolchain ID For JDKs
@ -926,28 +926,28 @@ Each JDK provider will receive a default `id` based on the combination of `distr
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v7 - uses: actions/checkout@v7
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '11'
mvn-toolchain-id: 'some_other_id' mvn-toolchain-id: 'some_other_id'
- run: java --version - run: java --version
``` ```
In case you install multiple versions of Java at once you can use the same syntax as used in `java-versions`. Please note that you have to declare an ID for all Java versions that will be installed or the `mvn-toolchain-id` instruction will be skipped wholesale due to mapping ambiguities. In case you install multiple versions of Java at once you can use the same syntax as used in `java-versions`. Please note that you have to declare an ID for all Java versions that will be installed or the `mvn-toolchain-id` instruction will be skipped wholesale due to mapping ambiguities.
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v6 - uses: actions/setup-java@v6
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: | java-version: |
8 8
11 11
mvn-toolchain-id: | mvn-toolchain-id: |
something_else something_else
something_other something_other
``` ```
## Java version file ## Java version file

View File

@ -4,13 +4,13 @@ The major breaking change in V2 is the new mandatory `distribution` input. This
Use the `zulu` keyword if you would like to continue using the same distribution as in V1. Use the `zulu` keyword if you would like to continue using the same distribution as in V1.
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v2 - uses: actions/setup-java@v2
with: with:
distribution: 'zulu' distribution: 'zulu'
java-version: '11' java-version: '11'
java-package: jdk # optional (jdk or jre) - defaults to jdk java-package: jdk # optional (jdk or jre) - defaults to jdk
- run: java -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
**General recommendation** — configure CI with the same distribution that is used on your local dev machine. **General recommendation** — configure CI with the same distribution that is used on your local dev machine.
@ -19,15 +19,15 @@ steps:
Since the `distribution` input is required in V2, you should specify it using `jdkfile` to continue installing Java from a local file on the runner Since the `distribution` input is required in V2, you should specify it using `jdkfile` to continue installing Java from a local file on the runner
```yaml ```yaml
steps: steps:
- run: | - run: |
download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz" download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- uses: actions/setup-java@v2 - uses: actions/setup-java@v2
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz jdkFile: ${{ runner.temp }}/java_package.tar.gz
java-version: '11.0.0' java-version: '11.0.0'
architecture: x64 architecture: x64
``` ```
## Dropping legacy Java version syntax 1.x ## Dropping legacy Java version syntax 1.x