| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c3ac5dd commit 1df8dbe
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -240,4 +240,99 @@ jobs: | |||
| 240 | 240 | run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" | |
| 241 | 241 | shell: bash | |
| 242 | 242 | ||
| 243 | - # Only Microsoft provides AArch64. However, GitHub-hosted runners do not support this architecture. | ||
| 243 | + setup-java-version-both-version-inputs-presents: | ||
| 244 | + name: ${{ matrix.distribution }} version (should be from input) - ${{ matrix.os }} | ||
| 245 | + runs-on: ${{ matrix.os }} | ||
| 246 | + strategy: | ||
| 247 | + fail-fast: false | ||
| 248 | + matrix: | ||
| 249 | + os: [macos-latest, windows-latest, ubuntu-latest] | ||
| 250 | + distribution: ['temurin', 'microsoft', 'corretto' ] | ||
| 251 | + steps: | ||
| 252 | + - name: Checkout | ||
| 253 | + uses: actions/checkout@v3 | ||
| 254 | + - name: Create .java-version file | ||
| 255 | + shell: bash | ||
| 256 | + run: echo "8" > .java-version | ||
| 257 | + - name: setup-java | ||
| 258 | + uses: ./ | ||
| 259 | + id: setup-java | ||
| 260 | + with: | ||
| 261 | + distribution: ${{ matrix.distribution }} | ||
| 262 | + java-version: 11 | ||
| 263 | + java-version-file: '.java-version' | ||
| 264 | + - name: Verify Java | ||
| 265 | + run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" | ||
| 266 | + shell: bash | ||
| 267 | + | ||
| 268 | + setup-java-version-from-file-major-notation: | ||
| 269 | + name: ${{ matrix.distribution }} version from file X - ${{ matrix.os }} | ||
| 270 | + runs-on: ${{ matrix.os }} | ||
| 271 | + strategy: | ||
| 272 | + fail-fast: false | ||
| 273 | + matrix: | ||
| 274 | + os: [macos-latest, windows-latest, ubuntu-latest] | ||
| 275 | + distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto' ] | ||
| 276 | + steps: | ||
| 277 | + - name: Checkout | ||
| 278 | + uses: actions/checkout@v3 | ||
| 279 | + - name: Create .java-version file | ||
| 280 | + shell: bash | ||
| 281 | + run: echo "11" > .java-version | ||
| 282 | + - name: setup-java | ||
| 283 | + uses: ./ | ||
| 284 | + id: setup-java | ||
| 285 | + with: | ||
| 286 | + distribution: ${{ matrix.distribution }} | ||
| 287 | + java-version-file: '.java-version' | ||
| 288 | + - name: Verify Java | ||
| 289 | + run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" | ||
| 290 | + shell: bash | ||
| 291 | + | ||
| 292 | + setup-java-version-from-file-major-minor-patch-notation: | ||
| 293 | + name: ${{ matrix.distribution }} version from file X.Y.Z - ${{ matrix.os }} | ||
| 294 | + runs-on: ${{ matrix.os }} | ||
| 295 | + strategy: | ||
| 296 | + fail-fast: false | ||
| 297 | + matrix: | ||
| 298 | + os: [macos-latest, windows-latest, ubuntu-latest] | ||
| 299 | + distribution: [ 'adopt', 'adopt-openj9', 'zulu' ] | ||
| 300 | + steps: | ||
| 301 | + - name: Checkout | ||
| 302 | + uses: actions/checkout@v3 | ||
| 303 | + - name: Create .java-version file | ||
| 304 | + shell: bash | ||
| 305 | + run: echo "11.0.2" > .java-version | ||
| 306 | + - name: setup-java | ||
| 307 | + uses: ./ | ||
| 308 | + id: setup-java | ||
| 309 | + with: | ||
| 310 | + distribution: ${{ matrix.distribution }} | ||
| 311 | + java-version-file: '.java-version' | ||
| 312 | + - name: Verify Java | ||
| 313 | + run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" | ||
| 314 | + shell: bash | ||
| 315 | + | ||
| 316 | + setup-java-version-from-file-major-minor-patch-with-dist: | ||
| 317 | + name: ${{ matrix.distribution }} version from file 'openjdk64-11.0.2' - ${{ matrix.os }} | ||
| 318 | + runs-on: ${{ matrix.os }} | ||
| 319 | + strategy: | ||
| 320 | + fail-fast: false | ||
| 321 | + matrix: | ||
| 322 | + os: [macos-latest, windows-latest, ubuntu-latest] | ||
| 323 | + distribution: ['adopt', 'zulu', 'liberica' ] | ||
| 324 | + steps: | ||
| 325 | + - name: Checkout | ||
| 326 | + uses: actions/checkout@v3 | ||
| 327 | + - name: Create .java-version file | ||
| 328 | + shell: bash | ||
| 329 | + run: echo "openjdk64-11.0.2" > .java-version | ||
| 330 | + - name: setup-java | ||
| 331 | + uses: ./ | ||
| 332 | + id: setup-java | ||
| 333 | + with: | ||
| 334 | + distribution: ${{ matrix.distribution }} | ||
| 335 | + java-version-file: '.java-version' | ||
| 336 | + - name: Verify Java | ||
| 337 | + run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" | ||
| 338 | + shell: bash | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,9 @@ This action allows you to work with Java and Scala projects. | |||
| 23 | 23 | ||
| 24 | 24 | ## Usage | |
| 25 | 25 | ||
| 26 | - - `java-version`: _(required)_ The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. | ||
| 26 | + - `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. | ||
| 27 | + | ||
| 28 | + - `java-version-file`: The path to the `.java-version` file. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). | ||
| 27 | 29 | ||
| 28 | 30 | - `distribution`: _(required)_ Java [distribution](#supported-distributions). | |
| 29 | 31 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,8 @@ author: 'GitHub' | |||
| 5 | 5 | inputs: | |
| 6 | 6 | java-version: | |
| 7 | 7 | description: 'The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file' | |
| 8 | - required: true | ||
| 8 | + java-version-file: | ||
| 9 | + description: 'The path to the `.java-version` file. See examples of supported syntax in README file' | ||
| 9 | 10 | distribution: | |
| 10 | 11 | description: 'Java distribution. See the list of supported distributions in README file' | |
| 11 | 12 | required: true | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68480,9 +68480,10 @@ else { | |||
| 68480 | 68480 | "use strict"; | |
| 68481 | 68481 | ||
| 68482 | 68482 | Object.defineProperty(exports, "__esModule", ({ value: true })); | |
| 68483 | - exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; | ||
| 68483 | + exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; | ||
| 68484 | 68484 | exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; | |
| 68485 | 68485 | exports.INPUT_JAVA_VERSION = 'java-version'; | |
| 68486 | + exports.INPUT_JAVA_VERSION_FILE = 'java-version-file'; | ||
| 68486 | 68487 | exports.INPUT_ARCHITECTURE = 'architecture'; | |
| 68487 | 68488 | exports.INPUT_JAVA_PACKAGE = 'java-package'; | |
| 68488 | 68489 | exports.INPUT_DISTRIBUTION = 'distribution'; | |
@@ -68505,6 +68506,7 @@ exports.MVN_SETTINGS_FILE = 'settings.xml'; | |||
| 68505 | 68506 | exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; | |
| 68506 | 68507 | exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; | |
| 68507 | 68508 | exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; | |
| 68509 | + exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; | ||
| 68508 | 68510 | ||
| 68509 | 68511 | ||
| 68510 | 68512 | /***/ }), | |
@@ -68622,7 +68624,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | |||
| 68622 | 68624 | return (mod && mod.__esModule) ? mod : { "default": mod }; | |
| 68623 | 68625 | }; | |
| 68624 | 68626 | Object.defineProperty(exports, "__esModule", ({ value: true })); | |
| 68625 | - exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; | ||
| 68627 | + exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; | ||
| 68626 | 68628 | const os_1 = __importDefault(__nccwpck_require__(2037)); | |
| 68627 | 68629 | const path_1 = __importDefault(__nccwpck_require__(1017)); | |
| 68628 | 68630 | const fs = __importStar(__nccwpck_require__(7147)); | |
@@ -68718,6 +68720,34 @@ function isCacheFeatureAvailable() { | |||
| 68718 | 68720 | return true; | |
| 68719 | 68721 | } | |
| 68720 | 68722 | exports.isCacheFeatureAvailable = isCacheFeatureAvailable; | |
| 68723 | + function getVersionFromFileContent(content, distributionName) { | ||
| 68724 | + var _a, _b, _c, _d, _e; | ||
| 68725 | + const javaVersionRegExp = /(?<version>(?<=(^|\s|\-))(\d+\S*))(\s|$)/; | ||
| 68726 | + const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) | ||
| 68727 | + ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version | ||
| 68728 | + : ''; | ||
| 68729 | + if (!fileContent) { | ||
| 68730 | + return null; | ||
| 68731 | + } | ||
| 68732 | + core.debug(`Version from file '${fileContent}'`); | ||
| 68733 | + const tentativeVersion = avoidOldNotation(fileContent); | ||
| 68734 | + const rawVersion = tentativeVersion.split('-')[0]; | ||
| 68735 | + let version = semver.validRange(rawVersion) ? tentativeVersion : semver.coerce(tentativeVersion); | ||
| 68736 | + core.debug(`Range version from file is '${version}'`); | ||
| 68737 | + if (!version) { | ||
| 68738 | + return null; | ||
| 68739 | + } | ||
| 68740 | + if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { | ||
| 68741 | + const coerceVersion = (_e = semver.coerce(version)) !== null && _e !== void 0 ? _e : version; | ||
| 68742 | + version = semver.major(coerceVersion).toString(); | ||
| 68743 | + } | ||
| 68744 | + return version.toString(); | ||
| 68745 | + } | ||
| 68746 | + exports.getVersionFromFileContent = getVersionFromFileContent; | ||
| 68747 | + // By convention, action expects version 8 in the format `8.*` instead of `1.8` | ||
| 68748 | + function avoidOldNotation(content) { | ||
| 68749 | + return content.startsWith('1.') ? content.substring(2) : content; | ||
| 68750 | + } | ||
| 68721 | 68751 | ||
| 68722 | 68752 | ||
| 68723 | 68753 | /***/ }), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments