diff --git a/.github/workflows/publish-immutable-actions.yml b/.github/workflows/publish-immutable-actions.yml index 9f6953ee..cb187aea 100644 --- a/.github/workflows/publish-immutable-actions.yml +++ b/.github/workflows/publish-immutable-actions.yml @@ -4,7 +4,6 @@ on: release: types: [released] workflow_dispatch: - jobs: publish: runs-on: ubuntu-latest @@ -18,4 +17,5 @@ jobs: uses: actions/checkout@v4 - name: Publish id: publish + uses: actions/publish-immutable-action@v0.0.4 diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index b8d03ca1..0e413c67 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -93634,7 +93634,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) { const versionFileName = getFileName(versionFile); if (versionFileName == '.tool-versions') { javaVersionRegExp = - /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + /^java\s+(?:\S*-)?(?\d+(?:\.\d+){0,2}(?:[+_]\d+)?)(?=(?:[-_](?!\d))|$)(?:[-_.](?:ea|LTS|beta|snapshot|internal|b\d+|\d+[a-z]*))*$/im; } else { javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; diff --git a/dist/setup/index.js b/dist/setup/index.js index 8bf08ef2..d60b0144 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -131662,7 +131662,7 @@ function getVersionFromFileContent(content, distributionName, versionFile) { const versionFileName = getFileName(versionFile); if (versionFileName == '.tool-versions') { javaVersionRegExp = - /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + /^java\s+(?:\S*-)?(?\d+(?:\.\d+){0,2}(?:[+_]\d+)?)(?=(?:[-_](?!\d))|$)(?:[-_.](?:ea|LTS|beta|snapshot|internal|b\d+|\d+[a-z]*))*$/im; } else { javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 4ba80b03..285703cb 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -614,5 +614,14 @@ major versions: 8, 11, 16, 17, 21 more specific versions: 8.0.282+8, 8.0.232, 11.0, 11.0.4, 17.0 early access (EA) versions: 15-ea, 15.0.0-ea versions with specified distribution: openjdk64-11.0.2 +LTS versions : temurin-21.0.5+11.0.LTS ``` If the file contains multiple versions, only the first one will be recognized. +``` +Note: +In some complex version strings containing multiple version-like segments (e.g., java semeru-openj9-11.0.15+10_openj9-0.32.0), +the regular expression may extract the last version segment (0.32.0) instead of the intended main version (11.0.15+10). +Additionally, the regex is designed to support standard semantic versioning (semver) formats +and may not correctly parse non-standard formats such as jetbrains-21b212.1. +Users are encouraged to provide clear, semver-compliant version specifications to ensure accurate extraction. +``` diff --git a/src/util.ts b/src/util.ts index af75aaac..1d96719d 100644 --- a/src/util.ts +++ b/src/util.ts @@ -133,7 +133,7 @@ export function getVersionFromFileContent( const versionFileName = getFileName(versionFile); if (versionFileName == '.tool-versions') { javaVersionRegExp = - /^(java\s+)(?:\S*-)?v?(?(\d+)(\.\d+)?(\.\d+)?(\+\d+)?(-ea(\.\d+)?)?)$/m; + /^java\s+(?:\S*-)?(?\d+(?:\.\d+){0,2}(?:[+_]\d+)?)(?=(?:[-_](?!\d))|$)(?:[-_.](?:ea|LTS|beta|snapshot|internal|b\d+|\d+[a-z]*))*$/im; } else { javaVersionRegExp = /(?(?<=(^|\s|-))(\d+\S*))(\s|$)/; }