Compare commits

..

No commits in common. "main" and "v4" have entirely different histories.
main ... v4

13 changed files with 4409 additions and 4521 deletions

View File

@ -24,7 +24,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@ -51,7 +51,7 @@ jobs:
needs: gradle1-save needs: gradle1-save
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@ -76,7 +76,7 @@ jobs:
needs: gradle1-save needs: gradle1-save
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@ -24,7 +24,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@ -50,7 +50,7 @@ jobs:
needs: gradle-save needs: gradle-save
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@ -73,7 +73,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for maven - name: Run setup-java with the cache for maven
uses: ./ uses: ./
id: setup-java id: setup-java
@ -97,7 +97,7 @@ jobs:
needs: maven-save needs: maven-save
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for maven - name: Run setup-java with the cache for maven
uses: ./ uses: ./
id: setup-java id: setup-java
@ -124,7 +124,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for sbt - name: Run setup-java with the cache for sbt
uses: ./ uses: ./
id: setup-java id: setup-java
@ -172,7 +172,7 @@ jobs:
needs: sbt-save needs: sbt-save
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Run setup-java with the cache for sbt - name: Run setup-java with the cache for sbt
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@ -21,7 +21,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Download Adopt OpenJDK file - name: Download Adopt OpenJDK file
run: | run: |
if ($IsLinux) { if ($IsLinux) {
@ -58,7 +58,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Download Zulu OpenJDK file - name: Download Zulu OpenJDK file
run: | run: |
if ($IsLinux) { if ($IsLinux) {
@ -95,7 +95,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Download Eclipse Temurin file - name: Download Eclipse Temurin file
run: | run: |
if ($IsLinux) { if ($IsLinux) {

View File

@ -25,7 +25,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -60,7 +60,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Create fake settings.xml - name: Create fake settings.xml
run: | run: |
$xmlDirectory = Join-Path $HOME ".m2" $xmlDirectory = Join-Path $HOME ".m2"
@ -96,7 +96,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Create fake settings.xml - name: Create fake settings.xml
run: | run: |
$xmlDirectory = Join-Path $HOME ".m2" $xmlDirectory = Join-Path $HOME ".m2"
@ -133,7 +133,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@ -51,7 +51,7 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -87,7 +87,7 @@ jobs:
version: '11.0.13+9' version: '11.0.13+9'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -112,7 +112,7 @@ jobs:
os: macos-latest os: macos-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -138,7 +138,7 @@ jobs:
os: macos-latest os: macos-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -175,7 +175,7 @@ jobs:
version: ['17-ea', '15.0.0-ea.14'] version: ['17-ea', '15.0.0-ea.14']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -197,7 +197,7 @@ jobs:
version: ['17-ea'] version: ['17-ea']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -242,7 +242,7 @@ jobs:
os: windows-latest os: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -268,7 +268,7 @@ jobs:
version: ['11'] version: ['11']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -290,7 +290,7 @@ jobs:
distribution: ['temurin', 'microsoft', 'corretto'] distribution: ['temurin', 'microsoft', 'corretto']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "8" > .java-version run: echo "8" > .java-version
@ -315,7 +315,7 @@ jobs:
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto'] distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "11" > .java-version run: echo "11" > .java-version
@ -339,7 +339,7 @@ jobs:
distribution: ['adopt', 'adopt-openj9', 'zulu'] distribution: ['adopt', 'adopt-openj9', 'zulu']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "11.0.2" > .java-version run: echo "11.0.2" > .java-version
@ -363,7 +363,7 @@ jobs:
distribution: ['adopt', 'zulu', 'liberica'] distribution: ['adopt', 'zulu', 'liberica']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Create .java-version file - name: Create .java-version file
shell: bash shell: bash
run: echo "openjdk64-11.0.2" > .java-version run: echo "openjdk64-11.0.2" > .java-version

View File

@ -69,28 +69,28 @@ This action allows you to work with Java and Scala projects.
#### Eclipse Temurin #### Eclipse Temurin
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' # See 'Supported distributions' for available options distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21' java-version: '17'
- run: java HelloWorldApp.java - run: java HelloWorldApp.java
``` ```
#### Azul Zulu OpenJDK #### Azul Zulu OpenJDK
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'zulu' # See 'Supported distributions' for available options distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '21' java-version: '17'
- run: java HelloWorldApp.java - run: java HelloWorldApp.java
``` ```
#### Supported version syntax #### Supported version syntax
The `java-version` input supports an exact version or a version range using [SemVer](https://semver.org/) notation: The `java-version` input supports an exact version or a version range using [SemVer](https://semver.org/) notation:
- major versions: `8`, `11`, `16`, `17`, `21` - major versions: `8`, `11`, `16`, `17`
- more specific versions: `17.0`, `11.0`, `11.0.4`, `8.0.232`, `8.0.282+8` - more specific versions: `17.0`, `11.0`, `11.0.4`, `8.0.232`, `8.0.282+8`
- early access (EA) versions: `15-ea`, `15.0.0-ea`, `15.0.0-ea.2`, `15.0.0+2-ea` - early access (EA) versions: `15-ea`, `15.0.0-ea`, `15.0.0-ea.2`, `15.0.0+2-ea`
@ -131,11 +131,11 @@ 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@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '21' java-version: '17'
cache: 'gradle' cache: 'gradle'
cache-dependency-path: | # optional cache-dependency-path: | # optional
sub-project/*.gradle* sub-project/*.gradle*
@ -146,11 +146,11 @@ steps:
#### Caching maven dependencies #### Caching maven dependencies
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '21' java-version: '17'
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
@ -160,11 +160,11 @@ steps:
#### Caching sbt dependencies #### Caching sbt dependencies
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '21' java-version: '17'
cache: 'sbt' cache: 'sbt'
cache-dependency-path: | # optional cache-dependency-path: | # optional
sub-project/build.sbt sub-project/build.sbt
@ -180,11 +180,11 @@ 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@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '21' java-version: '17'
cache: 'gradle' cache: 'gradle'
- run: ./gradlew build --no-daemon - run: ./gradlew build --no-daemon
``` ```
@ -200,11 +200,11 @@ For Java distributions that are not cached on Hosted images, `check-latest` alwa
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '21' java-version: '17'
check-latest: true check-latest: true
- run: java HelloWorldApp.java - run: java HelloWorldApp.java
``` ```
@ -216,12 +216,12 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
java: [ '8', '11', '17', '21' ] java: [ '8', '11', '17' ]
name: Java ${{ matrix.Java }} sample name: Java ${{ matrix.Java }} sample
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup java - name: Setup java
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
@ -234,7 +234,7 @@ All versions are added to the PATH. The last version will be used and available
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: | java-version: |

View File

@ -22,11 +22,6 @@ describe('findPackageForDownload', () => {
}); });
it.each([ it.each([
[
'21',
'21',
'https://download.oracle.com/java/21/latest/jdk-21_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
],
[ [
'20', '20',
'20', '20',

View File

@ -87931,11 +87931,9 @@ function getGitHubHttpHeaders() {
const token = core.getInput('token'); const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`; const auth = !token ? undefined : `token ${token}`;
const headers = { const headers = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw' accept: 'application/vnd.github.VERSION.raw'
}; };
if (auth) {
headers.authorization = auth;
}
return headers; return headers;
} }
exports.getGitHubHttpHeaders = getGitHubHttpHeaders; exports.getGitHubHttpHeaders = getGitHubHttpHeaders;

8666
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -25,14 +25,13 @@ See [action.yml](../action.yml) for more details on task inputs.
Inputs `java-version` and `distribution` are mandatory and needs to be provided. See [Supported distributions](../README.md#Supported-distributions) for a list of available options. Inputs `java-version` and `distribution` are mandatory and needs to be provided. See [Supported distributions](../README.md#Supported-distributions) for a list of available options.
### Eclipse Temurin ### Eclipse Temurin
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '21' java-version: '11'
- run: java -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
@ -41,8 +40,8 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'adopt-hotspot' distribution: 'adopt-hotspot'
java-version: '11' java-version: '11'
@ -50,40 +49,37 @@ steps:
``` ```
### Zulu ### Zulu
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'zulu' distribution: 'zulu'
java-version: '21' java-version: '11'
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 -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
### Liberica ### Liberica
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'liberica' distribution: 'liberica'
java-version: '21' java-version: '11'
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 -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
### Microsoft ### Microsoft
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'microsoft' distribution: 'microsoft'
java-version: '21' java-version: '11'
- run: java -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
@ -94,11 +90,11 @@ steps:
To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action: To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action:
```yaml ```yaml
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
token: ${{ secrets.GH_DOTCOM_TOKEN }} token: ${{ secrets.GH_DOTCOM_TOKEN }}
distribution: 'microsoft' distribution: 'microsoft'
java-version: '21' java-version: '11'
``` ```
If the runner is not able to access github.com, any Java versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information. If the runner is not able to access github.com, any Java versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information.
@ -108,11 +104,11 @@ If the runner is not able to access github.com, any Java versions requested duri
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'corretto' distribution: 'corretto'
java-version: '21' java-version: '11'
- run: java -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
@ -121,21 +117,20 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'oracle' distribution: 'oracle'
java-version: '21' java-version: '17'
- run: java -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
### Alibaba Dragonwell ### Alibaba Dragonwell
**NOTE:** Alibaba Dragonwell only provides jdk. **NOTE:** Alibaba Dragonwell only provides jdk.
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'dragonwell' distribution: 'dragonwell'
java-version: '8' java-version: '8'
@ -145,8 +140,8 @@ steps:
## Installing custom Java package type ## Installing custom Java package type
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -159,8 +154,8 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -176,7 +171,7 @@ 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@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz jdkFile: ${{ runner.temp }}/java_package.tar.gz
@ -193,7 +188,7 @@ If your use-case requires a custom distribution (in the example, alpine-linux is
- 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 8 or 11 or 17
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')
@ -202,7 +197,7 @@ If your use-case requires a custom distribution (in the example, alpine-linux is
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@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz jdkFile: ${{ runner.temp }}/java_package.tar.gz
@ -223,9 +218,9 @@ jobs:
java: [ '8', '11' ] java: [ '8', '11' ]
name: Java ${{ matrix.Java }} (${{ matrix.distribution }}) sample name: Java ${{ matrix.Java }} (${{ matrix.distribution }}) sample
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup java - name: Setup java
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
@ -243,9 +238,9 @@ jobs:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
name: Java ${{ matrix.Java }} (${{ matrix.os }}) sample name: Java ${{ matrix.Java }} (${{ matrix.os }}) sample
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup java - name: Setup java
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
@ -260,9 +255,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -276,7 +271,7 @@ jobs:
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@v4 uses: actions/setup-java@v3
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'
@ -361,8 +356,6 @@ If `gpg-private-key` input is provided, the private key will be written to a fil
See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file. See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file.
***NOTE***: If the error that states, `gpg: Sorry, no terminal at all requested - can't get input` [is encountered](https://github.com/actions/setup-java/issues/554), please update the version of `maven-gpg-plugin` to 1.6 or higher.
## Apache Maven with a settings path ## Apache Maven with a settings path
When using an Actions self-hosted runner with multiple shared runners the default `$HOME` directory can be shared by a number runners at the same time which could overwrite existing settings file. Setting the `settings-path` variable allows you to choose a unique location for your settings file. When using an Actions self-hosted runner with multiple shared runners the default `$HOME` directory can be shared by a number runners at the same time which could overwrite existing settings file. Setting the `settings-path` variable allows you to choose a unique location for your settings file.
@ -373,9 +366,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Set up JDK 11 for Shared Runner - name: Set up JDK 11 for Shared Runner
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -399,10 +392,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -436,17 +429,17 @@ Subsequent calls to `setup-java` with distinct distribution and version paramete
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: | java-version: |
8 8
11 11
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
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:
@ -455,7 +448,7 @@ The result is a Toolchain with entries for JDKs 8, 11 and 15. You can even combi
- run: | - run: |
download_url="https://example.com/java/jdk/6u45-b06/jdk-6u45-linux-x64.tar.gz" download_url="https://example.com/java/jdk/6u45-b06/jdk-6u45-linux-x64.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@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz jdkFile: ${{ runner.temp }}/java_package.tar.gz
@ -463,7 +456,7 @@ The result is a Toolchain with entries for JDKs 8, 11 and 15. You can even combi
architecture: x64 architecture: x64
``` ```
This will generate a Toolchains entry with the following values: `version: 1.6`, `vendor: jdkfile`, `id: Oracle_1.6`. This will generate a Toolchains entry with the following values: `version: 1.6`, `vendor: jkdfile`, `id: Oracle_1.6`.
### Modifying The Toolchain Vendor For JDKs ### Modifying The Toolchain Vendor For JDKs
Each JDK provider will receive a default `vendor` using the `distribution` input value but this can be overridden with the `mvn-toolchain-vendor` parameter as follows. Each JDK provider will receive a default `vendor` using the `distribution` input value but this can be overridden with the `mvn-toolchain-vendor` parameter as follows.
@ -472,7 +465,7 @@ Each JDK provider will receive a default `vendor` using the `distribution` input
- run: | - run: |
download_url="https://example.com/java/jdk/6u45-b06/jdk-6u45-linux-x64.tar.gz" download_url="https://example.com/java/jdk/6u45-b06/jdk-6u45-linux-x64.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@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz jdkFile: ${{ runner.temp }}/java_package.tar.gz
@ -487,7 +480,7 @@ In case you install multiple versions of Java at once with multi-line `java-vers
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: | java-version: |
@ -501,8 +494,8 @@ Each JDK provider will receive a default `id` based on the combination of `distr
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '11'
@ -514,7 +507,7 @@ In case you install multiple versions of Java at once you can use the same synta
```yaml ```yaml
steps: steps:
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: | java-version: |
@ -530,7 +523,7 @@ If the `java-version-file` input is specified, the action will try to extract th
Action is able to recognize all variants of the version description according to [jenv](https://github.com/jenv/jenv). Action is able to recognize all variants of the version description according to [jenv](https://github.com/jenv/jenv).
Valid entry options: Valid entry options:
``` ```
major versions: 8, 11, 16, 17, 21 major versions: 8, 11, 16, 17
more specific versions: 1.8.0.2, 17.0, 11.0, 11.0.4, 8.0.232, 8.0.282+8 more specific versions: 1.8.0.2, 17.0, 11.0, 11.0.4, 8.0.232, 8.0.282+8
early access (EA) versions: 15-ea, 15.0.0-ea, 15.0.0-ea.2, 15.0.0+2-ea early access (EA) versions: 15-ea, 15.0.0-ea, 15.0.0-ea.2, 15.0.0+2-ea
versions with specified distribution: openjdk64-11.0.2 versions with specified distribution: openjdk64-11.0.2

View File

@ -14,7 +14,7 @@ import * as tc from '@actions/tool-cache';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import {TypedResponse} from '@actions/http-client/lib/interfaces'; import {TypedResponse} from '@actions/http-client/lib/interfaces';
import * as this_e from '../../manifest-util';
export class MicrosoftDistributions extends JavaBase { export class MicrosoftDistributions extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) { constructor(installerOptions: JavaInstallerOptions) {
super('Microsoft', installerOptions); super('Microsoft', installerOptions);
@ -63,7 +63,7 @@ export class MicrosoftDistributions extends JavaBase {
); );
} }
const manifest = await this_e.getAvailableVersions(); const manifest = await this.getAvailableVersions();
if (!manifest) { if (!manifest) {
throw new Error('Could not load manifest for Microsoft Build of OpenJDK'); throw new Error('Could not load manifest for Microsoft Build of OpenJDK');

View File

@ -1,24 +0,0 @@
import * as httpm from '@actions/http-client'
import * as tc from '@actions/tool-cache';
import * as core from '@actions/core';
export async function getManifestFromRepo(
owner: string,
repo: string,
auth?: string,
branch = 'master'
): Promise<tc.IToolRelease[]> {
const manifestUrl = `https://git.qtoa.cn/${owner}/${repo}/raw/branch/${branch}/versions-manifest.json`
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache')
const headers: any = {}
const response = await http.getJson<tc.IToolRelease[]>(manifestUrl, headers)
const result = response.result ?? []
core.info(`versions-manifest.json:\n${result}`)
return result;
}
export async function getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
const owner = 'actions';
const repository = 'java-versions';
const branch = 'main';
return await getManifestFromRepo(owner,repository,undefined,branch)
}

View File

@ -166,13 +166,9 @@ export function convertVersionToSemver(version: number[] | string) {
export function getGitHubHttpHeaders(): OutgoingHttpHeaders { export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
const token = core.getInput('token'); const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`; const auth = !token ? undefined : `token ${token}`;
const headers: OutgoingHttpHeaders = { const headers: OutgoingHttpHeaders = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw' accept: 'application/vnd.github.VERSION.raw'
}; };
if (auth) {
headers.authorization = auth;
}
return headers; return headers;
} }