Compare commits

...

18 Commits

Author SHA1 Message Date
Gregory Mitchell
cc7d134220
Merge d3a91fa39c into bcfbca5b71 2024-09-11 09:50:06 -05:00
Gregory Mitchell
d3a91fa39c
Resolve Merge Conflicts 2024-09-11 14:49:52 +00:00
Joel Ambass
bcfbca5b71
Merge pull request #684 from actions/Jcambass-patch-1
Add workflow file for publishing releases to immutable action package
2024-09-11 09:54:38 +02:00
Joel Ambass
78eae7945c
Add workflow file for publishing releases to immutable action package
This workflow file publishes new action releases to the immutable action package of the same name as this repo.

This is part of the Immutable Actions project which is not yet fully released to the public. First party actions like this one are part of our initial testing of this feature.
2024-09-11 09:48:56 +02:00
aparnajyothi-y
2dfa2011c5
basic validation failure fix (#682) 2024-09-06 14:42:39 -05:00
Tobias
7467385c61
feat: add support for SapMachine JDK/JRE (#614)
Co-authored-by: Christian Schwaninger <christian.schwaninger@sap.com>
2024-09-05 14:04:24 -05:00
Gregory Mitchell
6d2c5e1f82
Update Authorization, Add Documentation 2024-07-09 10:33:58 -05:00
Gregory Mitchell
b4d76a354b
Add GITHUB_TOKEN Authentication 2024-07-08 20:44:46 -05:00
Gregory Mitchell
3653181378
Merge branch 'actions:main' into main 2024-06-30 19:36:32 -04:00
Gregory Mitchell
e1f4c15fac
Fix Windows Support 2024-06-18 23:44:58 -05:00
Gregory Mitchell
ab5c653696
npm run build (JBR) 2024-06-18 23:39:23 -05:00
Gregory Mitchell
4f206bae88
Fix Incorrect File Extension 2024-06-18 23:37:51 -05:00
Gregory Mitchell
99fc2135f7
Switch to jbrsdk_jcef 2024-06-18 23:07:24 -05:00
Gregory Mitchell
c192e7bfa1
Fix Incorrect JBR Distribution 2024-06-18 22:57:33 -05:00
Gregory Mitchell
7f3ab2648f
npm run build (JBR) 2024-06-18 22:13:09 -05:00
Gregory Mitchell
db1c6faf09
Fix Runtime Unrecognizable 2024-06-18 22:11:58 -05:00
Gregory Mitchell
07ea605e4b
Add Docs + Distro Factory 2024-06-05 16:00:38 -05:00
Gregory Mitchell
bee7c8545c
Add Support for JetBrains Runtime
- Add Installer, Models
- Includes Tests & Test Manifest Data
- Add to `e2e-versions.yml`
- Run `npm run build`
- Update README.md
2024-06-05 15:43:34 -05:00
14 changed files with 89460 additions and 9 deletions

View File

@ -30,7 +30,9 @@ jobs:
'microsoft',
'semeru',
'corretto',
'dragonwell'
'dragonwell',
'sapmachine',
'jetbrains'
] # internally 'adopt-hotspot' is the same as 'adopt'
version: ['21', '11', '17']
exclude:
@ -85,6 +87,9 @@ jobs:
- distribution: dragonwell
os: ubuntu-latest
version: '11.0.13+9'
- distribution: sapmachine
os: ubuntu-latest
version: '17.0.7'
steps:
- name: Checkout
uses: actions/checkout@v4
@ -106,7 +111,8 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
distribution:
['temurin', 'zulu', 'liberica', 'dragonwell', 'sapmachine']
exclude:
- distribution: dragonwell
os: macos-latest
@ -132,7 +138,8 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
distribution:
['temurin', 'zulu', 'liberica', 'dragonwell', 'sapmachine']
exclude:
- distribution: dragonwell
os: macos-latest
@ -154,10 +161,10 @@ jobs:
{
$envName = "JAVA_HOME_${version}_${env:RUNNER_ARCH}"
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
if (-not (Test-Path "$JavaVersionPath")) {
if (-not (Test-Path "$JavaVersionPath")) {
Write-Host "$envName is not found"
exit 1
}
}
}
shell: pwsh
- name: Verify Java
@ -208,6 +215,28 @@ jobs:
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-ea-versions-sapmachine:
name: sapmachine ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
needs: setup-java-major-minor-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
version: ['17-ea', '21-ea']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
with:
java-version: ${{ matrix.version }}
distribution: sapmachine
- name: Verify Java
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-custom-package-type:
name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }}
needs: setup-java-major-minor-versions
@ -216,7 +245,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-13, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'semeru']
distribution: ['temurin', 'zulu', 'liberica', 'semeru', 'sapmachine']
java-package: ['jre']
version: ['17.0']
include:

View File

@ -0,0 +1,22 @@
name: 'Publish Immutable Action Version'
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checking out
uses: actions/checkout@v4
- name: Publish
id: publish
uses: actions/publish-immutable-action@0.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -28,7 +28,7 @@ This action allows you to work with Java and Scala projects.
- `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified.
- `java-version-file`: The path to a file containing java version. Supported file types are `.java-version` and `.tool-versions`. See more details in [about .java-version-file](docs/advanced-usage.md#Java-version-file).
- `distribution`: _(required)_ Java [distribution](#supported-distributions).
- `java-package`: The packaging variant of the chosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`. Default value: `jdk`.
@ -108,6 +108,8 @@ Currently, the following distributions are supported:
| `semeru` | IBM Semeru Runtime Open Edition | [Link](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [Link](https://openjdk.java.net/legal/gplv2+ce.html) |
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
| `sapmachine` | SAP SapMachine JDK/JRE | [Link](https://sapmachine.io/) | [Link](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
| `jetbrains` | JetBrains Runtime | [Link](https://github.com/JetBrains/JetBrainsRuntime/) | [Link](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
@ -257,6 +259,7 @@ In the example above multiple JDKs are installed for the same job. The result af
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
- [Oracle](docs/advanced-usage.md#Oracle)
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
- [SapMachine](docs/advanced-usage.md#SapMachine)
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)

View File

@ -0,0 +1,794 @@
[
{
"tag_name": "jbr-release-21.0.3b465.3",
"semver": "21.0.3",
"build": 465.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.3-windows-x64-b465.3.tar.gz"
},
{
"tag_name": "jbr-release-21.0.3b458.1",
"semver": "21.0.3",
"build": 458.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.3-windows-x64-b458.1.tar.gz"
},
{
"tag_name": "jbr-release-21.0.3b453.2",
"semver": "21.0.3",
"build": 453.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.3-windows-x64-b453.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.11b1207.24",
"semver": "17.0.11",
"build": 1207.24,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.11-windows-x64-b1207.24.tar.gz"
},
{
"tag_name": "jbr-release-17.0.11b1207.23",
"semver": "17.0.11",
"build": 1207.23,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.11-windows-x64-b1207.23.tar.gz"
},
{
"tag_name": "jbr-release-21.0.3b446.1",
"semver": "21.0.3",
"build": 446.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.3-windows-x64-b446.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.11b1207.20",
"semver": "17.0.11",
"build": 1207.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.11-windows-x64-b1207.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1207.14",
"semver": "17.0.10",
"build": 1207.14,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1207.14.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b829.27",
"semver": "17.0.10",
"build": 829.27,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b829.27.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1087.23",
"semver": "17.0.10",
"build": 1087.23,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1087.23.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1000.50",
"semver": "17.0.10",
"build": 1000.5,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1000.5.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1207.12",
"semver": "17.0.10",
"build": 1207.12,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1207.12.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1087.21",
"semver": "17.0.10",
"build": 1087.21,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1087.21.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1207.6",
"semver": "17.0.10",
"build": 1207.6,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1207.6.tar.gz"
},
{
"tag_name": "jbr-release-21.0.2b375.1",
"semver": "21.0.2",
"build": 375.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.2-windows-x64-b375.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1207.1",
"semver": "17.0.10",
"build": 1207.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1207.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1186.1",
"semver": "17.0.10",
"build": 1186.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1186.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1171.14",
"semver": "17.0.10",
"build": 1171.14,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1171.14.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b829.26",
"semver": "17.0.10",
"build": 829.26,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b829.26.tar.gz"
},
{
"tag_name": "jbr-release-21.0.2b346.3",
"semver": "21.0.2",
"build": 346.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.2-windows-x64-b346.3.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1000.48",
"semver": "17.0.10",
"build": 1000.48,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1000.48.tar.gz"
},
{
"tag_name": "jbr-release-21.0.2b341.4",
"semver": "21.0.2",
"build": 341.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.2-windows-x64-b341.4.tar.gz"
},
{
"tag_name": "jbr-release-17.0.10b1087.17",
"semver": "17.0.10",
"build": 1087.17,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.10-windows-x64-b1087.17.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1166.2",
"semver": "17.0.9",
"build": 1166.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1166.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1162.7",
"semver": "17.0.9",
"build": 1162.7,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1162.7.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1087.11",
"semver": "17.0.9",
"build": 1087.11,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1087.11.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1087.9",
"semver": "17.0.9",
"build": 1087.9,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1087.9.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1087.7",
"semver": "17.0.9",
"build": 1087.7,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1087.7.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1000.47",
"semver": "17.0.9",
"build": 1000.47,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1000.47.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1000.46",
"semver": "17.0.9",
"build": 1000.46,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1000.46.tar.gz"
},
{
"tag_name": "jbr-release-17.0.9b1087.3",
"semver": "17.0.9",
"build": 1087.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.9-windows-x64-b1087.3.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8.1b1080.1",
"semver": "17.0.8.1",
"build": 1080.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8.1-windows-x64-b1080.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8.1b1072.1",
"semver": "17.0.8.1",
"build": 1072.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8.1-windows-x64-b1072.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8.1b1070.2",
"semver": "17.0.8.1",
"build": 1070.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8.1-windows-x64-b1070.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8.1b1063.1",
"semver": "17.0.8.1",
"build": 1063.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8.1-windows-x64-b1063.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8.1b1000.32",
"semver": "17.0.8.1",
"build": 1000.32,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8.1-windows-x64-b1000.32.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8.1b1059.3",
"semver": "17.0.8.1",
"build": 1059.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8.1-windows-x64-b1059.3.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8b1000.22",
"semver": "17.0.8",
"build": 1000.22,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8-windows-x64-b1000.22.tar.gz"
},
{
"tag_name": "jbr-release-21b212.1",
"semver": "21",
"build": 212.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21-windows-x64-b212.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.8b1000.8",
"semver": "17.0.8",
"build": 1000.8,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.8-windows-x64-b1000.8.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b1000.6",
"semver": "17.0.7",
"build": 1000.6,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b1000.6.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b1000.5",
"semver": "17.0.7",
"build": 1000.5,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b1000.5.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b1000.2",
"semver": "17.0.7",
"build": 1000.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b1000.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b985.2",
"semver": "17.0.7",
"build": 985.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b985.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b979.4",
"semver": "17.0.7",
"build": 979.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b979.4.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b829.16",
"semver": "17.0.7",
"build": 829.16,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b829.16.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b966.2",
"semver": "17.0.7",
"build": 966.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b966.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b964.1",
"semver": "17.0.7",
"build": 964.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b964.1.tar.gz"
},
{
"tag_name": "jbr-release-21b126.4",
"semver": "21",
"build": 126.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21-windows-x64-b126.4.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b829.14",
"semver": "17.0.7",
"build": 829.14,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b829.14.tar.gz"
},
{
"tag_name": "jbr-release-17.0.7b953.1",
"semver": "17.0.7",
"build": 953.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.7-windows-x64-b953.1.tar.gz"
},
{
"tag_name": "jbr-release-21b75.2",
"semver": "21",
"build": 75.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21-windows-x64-b75.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b829.9",
"semver": "17.0.6",
"build": 829.9,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b829.9.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b469.82",
"semver": "17.0.6",
"build": 469.82,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b469.82.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b829.5",
"semver": "17.0.6",
"build": 829.5,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b829.5.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b653.34",
"semver": "17.0.6",
"build": 653.34,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b653.34.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b829.4",
"semver": "17.0.6",
"build": 829.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b829.4.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b829.1",
"semver": "17.0.6",
"build": 829.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b829.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b653.32",
"semver": "17.0.6",
"build": 653.32,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b653.32.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b802.4",
"semver": "17.0.6",
"build": 802.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b802.4.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b802.1",
"semver": "17.0.6",
"build": 802.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b802.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b785.1",
"semver": "17.0.6",
"build": 785.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b785.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.6b779.1",
"semver": "17.0.6",
"build": 779.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.6-windows-x64-b779.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b762.1",
"semver": "17.0.5",
"build": 762.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b762.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b653.25",
"semver": "17.0.5",
"build": 653.25,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b653.25.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b759.1",
"semver": "17.0.5",
"build": 759.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b759.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b653.23",
"semver": "17.0.5",
"build": 653.23,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b653.23.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b653.14",
"semver": "17.0.5",
"build": 653.14,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b653.14.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b469.71",
"semver": "17.0.5",
"build": 469.71,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b469.71.tar.gz"
},
{
"tag_name": "jbr11_0_16b2043.64",
"semver": "11.0.16",
"build": 2043.64,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.16-windows-x64-b2043.64.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b653.6",
"semver": "17.0.5",
"build": 653.6,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b653.6.tar.gz"
},
{
"tag_name": "jbr-release-17.0.5b469.67",
"semver": "17.0.5",
"build": 469.67,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.5-windows-x64-b469.67.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4.1b653.1",
"semver": "17.0.4.1",
"build": 653.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4.1-windows-x64-b653.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4.1b646.8",
"semver": "17.0.4.1",
"build": 646.8,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4.1-windows-x64-b646.8.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4.1b629.2",
"semver": "17.0.4.1",
"build": 629.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4.1-windows-x64-b629.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4.1b617.2",
"semver": "17.0.4.1",
"build": 617.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4.1-windows-x64-b617.2.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4.1b469.62",
"semver": "17.0.4.1",
"build": 469.62,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4.1-windows-x64-b469.62.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4.1b597.1",
"semver": "17.0.4.1",
"build": 597.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4.1-windows-x64-b597.1.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4b469.53",
"semver": "17.0.4",
"build": 469.53,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4-windows-x64-b469.53.tar.gz"
},
{
"tag_name": "jbr-release-17.0.4b469.44",
"semver": "17.0.4",
"build": 469.44,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.4-windows-x64-b469.44.tar.gz"
},
{
"tag_name": "jbr-release-17.0.3b469.37",
"semver": "17.0.3",
"build": 469.37,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b469.37.tar.gz"
},
{
"tag_name": "jbr17.0.3b469.32",
"semver": "17.0.3",
"build": 469.32,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b469.32.tar.gz"
},
{
"tag_name": "jbr17.0.3b469.30",
"semver": "17.0.3",
"build": 469.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b469.3.tar.gz"
},
{
"tag_name": "jbr17.0.3b469.19",
"semver": "17.0.3",
"build": 469.19,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b469.19.tar.gz"
},
{
"tag_name": "jbr17.0.3b498.3",
"semver": "17.0.3",
"build": 498.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b498.3.tar.gz"
},
{
"tag_name": "jbr17.0.3b469.16",
"semver": "17.0.3",
"build": 469.16,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b469.16.tar.gz"
},
{
"tag_name": "jbr17.0.3b469.12",
"semver": "17.0.3",
"build": 469.12,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b469.12.tar.gz"
},
{
"tag_name": "jbr17.0.3b469.3",
"semver": "17.0.3",
"build": 469.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b469.3.tar.gz"
},
{
"tag_name": "jbr17.0.3b463.3",
"semver": "17.0.3",
"build": 463.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b463.3.tar.gz"
},
{
"tag_name": "jbr17.0.3b423.10",
"semver": "17.0.3",
"build": 423.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.3-windows-x64-b423.1.tar.gz"
},
{
"tag_name": "jbr11_0_15b2043.56",
"semver": "11.0.15",
"build": 2043.56,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.15-windows-x64-b2043.56.tar.gz"
},
{
"tag_name": "jbr11_0_14_1b2043.45",
"semver": "11.0.14.1",
"build": 2043.45,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14.1-windows-x64-b2043.45.tar.gz"
},
{
"tag_name": "jbr17.0.2b396.4",
"semver": "17.0.2",
"build": 396.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.2-windows-x64-b396.4.tar.gz"
},
{
"tag_name": "jbr11_0_14_1b2043.25",
"semver": "11.0.14.1",
"build": 2043.25,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14.1-windows-x64-b2043.25.tar.gz"
},
{
"tag_name": "jbr11_0_14_1b2043.22",
"semver": "11.0.14.1",
"build": 2043.22,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14.1-windows-x64-b2043.22.tar.gz"
},
{
"tag_name": "jbr11_0_14_1b2043.17",
"semver": "11.0.14.1",
"build": 2043.17,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14.1-windows-x64-b2043.17.tar.gz"
},
{
"tag_name": "jbr11_0_14_1b2043.14",
"semver": "11.0.14.1",
"build": 2043.14,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14.1-windows-x64-b2043.14.tar.gz"
},
{
"tag_name": "jbr11_0_14_1b2043.11",
"semver": "11.0.14.1",
"build": 2043.11,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14.1-windows-x64-b2043.11.tar.gz"
},
{
"tag_name": "jbr11_0_14b2043.2",
"semver": "11.0.14",
"build": 2043.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14-windows-x64-b2043.2.tar.gz"
},
{
"tag_name": "jbr11_0_14_1b1751.46",
"semver": "11.0.14.1",
"build": 1751.46,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14.1-windows-x64-b1751.46.tar.gz"
},
{
"tag_name": "jbr11_0_14b1993.2",
"semver": "11.0.14",
"build": 1993.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14-windows-x64-b1993.2.tar.gz"
},
{
"tag_name": "jbr17_0_2b315.1",
"semver": "17.0.2",
"build": 315.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.2-windows-x64-b315.1.tar.gz"
},
{
"tag_name": "jbr11_0_14b1982.1",
"semver": "11.0.14",
"build": 1982.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.14-windows-x64-b1982.1.tar.gz"
},
{
"tag_name": "jbr11_0_13b1890.3",
"semver": "11.0.13",
"build": 1890.3,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.13-windows-x64-b1890.3.tar.gz"
},
{
"tag_name": "jbr11_0_13b1751.25",
"semver": "11.0.13",
"build": 1751.25,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.13-windows-x64-b1751.25.tar.gz"
},
{
"tag_name": "jbr11_0_13b1751.24",
"semver": "11.0.13",
"build": 1751.24,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.13-windows-x64-b1751.24.tar.gz"
},
{
"tag_name": "jbr11_0_13b1751.21",
"semver": "11.0.13",
"build": 1751.21,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.13-windows-x64-b1751.21.tar.gz"
},
{
"tag_name": "jbr17_0_1b164.8",
"semver": "17.0.1",
"build": 164.8,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.1-windows-x64-b164.8.tar.gz"
},
{
"tag_name": "jbr11_0_13b1751.19",
"semver": "11.0.13",
"build": 1751.19,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.13-windows-x64-b1751.19.tar.gz"
},
{
"tag_name": "jb11_0_13-b1504.49",
"semver": "11.0.13",
"build": 1504.49,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.13-windows-x64-b1504.49.tar.gz"
},
{
"tag_name": "jbr17_0_1b164.4",
"semver": "17.0.1",
"build": 164.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17.0.1-windows-x64-b164.4.tar.gz"
},
{
"tag_name": "jbr11_0_13b1751.16",
"semver": "11.0.13",
"build": 1751.16,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.13-windows-x64-b1751.16.tar.gz"
},
{
"tag_name": "jbr17b135.1",
"semver": "17",
"build": 135.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17-windows-x64-b135.1.tar.gz"
},
{
"tag_name": "jbr11_0_12b1751.11",
"semver": "11.0.12",
"build": 1751.11,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1751.11.tar.gz"
},
{
"tag_name": "jbr11_0_12b1729.1",
"semver": "11.0.12",
"build": 1729.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1729.1.tar.gz"
},
{
"tag_name": "jbr11_0_12b1715.4",
"semver": "11.0.12",
"build": 1715.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1715.4.tar.gz"
},
{
"tag_name": "jbr17b106.1",
"semver": "17",
"build": 106.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-17-windows-x64-b106.1.tar.gz"
},
{
"tag_name": "jbr11_0_12b1692.9",
"semver": "11.0.12",
"build": 1692.9,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1692.9.tar.gz"
},
{
"tag_name": "jbr17-b87.7",
"semver": "r17",
"build": 87.7,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-r17-windows-x64-b87.7.tar.gz"
},
{
"tag_name": "jb11_0_12-b1504.40",
"semver": "11.0.12",
"build": 1504.4,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1504.4.tar.gz"
},
{
"tag_name": "jb11_0_12-b1504.37",
"semver": "11.0.12",
"build": 1504.37,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1504.37.tar.gz"
},
{
"tag_name": "jbr11_0_12b1665.1",
"semver": "11.0.12",
"build": 1665.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1665.1.tar.gz"
},
{
"tag_name": "jb11_0_12-b11_0_12b1649.1",
"semver": "11.0.12",
"build": null,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-bNaN.tar.gz"
},
{
"tag_name": "jb11_0_12-b1504.28",
"semver": "11.0.12",
"build": 1504.28,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1504.28.tar.gz"
},
{
"tag_name": "jb11_0_12-b1504.27",
"semver": "11.0.12",
"build": 1504.27,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.12-windows-x64-b1504.27.tar.gz"
},
{
"tag_name": "jb11_0_11-b1504.16",
"semver": "11.0.11",
"build": 1504.16,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.11-windows-x64-b1504.16.tar.gz"
},
{
"tag_name": "jb11_0_11-b1504.13",
"semver": "11.0.11",
"build": 1504.13,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.11-windows-x64-b1504.13.tar.gz"
},
{
"tag_name": "jb11_0_11-b1504.12",
"semver": "11.0.11",
"build": 1504.12,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.11-windows-x64-b1504.12.tar.gz"
},
{
"tag_name": "jb11_0_11-b1542.1",
"semver": "11.0.11",
"build": 1542.1,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.11-windows-x64-b1542.1.tar.gz"
},
{
"tag_name": "jb11_0_11-b1504.8",
"semver": "11.0.11",
"build": 1504.8,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-11.0.11-windows-x64-b1504.8.tar.gz"
},
{
"tag_name": "11_0_11b1536.2",
"semver": "0.11",
"build": 1536.2,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-0.11-windows-x64-b1536.2.tar.gz"
},
{
"tag_name": "11_0_11-b1522",
"semver": ".0.11",
"build": 1522,
"url": "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-.0.11-windows-x64-b1522.tar.gz"
}
]

87242
__tests__/data/sapmachine.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,109 @@
import {HttpClient} from '@actions/http-client';
import os from 'os';
import fs from 'fs';
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
import {JavaInstallerOptions} from '../../src/distributions/base-models';
import manifestData from '../data/jetbrains.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: []
});
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it('load available versions', async () => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: []
});
const distribution = new JetBrainsDistribution({
version: '17',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).not.toBeNull();
expect(availableVersions.length).toBe(manifestData.length * 2);
});
});
describe('findPackageForDownload', () => {
it.each([
['17', '17.0.11+1207.24'],
['11.0', '11.0.16+2043.64'],
['11.0.11', '11.0.11+1542.1'],
['21.0.2', '21.0.2+375.1'],
['21', '21.0.3+465.3'],
['x', '21.0.3+465.3']
])('version is resolved correctly %s -> %s', async (input, expected) => {
const distribution = new JetBrainsDistribution(
{
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
);
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](input);
expect(resolvedVersion.version).toBe(expected);
});
it('version is not found', async () => {
const distribution = new JetBrainsDistribution(
{
version: '8.0.452',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
);
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(distribution['findPackageForDownload']('8.x')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
it('version list is empty', async () => {
const distribution = new JetBrainsDistribution(
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
);
distribution['getAvailableVersions'] = async () => [];
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
});

View File

@ -0,0 +1,294 @@
import {HttpClient} from '@actions/http-client';
import {SapMachineDistribution} from '../../src/distributions/sapmachine/installer';
import * as utils from '../../src/util';
import manifestData from '../data/sapmachine.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData
});
spyUtilGetDownloadArchiveExtension = jest.spyOn(
utils,
'getDownloadArchiveExtension'
);
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
const mockPlatform = (
distribution: SapMachineDistribution,
platform: string
) => {
distribution['getPlatformOption'] = () => platform;
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
};
describe('shouldFallbackToBackupUrl', () => {
it('should return correct release when the primary URL is not available', async () => {
spyHttpClient.mockReturnValueOnce({
statusCode: 404,
headers: {},
result: ''
});
spyHttpClient.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData
});
const version = '17';
const distribution = new SapMachineDistribution({
version: version,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, 'linux');
const availableVersion = await distribution['findPackageForDownload'](
version
);
expect(availableVersion).not.toBeNull();
expect(availableVersion.url).toBe(
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-x64_bin.tar.gz'
);
});
});
describe('getAvailableVersions', () => {
it.each([
['11', 'x64', 'linux', 71],
['11', 'aarch64', 'linux', 54],
['17', 'riscv', 'linux', 0],
['16.0.1', 'x64', 'linux', 71],
['23-ea', 'x64', 'linux', 798],
['23-ea', 'aarch64', 'windows', 0],
['23-ea', 'x64', 'windows', 750]
])(
'should get right number of available versions from JSON',
async (
jdkVersion: string,
arch: string,
platform: string,
len: number
) => {
const distribution = new SapMachineDistribution({
version: jdkVersion,
architecture: arch,
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, platform);
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).not.toBeNull();
expect(availableVersions.length).toBe(len);
}
);
});
describe('findPackageForDownload', () => {
it.each([
[
'11',
'linux',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.22/sapmachine-jdk-11.0.22_linux-x64_bin.tar.gz'
],
[
'11',
'linux',
'aarch64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.22/sapmachine-jdk-11.0.22_linux-aarch64_bin.tar.gz'
],
[
'11',
'windows',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.22/sapmachine-jdk-11.0.22_windows-x64_bin.zip'
],
[
'11.0.17',
'linux',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.17/sapmachine-jdk-11.0.17_linux-x64_bin.tar.gz'
],
[
'17',
'linux',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-x64_bin.tar.gz'
],
[
'17',
'linux',
'aarch64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-aarch64_bin.tar.gz'
],
[
'17',
'windows',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_windows-x64_bin.zip'
],
[
'17.0.4',
'linux',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.4.1/sapmachine-jdk-17.0.4.1_linux-x64_bin.tar.gz'
],
[
'17',
'linux',
'x64',
'jre',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jre-17.0.10_linux-x64_bin.tar.gz'
],
[
'17',
'linux',
'aarch64',
'jre',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jre-17.0.10_linux-aarch64_bin.tar.gz'
],
[
'17',
'windows',
'x64',
'jre',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jre-17.0.10_windows-x64_bin.zip'
],
[
'17.0.4',
'linux',
'x64',
'jre',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.4.1/sapmachine-jre-17.0.4.1_linux-x64_bin.tar.gz'
],
[
'23-ea',
'linux',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-23%2B15/sapmachine-jdk-23-ea.15_linux-x64_bin.tar.gz',
'23'
],
[
'21.0.2+2-ea',
'linux',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.2%2B2/sapmachine-jdk-21.0.2-ea.2_linux-x64_bin.tar.gz',
'21.0.2+2'
],
[
'17',
'linux-musl',
'x64',
'jdk',
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-x64-musl_bin.tar.gz'
]
])(
'should return proper link according to the specified java-version, platform and arch',
async (
version: string,
platform: string,
arch: string,
packageType: string,
expectedLink: string,
normalizedVersion: string = version
) => {
const distribution = new SapMachineDistribution({
version: version,
architecture: arch,
packageType: packageType,
checkLatest: false
});
mockPlatform(distribution, platform);
const availableVersion = await distribution['findPackageForDownload'](
normalizedVersion
);
expect(availableVersion).not.toBeNull();
expect(availableVersion.url).toBe(expectedLink);
}
);
it.each([
['8', 'linux', 'x64'],
['8', 'macos', 'aarch64'],
['23', 'macos', 'aarch64'],
['17', 'linux', 'riscv'],
['23', 'linux', 'x64'],
['25-ea', 'linux', 'x64', '25'],
['8-ea', 'linux', 'x64', '8'],
['21.0.3+7', 'linux', 'x64', '21.0.3+7'],
['21.0.3+8-ea', 'linux', 'x64', '21.0.3+8'],
['17', 'linux-muse', 'aarch64']
])(
'should throw when required version of JDK can not be found in the JSON',
async (
version: string,
platform: string,
arch: string,
normalizedVersion: string = version
) => {
const distribution = new SapMachineDistribution({
version: version,
architecture: arch,
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, platform);
await expect(
distribution['findPackageForDownload'](normalizedVersion)
).rejects.toThrow(
`Couldn't find any satisfied version for the specified java-version: "${normalizedVersion}" and architecture: "${arch}".`
);
}
);
it('should throw when required package type is not supported', async () => {
const jdkVersion = '17';
const arch = 'x64';
const platform = 'linux';
const distribution = new SapMachineDistribution({
version: jdkVersion,
architecture: arch,
packageType: 'jdk+fx',
checkLatest: false
});
mockPlatform(distribution, platform);
await expect(
distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow(
'SapMachine provides only the `jdk` and `jre` package type'
);
});
});
});

404
dist/setup/index.js vendored
View File

@ -124049,6 +124049,8 @@ const installer_7 = __nccwpck_require__(41121);
const installer_8 = __nccwpck_require__(34750);
const installer_9 = __nccwpck_require__(64298);
const installer_10 = __nccwpck_require__(16132);
const installer_11 = __nccwpck_require__(52869);
const installer_12 = __nccwpck_require__(12634);
var JavaDistribution;
(function (JavaDistribution) {
JavaDistribution["Adopt"] = "adopt";
@ -124063,6 +124065,8 @@ var JavaDistribution;
JavaDistribution["Corretto"] = "corretto";
JavaDistribution["Oracle"] = "oracle";
JavaDistribution["Dragonwell"] = "dragonwell";
JavaDistribution["SapMachine"] = "sapmachine";
JavaDistribution["JetBrains"] = "jetbrains";
})(JavaDistribution || (JavaDistribution = {}));
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
switch (distributionName) {
@ -124089,6 +124093,10 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
return new installer_9.OracleDistribution(installerOptions);
case JavaDistribution.Dragonwell:
return new installer_10.DragonwellDistribution(installerOptions);
case JavaDistribution.SapMachine:
return new installer_11.SapMachineDistribution(installerOptions);
case JavaDistribution.JetBrains:
return new installer_12.JetBrainsDistribution(installerOptions);
default:
return null;
}
@ -124306,6 +124314,189 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
exports.DragonwellDistribution = DragonwellDistribution;
/***/ }),
/***/ 12634:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JetBrainsDistribution = void 0;
const core = __importStar(__nccwpck_require__(42186));
const tc = __importStar(__nccwpck_require__(27784));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const path_1 = __importDefault(__nccwpck_require__(71017));
const semver_1 = __importDefault(__nccwpck_require__(11383));
const base_installer_1 = __nccwpck_require__(59741);
const util_1 = __nccwpck_require__(92629);
class JetBrainsDistribution extends base_installer_1.JavaBase {
constructor(installerOptions) {
super('JetBrains', installerOptions);
}
findPackageForDownload(range) {
return __awaiter(this, void 0, void 0, function* () {
const versionsRaw = yield this.getAvailableVersions();
const versions = versionsRaw.map(v => {
const formattedVersion = `${v.semver}+${v.build}`;
return {
version: formattedVersion,
url: v.url
};
});
const satisfiedVersions = versions
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
.sort((a, b) => {
return -semver_1.default.compareBuild(a.version, b.version);
});
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
if (!resolvedFullVersion) {
const availableOptions = versionsRaw.map(item => item.tag_name).join(', ');
const availableOptionsMessage = availableOptions
? `\nAvailable versions: ${availableOptions}`
: '';
throw new Error(`Could not find satisfied version for SemVer '${range}'. ${availableOptionsMessage}`);
}
return resolvedFullVersion;
});
}
downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`);
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, "tar.gz");
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version);
const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
return { version: javaRelease.version, path: javaPath };
});
}
getAvailableVersions() {
return __awaiter(this, void 0, void 0, function* () {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
if (core.isDebug()) {
console.time('Retrieving available versions for JBR took'); // eslint-disable-line no-console
}
// need to iterate through all pages to retrieve the list of all versions
// GitHub API doesn't provide way to retrieve the count of pages to iterate so infinity loop
let page_index = 1;
const rawVersions = [];
while (true) {
const requestArguments = `per_page=100&page=${page_index}`;
const requestHeaders = {};
if (process.env.GITHUB_TOKEN) {
requestHeaders['Authorization'] = `Bearer ${process.env.GITHUB_TOKEN}`;
}
const rawUrl = `https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases?${requestArguments}`;
if (core.isDebug() && page_index === 1) {
// url is identical except page_index so print it once for debug
core.debug(`Gathering available versions from '${rawUrl}'`);
}
const paginationPage = (yield this.http.getJson(rawUrl, requestHeaders)).result;
if (!paginationPage || paginationPage.length === 0) {
// break infinity loop because we have reached end of pagination
break;
}
rawVersions.push(...paginationPage);
page_index++;
}
const versions = rawVersions.map(v => {
var _a;
// Release tags look like one of these:
// jbr-release-21.0.3b465.3
// jb11_0_11-b87.7
// jbr11_0_15b2043.56
const tag = v.tag_name;
// Extract version string
let vstring;
switch ((_a = tag.match(/-/g)) === null || _a === void 0 ? void 0 : _a.length) {
case 2:
vstring = tag.substring(tag.lastIndexOf('-') + 1);
break;
case 1:
vstring = tag.substring(2).replace(/-/g, '').replace(/_/g, '.');
break;
case undefined: // 0
vstring = tag.substring(3);
break;
default:
throw new Error(`Unrecognized tag_name: ${tag}`);
}
const vsplit = vstring.split('b');
const semver = vsplit[0].replace(/_/g, '.');
const build = +vsplit[1];
// Construct URL
const url = `https://cache-redirector.jetbrains.com/intellij-jbr/jbrsdk_jcef-${semver}-${platform}-${arch}-b${build}.tar.gz`;
return {
tag_name: tag,
semver: semver,
build: build,
url: url
};
});
if (core.isDebug()) {
core.startGroup('Print information about available versions');
console.timeEnd('Retrieving available versions for JBR took'); // eslint-disable-line no-console
core.debug(`Available versions: [${versions.length}]`);
core.debug(versions.map(item => item.tag_name).join(', '));
core.endGroup();
}
return versions;
});
}
getPlatformOption() {
// Jetbrains has own platform names so need to map them
switch (process.platform) {
case 'darwin':
return 'osx';
case 'win32':
return 'windows';
default:
return process.platform;
}
}
}
exports.JetBrainsDistribution = JetBrainsDistribution;
/***/ }),
/***/ 40883:
@ -124874,6 +125065,219 @@ class OracleDistribution extends base_installer_1.JavaBase {
exports.OracleDistribution = OracleDistribution;
/***/ }),
/***/ 52869:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SapMachineDistribution = void 0;
const core = __importStar(__nccwpck_require__(42186));
const tc = __importStar(__nccwpck_require__(27784));
const semver_1 = __importDefault(__nccwpck_require__(11383));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const path_1 = __importDefault(__nccwpck_require__(71017));
const util_1 = __nccwpck_require__(92629);
const base_installer_1 = __nccwpck_require__(59741);
class SapMachineDistribution extends base_installer_1.JavaBase {
constructor(installerOptions) {
super('SapMachine', installerOptions);
}
findPackageForDownload(version) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`Only stable versions: ${this.stable}`);
if (!['jdk', 'jre'].includes(this.packageType)) {
throw new Error('SapMachine provides only the `jdk` and `jre` package type');
}
const availableVersions = yield this.getAvailableVersions();
const matchedVersions = availableVersions
.filter(item => {
return (0, util_1.isVersionSatisfies)(version, item.version);
})
.map(item => {
return {
version: item.version,
url: item.downloadLink
};
});
if (!matchedVersions.length) {
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`);
}
const resolvedVersion = matchedVersions[0];
return resolvedVersion;
});
}
getAvailableVersions() {
return __awaiter(this, void 0, void 0, function* () {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
let fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json');
if (!fetchedReleasesJson) {
fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages', (0, util_1.getGitHubHttpHeaders)());
}
if (!fetchedReleasesJson) {
throw new Error(`Couldn't fetch SapMachine versions information from both primary and backup urls`);
}
core.debug('Successfully fetched information about available SapMachine versions');
const availableVersions = this.parseVersions(platform, arch, fetchedReleasesJson);
if (core.isDebug()) {
core.startGroup('Print information about available versions');
core.debug(availableVersions.map(item => item.version).join(', '));
core.endGroup();
}
return availableVersions;
});
}
downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`);
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)());
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version);
const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
return { version: javaRelease.version, path: javaPath };
});
}
parseVersions(platform, arch, versions) {
const eligibleVersions = [];
for (const [, majorVersionMap] of Object.entries(versions)) {
for (const [, jdkVersionMap] of Object.entries(majorVersionMap.updates)) {
for (const [buildVersion, buildVersionMap] of Object.entries(jdkVersionMap)) {
let buildVersionWithoutPrefix = buildVersion.replace('sapmachine-', '');
if (!buildVersionWithoutPrefix.includes('.')) {
// replace major version with major.minor.patch and keep the remaining build identifier after the + as is with regex
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace(/(\d+)(\+.*)?/, '$1.0.0$2');
}
// replace + with . to convert to semver format if we have more than 3 version digits
if (buildVersionWithoutPrefix.split('.').length > 3) {
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace('+', '.');
}
buildVersionWithoutPrefix = (0, util_1.convertVersionToSemver)(buildVersionWithoutPrefix);
// ignore invalid version
if (!semver_1.default.valid(buildVersionWithoutPrefix)) {
core.debug(`Invalid version: ${buildVersionWithoutPrefix}`);
continue;
}
// skip earlyAccessVersions if stable version requested
if (this.stable && buildVersionMap.ea === 'true') {
continue;
}
for (const [edition, editionAssets] of Object.entries(buildVersionMap.assets)) {
if (this.packageType !== edition) {
continue;
}
for (const [archAndPlatForm, archAssets] of Object.entries(editionAssets)) {
let expectedArchAndPlatform = `${platform}-${arch}`;
if (platform === 'linux-musl') {
expectedArchAndPlatform = `linux-${arch}-musl`;
}
if (archAndPlatForm !== expectedArchAndPlatform) {
continue;
}
for (const [contentType, contentTypeAssets] of Object.entries(archAssets)) {
// skip if not tar.gz and zip files
if (contentType !== 'tar.gz' && contentType !== 'zip') {
continue;
}
eligibleVersions.push({
os: platform,
architecture: arch,
version: buildVersionWithoutPrefix,
checksum: contentTypeAssets.checksum,
downloadLink: contentTypeAssets.url,
packageType: edition
});
}
}
}
}
}
}
const sortedVersions = this.sortParsedVersions(eligibleVersions);
return sortedVersions;
}
// Sorts versions in descending order as by default data in JSON isn't sorted
sortParsedVersions(eligibleVersions) {
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
const version1 = versionObj1.version;
const version2 = versionObj2.version;
return semver_1.default.compareBuild(version1, version2);
});
return sortedVersions.reverse();
}
getPlatformOption() {
switch (process.platform) {
case 'win32':
return 'windows';
case 'darwin':
return 'macos';
case 'linux':
// figure out if alpine/musl
if (fs_1.default.existsSync('/etc/alpine-release')) {
return 'linux-musl';
}
return 'linux';
default:
return process.platform;
}
}
fetchReleasesFromUrl(url, headers = {}) {
return __awaiter(this, void 0, void 0, function* () {
try {
core.debug(`Trying to fetch available SapMachine versions info from the primary url: ${url}`);
const releases = (yield this.http.getJson(url, headers)).result;
return releases;
}
catch (err) {
core.debug(`Fetching SapMachine versions info from the link: ${url} ended up with the error: ${err.message}`);
return null;
}
});
}
}
exports.SapMachineDistribution = SapMachineDistribution;
/***/ }),
/***/ 41121:

View File

@ -8,6 +8,8 @@
- [Amazon Corretto](#Amazon-Corretto)
- [Oracle](#Oracle)
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
- [SapMachine](#SapMachine)
- [JetBrains](#JetBrains)
- [Installing custom Java package type](#Installing-custom-Java-package-type)
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
@ -142,6 +144,46 @@ steps:
- run: java -cp java HelloWorldApp
```
### SapMachine
**NOTE:** An OpenJDK release maintained and supported by SAP
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'sapmachine'
java-version: '21'
- run: java -cp java HelloWorldApp
```
### JetBrains
**NOTE:** JetBrains only provides jdk and is only available for LTS versions 11 or later.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'jetbrains'
java-version: '11'
- run: java -cp java HelloWorldApp
```
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
GitHub token to the action to increase the rate limit. Set the `GITHUB_TOKEN` environment variable to the value of your GitHub token in the workflow file.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'jetbrains'
java-version: '11'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: java -cp java HelloWorldApp
```
## Installing custom Java package type
```yaml
steps:
@ -154,7 +196,6 @@ steps:
- run: java -cp java HelloWorldApp
```
## Installing custom Java architecture
```yaml

View File

@ -10,6 +10,8 @@ import {SemeruDistribution} from './semeru/installer';
import {CorrettoDistribution} from './corretto/installer';
import {OracleDistribution} from './oracle/installer';
import {DragonwellDistribution} from './dragonwell/installer';
import {SapMachineDistribution} from './sapmachine/installer';
import {JetBrainsDistribution} from "./jetbrains/installer";
enum JavaDistribution {
Adopt = 'adopt',
@ -23,7 +25,9 @@ enum JavaDistribution {
Semeru = 'semeru',
Corretto = 'corretto',
Oracle = 'oracle',
Dragonwell = 'dragonwell'
Dragonwell = 'dragonwell',
SapMachine = 'sapmachine',
JetBrains = 'jetbrains'
}
export function getJavaDistribution(
@ -64,6 +68,10 @@ export function getJavaDistribution(
return new OracleDistribution(installerOptions);
case JavaDistribution.Dragonwell:
return new DragonwellDistribution(installerOptions);
case JavaDistribution.SapMachine:
return new SapMachineDistribution(installerOptions);
case JavaDistribution.JetBrains:
return new JetBrainsDistribution(installerOptions);
default:
return null;
}

View File

@ -0,0 +1,191 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import fs from 'fs';
import path from 'path';
import semver from 'semver';
import {JavaBase} from '../base-installer';
import {IJetBrainsRawVersion, IJetBrainsVersion} from './models';
import {
JavaDownloadRelease,
JavaInstallerOptions,
JavaInstallerResults
} from '../base-models';
import {
extractJdkFile,
isVersionSatisfies
} from '../../util';
import {IncomingHttpHeaders, OutgoingHttpHeaders} from "http";
export class JetBrainsDistribution extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) {
super('JetBrains', installerOptions);
}
protected async findPackageForDownload(
range: string
): Promise<JavaDownloadRelease> {
const versionsRaw = await this.getAvailableVersions();
const versions = versionsRaw.map(v => {
const formattedVersion = `${v.semver}+${v.build}`;
return {
version: formattedVersion,
url: v.url
} as JavaDownloadRelease;
});
const satisfiedVersions = versions
.filter(item => isVersionSatisfies(range, item.version))
.sort((a, b) => {
return -semver.compareBuild(a.version, b.version);
});
const resolvedFullVersion =
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
if (!resolvedFullVersion) {
const availableOptions = versionsRaw.map(item => item.tag_name).join(', ');
const availableOptionsMessage = availableOptions
? `\nAvailable versions: ${availableOptions}`
: '';
throw new Error(
`Could not find satisfied version for SemVer '${range}'. ${availableOptionsMessage}`
);
}
return resolvedFullVersion;
}
protected async downloadTool(
javaRelease: JavaDownloadRelease
): Promise<JavaInstallerResults> {
core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
);
const javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`);
const extractedJavaPath = await extractJdkFile(javaArchivePath, "tar.gz");
const archiveName = fs.readdirSync(extractedJavaPath)[0];
const archivePath = path.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version);
const javaPath = await tc.cacheDir(
archivePath,
this.toolcacheFolderName,
version,
this.architecture
);
return {version: javaRelease.version, path: javaPath};
}
private async getAvailableVersions(): Promise<IJetBrainsVersion[]> {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
if (core.isDebug()) {
console.time('Retrieving available versions for JBR took'); // eslint-disable-line no-console
}
// need to iterate through all pages to retrieve the list of all versions
// GitHub API doesn't provide way to retrieve the count of pages to iterate so infinity loop
let page_index = 1;
const rawVersions: IJetBrainsRawVersion[] = [];
while (true) {
const requestArguments = `per_page=100&page=${page_index}`;
const requestHeaders: OutgoingHttpHeaders = {}
if (process.env.GITHUB_TOKEN) {
requestHeaders['Authorization'] = `Bearer ${process.env.GITHUB_TOKEN}`;
}
const rawUrl = `https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases?${requestArguments}`;
if (core.isDebug() && page_index === 1) {
// url is identical except page_index so print it once for debug
core.debug(
`Gathering available versions from '${rawUrl}'`
);
}
const paginationPage = (
await this.http.getJson<IJetBrainsRawVersion[]>(
rawUrl, requestHeaders
)
).result;
if (!paginationPage || paginationPage.length === 0) {
// break infinity loop because we have reached end of pagination
break;
}
rawVersions.push(...paginationPage);
page_index++;
}
const versions = rawVersions.map(v => {
// Release tags look like one of these:
// jbr-release-21.0.3b465.3
// jb11_0_11-b87.7
// jbr11_0_15b2043.56
const tag = v.tag_name;
// Extract version string
let vstring;
switch (tag.match(/-/g)?.length) {
case 2:
vstring = tag.substring(tag.lastIndexOf('-') + 1);
break;
case 1:
vstring = tag.substring(2).replace(/-/g, '').replace(/_/g, '.');
break;
case undefined: // 0
vstring = tag.substring(3)
break;
default:
throw new Error(`Unrecognized tag_name: ${tag}`)
}
const vsplit = vstring.split('b');
const semver = vsplit[0].replace(/_/g, '.');
const build = +vsplit[1];
// Construct URL
const url = `https://cache-redirector.jetbrains.com/intellij-jbr/jbrsdk_jcef-${semver}-${platform}-${arch}-b${build}.tar.gz`;
return {
tag_name: tag,
semver: semver,
build: build,
url: url
} as IJetBrainsVersion;
});
if (core.isDebug()) {
core.startGroup('Print information about available versions');
console.timeEnd('Retrieving available versions for JBR took'); // eslint-disable-line no-console
core.debug(`Available versions: [${versions.length}]`);
core.debug(versions.map(item => item.tag_name).join(', '));
core.endGroup();
}
return versions;
}
private getPlatformOption(): string {
// Jetbrains has own platform names so need to map them
switch (process.platform) {
case 'darwin':
return 'osx';
case 'win32':
return 'windows';
default:
return process.platform;
}
}
}

View File

@ -0,0 +1,13 @@
// Raw Model from https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases
export interface IJetBrainsRawVersion {
tag_name: string;
name: string;
}
export interface IJetBrainsVersion {
tag_name: string;
semver: string;
build: number;
url: string;
}

View File

@ -0,0 +1,268 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import semver from 'semver';
import fs from 'fs';
import {OutgoingHttpHeaders} from 'http';
import path from 'path';
import {
convertVersionToSemver,
extractJdkFile,
getDownloadArchiveExtension,
getGitHubHttpHeaders,
isVersionSatisfies
} from '../../util';
import {JavaBase} from '../base-installer';
import {
JavaDownloadRelease,
JavaInstallerOptions,
JavaInstallerResults
} from '../base-models';
import {ISapMachineAllVersions, ISapMachineVersions} from './models';
export class SapMachineDistribution extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) {
super('SapMachine', installerOptions);
}
protected async findPackageForDownload(
version: string
): Promise<JavaDownloadRelease> {
core.debug(`Only stable versions: ${this.stable}`);
if (!['jdk', 'jre'].includes(this.packageType)) {
throw new Error(
'SapMachine provides only the `jdk` and `jre` package type'
);
}
const availableVersions = await this.getAvailableVersions();
const matchedVersions = availableVersions
.filter(item => {
return isVersionSatisfies(version, item.version);
})
.map(item => {
return {
version: item.version,
url: item.downloadLink
} as JavaDownloadRelease;
});
if (!matchedVersions.length) {
throw new Error(
`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`
);
}
const resolvedVersion = matchedVersions[0];
return resolvedVersion;
}
private async getAvailableVersions(): Promise<ISapMachineVersions[]> {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
let fetchedReleasesJson = await this.fetchReleasesFromUrl(
'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json'
);
if (!fetchedReleasesJson) {
fetchedReleasesJson = await this.fetchReleasesFromUrl(
'https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages',
getGitHubHttpHeaders()
);
}
if (!fetchedReleasesJson) {
throw new Error(
`Couldn't fetch SapMachine versions information from both primary and backup urls`
);
}
core.debug(
'Successfully fetched information about available SapMachine versions'
);
const availableVersions = this.parseVersions(
platform,
arch,
fetchedReleasesJson
);
if (core.isDebug()) {
core.startGroup('Print information about available versions');
core.debug(availableVersions.map(item => item.version).join(', '));
core.endGroup();
}
return availableVersions;
}
protected async downloadTool(
javaRelease: JavaDownloadRelease
): Promise<JavaInstallerResults> {
core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
);
const javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`);
const extractedJavaPath = await extractJdkFile(
javaArchivePath,
getDownloadArchiveExtension()
);
const archiveName = fs.readdirSync(extractedJavaPath)[0];
const archivePath = path.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version);
const javaPath = await tc.cacheDir(
archivePath,
this.toolcacheFolderName,
version,
this.architecture
);
return {version: javaRelease.version, path: javaPath};
}
private parseVersions(
platform: string,
arch: string,
versions: ISapMachineAllVersions
): ISapMachineVersions[] {
const eligibleVersions: ISapMachineVersions[] = [];
for (const [, majorVersionMap] of Object.entries(versions)) {
for (const [, jdkVersionMap] of Object.entries(majorVersionMap.updates)) {
for (const [buildVersion, buildVersionMap] of Object.entries(
jdkVersionMap
)) {
let buildVersionWithoutPrefix = buildVersion.replace(
'sapmachine-',
''
);
if (!buildVersionWithoutPrefix.includes('.')) {
// replace major version with major.minor.patch and keep the remaining build identifier after the + as is with regex
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace(
/(\d+)(\+.*)?/,
'$1.0.0$2'
);
}
// replace + with . to convert to semver format if we have more than 3 version digits
if (buildVersionWithoutPrefix.split('.').length > 3) {
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace(
'+',
'.'
);
}
buildVersionWithoutPrefix = convertVersionToSemver(
buildVersionWithoutPrefix
);
// ignore invalid version
if (!semver.valid(buildVersionWithoutPrefix)) {
core.debug(`Invalid version: ${buildVersionWithoutPrefix}`);
continue;
}
// skip earlyAccessVersions if stable version requested
if (this.stable && buildVersionMap.ea === 'true') {
continue;
}
for (const [edition, editionAssets] of Object.entries(
buildVersionMap.assets
)) {
if (this.packageType !== edition) {
continue;
}
for (const [archAndPlatForm, archAssets] of Object.entries(
editionAssets
)) {
let expectedArchAndPlatform = `${platform}-${arch}`;
if (platform === 'linux-musl') {
expectedArchAndPlatform = `linux-${arch}-musl`;
}
if (archAndPlatForm !== expectedArchAndPlatform) {
continue;
}
for (const [contentType, contentTypeAssets] of Object.entries(
archAssets
)) {
// skip if not tar.gz and zip files
if (contentType !== 'tar.gz' && contentType !== 'zip') {
continue;
}
eligibleVersions.push({
os: platform,
architecture: arch,
version: buildVersionWithoutPrefix,
checksum: contentTypeAssets.checksum,
downloadLink: contentTypeAssets.url,
packageType: edition
});
}
}
}
}
}
}
const sortedVersions = this.sortParsedVersions(eligibleVersions);
return sortedVersions;
}
// Sorts versions in descending order as by default data in JSON isn't sorted
private sortParsedVersions(
eligibleVersions: ISapMachineVersions[]
): ISapMachineVersions[] {
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
const version1 = versionObj1.version;
const version2 = versionObj2.version;
return semver.compareBuild(version1, version2);
});
return sortedVersions.reverse();
}
private getPlatformOption(): string {
switch (process.platform) {
case 'win32':
return 'windows';
case 'darwin':
return 'macos';
case 'linux':
// figure out if alpine/musl
if (fs.existsSync('/etc/alpine-release')) {
return 'linux-musl';
}
return 'linux';
default:
return process.platform;
}
}
private async fetchReleasesFromUrl(
url: string,
headers: OutgoingHttpHeaders = {}
): Promise<ISapMachineAllVersions | null> {
try {
core.debug(
`Trying to fetch available SapMachine versions info from the primary url: ${url}`
);
const releases = (
await this.http.getJson<ISapMachineAllVersions>(url, headers)
).result;
return releases;
} catch (err) {
core.debug(
`Fetching SapMachine versions info from the link: ${url} ended up with the error: ${
(err as Error).message
}`
);
return null;
}
}
}

View File

@ -0,0 +1,33 @@
export interface ISapMachineAllVersions {
[major: string]: {
lts: string;
updates: {
[full_version: string]: {
[sapmachineBuild: string]: {
release_url: string;
ea: string;
assets: {
[packageType: string]: {
[arch: string]: {
[content_type: string]: {
name: string;
checksum: string;
url: string;
};
};
};
};
};
};
};
};
}
export interface ISapMachineVersions {
os: string;
architecture: string;
version: string;
checksum: string;
downloadLink: string;
packageType: string;
}