mirror of
https://gh-proxy.com/github.com/actions/setup-java.git
synced 2026-10-04 03:26:03 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb0d854574 |
+13
-16
@@ -1,25 +1,22 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
|
# Enable version updates for npm
|
||||||
- package-ecosystem: 'npm'
|
- package-ecosystem: 'npm'
|
||||||
|
# Look for `package.json` and `lock` files in the `root` directory
|
||||||
directory: '/'
|
directory: '/'
|
||||||
|
# Check the npm registry for updates every day (weekdays)
|
||||||
schedule:
|
schedule:
|
||||||
interval: 'monthly'
|
interval: 'weekly'
|
||||||
cooldown:
|
|
||||||
default-days: 7
|
|
||||||
groups:
|
|
||||||
monthly-npm-updates:
|
|
||||||
applies-to: 'version-updates'
|
|
||||||
patterns:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
|
# Enable version updates for GitHub Actions
|
||||||
- package-ecosystem: 'github-actions'
|
- package-ecosystem: 'github-actions'
|
||||||
|
# Workflow files stored in the default location of `.github/workflows`
|
||||||
|
# You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
|
||||||
directory: '/'
|
directory: '/'
|
||||||
schedule:
|
schedule:
|
||||||
interval: 'monthly'
|
interval: 'weekly'
|
||||||
cooldown:
|
|
||||||
default-days: 7
|
|
||||||
groups:
|
|
||||||
monthly-actions-updates:
|
|
||||||
applies-to: 'version-updates'
|
|
||||||
patterns:
|
|
||||||
- '*'
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ jobs:
|
|||||||
warm-caches:
|
warm-caches:
|
||||||
name: Warm ${{ matrix.tool }} ${{ matrix.profile }} caches (${{ matrix.os }})
|
name: Warm ${{ matrix.tool }} ${{ matrix.profile }} caches (${{ matrix.os }})
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: write-only
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -66,7 +65,6 @@ jobs:
|
|||||||
name: Benchmark ${{ matrix.tool }} ${{ matrix.profile }} (${{ matrix.os }})
|
name: Benchmark ${{ matrix.tool }} ${{ matrix.profile }} (${{ matrix.os }})
|
||||||
needs: warm-caches
|
needs: warm-caches
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ defaults:
|
|||||||
jobs:
|
jobs:
|
||||||
gradle-save:
|
gradle-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: write-only
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -49,7 +48,6 @@ jobs:
|
|||||||
bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
||||||
gradle-restore:
|
gradle-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -74,7 +72,6 @@ jobs:
|
|||||||
run: bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
||||||
maven-save:
|
maven-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: write-only
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -100,7 +97,6 @@ jobs:
|
|||||||
bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
||||||
maven-restore:
|
maven-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -125,7 +121,6 @@ jobs:
|
|||||||
run: bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
run: bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
||||||
sbt-save:
|
sbt-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: write-only
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -165,7 +160,6 @@ jobs:
|
|||||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
sbt-restore:
|
sbt-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -200,7 +194,6 @@ jobs:
|
|||||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
gradle1-save:
|
gradle1-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: write-only
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -229,7 +222,6 @@ jobs:
|
|||||||
bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
||||||
gradle1-restore:
|
gradle1-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -254,7 +246,6 @@ jobs:
|
|||||||
run: bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/wrapper/dists"
|
||||||
gradle2-restore:
|
gradle2-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -277,7 +268,6 @@ jobs:
|
|||||||
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches" absent
|
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches" absent
|
||||||
maven1-save:
|
maven1-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: write-only
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -304,7 +294,6 @@ jobs:
|
|||||||
bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
||||||
maven1-restore:
|
maven1-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -329,7 +318,6 @@ jobs:
|
|||||||
run: bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
run: bash __tests__/check-dir.sh "$HOME/.m2/wrapper/dists"
|
||||||
maven2-restore:
|
maven2-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -354,7 +342,6 @@ jobs:
|
|||||||
run: bash __tests__/check-dir.sh "$HOME/.m2/repository" absent
|
run: bash __tests__/check-dir.sh "$HOME/.m2/repository" absent
|
||||||
sbt1-save:
|
sbt1-save:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: write-only
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -395,7 +382,6 @@ jobs:
|
|||||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
sbt1-restore:
|
sbt1-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -430,7 +416,6 @@ jobs:
|
|||||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||||
sbt2-restore:
|
sbt2-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
cache-mode: read
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -465,7 +450,6 @@ jobs:
|
|||||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier" absent
|
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier" absent
|
||||||
custom-maven-path-save:
|
custom-maven-path-save:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
cache-mode: write-only
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
@@ -490,7 +474,6 @@ jobs:
|
|||||||
bash __tests__/check-dir.sh "$RUNNER_TEMP/setup-java-custom-maven-repository"
|
bash __tests__/check-dir.sh "$RUNNER_TEMP/setup-java-custom-maven-repository"
|
||||||
custom-maven-path-restore:
|
custom-maven-path-restore:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
cache-mode: read
|
|
||||||
needs: custom-maven-path-save
|
needs: custom-maven-path-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ jobs:
|
|||||||
version: 25
|
version: 25
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-15-intel
|
os: macos-15-intel
|
||||||
version: 21
|
version: 17
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
version: 21
|
version: 21
|
||||||
@@ -154,8 +154,8 @@ jobs:
|
|||||||
version: ['21', '17']
|
version: ['21', '17']
|
||||||
steps:
|
steps:
|
||||||
- *checkout_step
|
- *checkout_step
|
||||||
- name: Install bash and GnuPG
|
- name: Install bash
|
||||||
run: apk add --no-cache bash gnupg
|
run: apk add --no-cache bash
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@@ -340,7 +340,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.version }}
|
java-version: ${{ matrix.version }}
|
||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
verify-signature: ${{ matrix.distribution == 'temurin' && contains(matrix.version, '-ea') && 'false' || '' }}
|
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
env:
|
env:
|
||||||
JAVA_VERSION: ${{ matrix.version }}
|
JAVA_VERSION: ${{ matrix.version }}
|
||||||
@@ -637,26 +636,6 @@ jobs:
|
|||||||
run: bash __tests__/verify-java.sh "17.0.10" "$JAVA_PATH"
|
run: bash __tests__/verify-java.sh "17.0.10" "$JAVA_PATH"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-java-version-from-sdkman-major:
|
|
||||||
name: temurin 26 from .sdkmanrc - ubuntu-latest
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- *checkout_step
|
|
||||||
- name: Create SDKMAN and Gradle files
|
|
||||||
run: |
|
|
||||||
echo "java=26-tem" > .sdkmanrc
|
|
||||||
touch build.gradle
|
|
||||||
- name: setup-java
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
java-version-file: .sdkmanrc
|
|
||||||
cache: gradle
|
|
||||||
- name: Verify Java
|
|
||||||
env:
|
|
||||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
|
||||||
run: bash __tests__/verify-java.sh "26" "$JAVA_PATH"
|
|
||||||
|
|
||||||
setup-java-set-default:
|
setup-java-set-default:
|
||||||
name: set-default option - ${{ matrix.os }}
|
name: set-default option - ${{ matrix.os }}
|
||||||
needs: setup-java-major-versions
|
needs: setup-java-major-versions
|
||||||
|
|||||||
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
@@ -9,13 +9,22 @@ Set up Java for GitHub Actions workflows. `setup-java` installs a requested Java
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
- run: java --version
|
- run: java --version
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> V6 is still in development on the `main` branch and is not yet recommended for production workflows. To use it, you must explicitly reference the `main` branch in your workflow, as in
|
||||||
|
>
|
||||||
|
> ```yaml
|
||||||
|
> - uses: actions/setup-java@main
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> For production workflows, it is recommended to use the latest stable release `v5`.
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
- [What it does](#what-it-does)
|
- [What it does](#what-it-does)
|
||||||
@@ -45,20 +54,15 @@ steps:
|
|||||||
|
|
||||||
## What's new
|
## What's new
|
||||||
|
|
||||||
### V6
|
### V6 (in development)
|
||||||
|
|
||||||
- Migrated the action implementation to ESM to support the latest `@actions/*` packages.
|
- Migrated the action implementation to ESM to support the latest `@actions/*` packages.
|
||||||
- Added Oracle OpenJDK (`oracle-openjdk`), Red Hat Build of OpenJDK (`redhat`), and Liberica Native Image Kit (`liberica-nik`), and expanded Tencent Kona support through JDK 25.
|
- Added the `oracle-openjdk` distribution for OpenJDK builds from Oracle.
|
||||||
- Added `java-version: latest` to resolve the newest stable GA release from the distribution's remote metadata.
|
- Added `java-version: latest` to resolve the newest stable GA release from the distribution's remote metadata.
|
||||||
- Expanded install compatibility with JEP 322 multi-field versions such as `18.0.1.1`, Temurin `jdk+jmods` packages, and native musl artifacts on Alpine for Dragonwell, Corretto, Zulu, and Liberica.
|
- JDK downloads now automatically verify authoritative checksums for [supported distributions](#download-integrity-and-signatures).
|
||||||
- JDK downloads now automatically verify authoritative checksums. Package signature verification is supported for Temurin and Microsoft builds, with configurable strict enforcement.
|
|
||||||
- Added `force-download: true` to bypass the tool cache and perform a reproducible fresh install.
|
- Added `force-download: true` to bypass the tool cache and perform a reproducible fresh install.
|
||||||
- Dependency caching now supports custom paths with `cache-path` and restore-only operation with `cache-read-only: true`.
|
- Dependency caching now supports custom paths with `cache-path` and restore-only operation with `cache-read-only: true`.
|
||||||
- Dependency cache keys now include `.mvn/extensions.xml` and `gradle.properties`, preventing stale restores when Maven extensions or Gradle dependency properties change.
|
|
||||||
- Downloaded JDKs are now [cached](#caching-jdk-installations) automatically when `cache` is set; use `cache-jdk` to enable or disable it independently.
|
- Downloaded JDKs are now [cached](#caching-jdk-installations) automatically when `cache` is set; use `cache-jdk` to enable or disable it independently.
|
||||||
- Warm JDK-cached jobs can reuse cached release metadata, avoiding vendor API calls while retaining a stale-metadata fallback for vendor outages and rate limits.
|
|
||||||
- Maven configuration now supports multiple server credentials and custom dependency-resolution repositories.
|
|
||||||
- Maven signing keys are imported into an isolated temporary GPG home instead of the runner's default keyring.
|
|
||||||
- Set `problem-matcher: false` to disable Java compiler and uncaught-exception annotations.
|
- Set `problem-matcher: false` to disable Java compiler and uncaught-exception annotations.
|
||||||
- GraalVM distributions now set `GRAALVM_HOME` in addition to `JAVA_HOME`.
|
- GraalVM distributions now set `GRAALVM_HOME` in addition to `JAVA_HOME`.
|
||||||
- Invalid boolean values, unsupported distribution/package/platform combinations, and mismatched Maven toolchain ID counts now fail with targeted errors.
|
- Invalid boolean values, unsupported distribution/package/platform combinations, and mismatched Maven toolchain ID counts now fail with targeted errors.
|
||||||
@@ -69,7 +73,6 @@ steps:
|
|||||||
- Deprecated aliases still work, but emit warnings.
|
- Deprecated aliases still work, but emit warnings.
|
||||||
- Maven GPG passphrases are now passed through `gpg.passphraseEnvName` instead of a deprecated `gpg.passphrase` server entry in `settings.xml`. This requires `maven-gpg-plugin` 3.2.0 or newer. See [GPG](docs/advanced-usage.md#gpg).
|
- Maven GPG passphrases are now passed through `gpg.passphraseEnvName` instead of a deprecated `gpg.passphrase` server entry in `settings.xml`. This requires `maven-gpg-plugin` 3.2.0 or newer. See [GPG](docs/advanced-usage.md#gpg).
|
||||||
- Legacy AdoptOpenJDK distributions were removed. Use `temurin` instead of `adopt` or `adopt-hotspot`, and `semeru` instead of `adopt-openj9`.
|
- Legacy AdoptOpenJDK distributions were removed. Use `temurin` instead of `adopt` or `adopt-hotspot`, and `semeru` instead of `adopt-openj9`.
|
||||||
- See the [complete V6 release notes](https://github.com/actions/setup-java/releases/tag/v6.0.0) for all enhancements and fixes.
|
|
||||||
|
|
||||||
### V5
|
### V5
|
||||||
|
|
||||||
@@ -86,7 +89,7 @@ steps:
|
|||||||
### Older versions
|
### Older versions
|
||||||
|
|
||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
> `actions/setup-java` versions `v1` through `v4` are deprecated. Upgrade workflows to `actions/setup-java@v6`, the latest stable release.
|
> `actions/setup-java` versions `v1` through `v4` are deprecated. Upgrade workflows to `actions/setup-java@v5`, the latest stable release.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -95,7 +98,7 @@ steps:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -107,7 +110,7 @@ steps:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: microsoft
|
distribution: microsoft
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -119,7 +122,7 @@ steps:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version-file: .java-version
|
java-version-file: .java-version
|
||||||
@@ -133,7 +136,7 @@ Supported version files are `.java-version`, `.tool-versions`, and `.sdkmanrc`.
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: latest
|
java-version: latest
|
||||||
@@ -150,14 +153,14 @@ steps:
|
|||||||
| `java-version-file` | Path to `.java-version`, `.tool-versions`, or `.sdkmanrc`. Used when `java-version` is not set. | |
|
| `java-version-file` | Path to `.java-version`, `.tool-versions`, or `.sdkmanrc`. Used when `java-version` is not set. | |
|
||||||
| `distribution` | Java distribution keyword. Values are case-sensitive and must match one of the supported keywords below. Required unless `java-version-file` points to `.sdkmanrc` with a recognized distribution suffix. | |
|
| `distribution` | Java distribution keyword. Values are case-sensitive and must match one of the supported keywords below. Required unless `java-version-file` points to `.sdkmanrc` with a recognized distribution suffix. | |
|
||||||
| `java-package` | Package variant such as `jdk`, `jre`, `jdk+fx`, `jre+fx`, `jdk+crac`, `jre+crac`, `jdk+jmods`, `jdk+jcef`, `jre+jcef`, `jdk+ft`, or `jre+ft`. Support varies by distribution. | `jdk` |
|
| `java-package` | Package variant such as `jdk`, `jre`, `jdk+fx`, `jre+fx`, `jdk+crac`, `jre+crac`, `jdk+jmods`, `jdk+jcef`, `jre+jcef`, `jdk+ft`, or `jre+ft`. Support varies by distribution. | `jdk` |
|
||||||
| `architecture` | Package architecture. Canonical values are `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, `riscv64`, and `s390x`. Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized. | Runner architecture |
|
| `architecture` | Package architecture. Canonical values are `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, and `s390x`. Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized. | Runner architecture |
|
||||||
| `jdk-file` | Local compressed JDK archive. Requires `distribution: jdkfile`. | |
|
| `jdk-file` | Local compressed JDK archive. Requires `distribution: jdkfile`. | |
|
||||||
| `check-latest` | Check remote metadata for the latest version satisfying the version spec before using the runner tool cache. | `false` |
|
| `check-latest` | Check remote metadata for the latest version satisfying the version spec before using the runner tool cache. | `false` |
|
||||||
| `force-download` | Always download Java and replace any matching version in the tool cache. | `false` |
|
| `force-download` | Always download Java and replace any matching version in the tool cache. | `false` |
|
||||||
| `set-default` | Add Java to `PATH` and set `JAVA_HOME`. When `false`, only version-specific `JAVA_HOME_<major>_<arch>` variables are set. | `true` |
|
| `set-default` | Add Java to `PATH` and set `JAVA_HOME`. When `false`, only version-specific `JAVA_HOME_<major>_<arch>` variables are set. | `true` |
|
||||||
| `problem-matcher` | Register Java compiler and uncaught exception problem matchers. | `true` |
|
| `problem-matcher` | Register Java compiler and uncaught exception problem matchers. | `true` |
|
||||||
| `verify-signature` | Verify downloaded Java package signatures when supported. Explicitly setting this to `true` makes verification failures fatal. | Distribution-dependent; see [Download integrity and signatures](#download-integrity-and-signatures) |
|
| `verify-signature` | Verify downloaded Java package signatures when supported. Currently supported for `temurin` and `microsoft`. | `false` |
|
||||||
| `verify-signature-public-key` | One or more ASCII-armored GPG public keys used for signature verification. Concatenate multiple armored key blocks. Custom keys replace the bundled distribution keys. | |
|
| `verify-signature-public-key` | ASCII-armored GPG public key to use for signature verification. Overrides the bundled key. | |
|
||||||
| `token` | Token for fetching GitHub.com-hosted version manifests, useful on GitHub Enterprise Server when unauthenticated requests are rate-limited. | `${{ github.token }}` on GitHub.com; empty string on GHES |
|
| `token` | Token for fetching GitHub.com-hosted version manifests, useful on GitHub Enterprise Server when unauthenticated requests are rate-limited. | `${{ github.token }}` on GitHub.com; empty string on GHES |
|
||||||
| `cache` | Enable dependency caching for `maven`, `gradle`, or `sbt`. | |
|
| `cache` | Enable dependency caching for `maven`, `gradle`, or `sbt`. | |
|
||||||
| `cache-jdk` | Cache downloaded JDK installations between jobs. When omitted, JDK caching is enabled only if `cache` is set. Set explicitly to `true` or `false` to override. | Enabled when `cache` is set |
|
| `cache-jdk` | Cache downloaded JDK installations between jobs. When omitted, JDK caching is enabled only if `cache` is set. Set explicitly to `true` or `false` to override. | Enabled when `cache` is set |
|
||||||
@@ -167,10 +170,6 @@ steps:
|
|||||||
| `server-id` | Maven repository ID used in generated `settings.xml`. | `github` |
|
| `server-id` | Maven repository ID used in generated `settings.xml`. | `github` |
|
||||||
| `server-username-env-var` | Environment variable name for Maven repository username. | `GITHUB_ACTOR` |
|
| `server-username-env-var` | Environment variable name for Maven repository username. | `GITHUB_ACTOR` |
|
||||||
| `server-password-env-var` | Environment variable name for Maven repository password or token. | `GITHUB_TOKEN` |
|
| `server-password-env-var` | Environment variable name for Maven repository password or token. | `GITHUB_TOKEN` |
|
||||||
| `mvn-server-credentials` | Multiline Maven server credentials in the format `server-id:USERNAME_ENV:PASSWORD_ENV`. Replaces the single server configured by the three inputs above when set. | |
|
|
||||||
| `mvn-repositories` | Multiline Maven dependency repositories in the format `repository-id:repository-url:snapshots-enabled`. | |
|
|
||||||
| `mvn-repositories-include-central` | Include Maven Central in the generated dependency repositories profile. When `false`, Central is disabled unless an explicit `central` repository is declared. | `true` |
|
|
||||||
| `mvn-repositories-prioritize-central` | Place Maven Central before custom dependency repositories. Has no effect when Maven Central is excluded. | `true` |
|
|
||||||
| `settings-path` | Directory where `settings.xml` is written. | `~/.m2` |
|
| `settings-path` | Directory where `settings.xml` is written. | `~/.m2` |
|
||||||
| `overwrite-settings` | Overwrite an existing `settings.xml`. | `true` |
|
| `overwrite-settings` | Overwrite an existing `settings.xml`. | `true` |
|
||||||
| `gpg-private-key` | GPG private key to import into an isolated temporary keyring. | |
|
| `gpg-private-key` | GPG private key to import into an isolated temporary keyring. | |
|
||||||
@@ -208,7 +207,6 @@ Deprecated aliases `jdkFile`, `server-username`, `server-password`, and `gpg-pas
|
|||||||
| `microsoft` | [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) | [License](https://docs.microsoft.com/java/openjdk/faq) |
|
| `microsoft` | [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) | [License](https://docs.microsoft.com/java/openjdk/faq) |
|
||||||
| `oracle` | [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) | [License](https://java.com/freeuselicense) |
|
| `oracle` | [Oracle JDK](https://www.oracle.com/java/technologies/downloads/) | [License](https://java.com/freeuselicense) |
|
||||||
| `oracle-openjdk` | [Oracle OpenJDK](https://jdk.java.net/) | [License](https://openjdk.org/legal/gplv2+ce.html) |
|
| `oracle-openjdk` | [Oracle OpenJDK](https://jdk.java.net/) | [License](https://openjdk.org/legal/gplv2+ce.html) |
|
||||||
| `redhat` | [Red Hat Build of OpenJDK](https://developers.redhat.com/products/openjdk/overview) | [License](https://openjdk.org/legal/gplv2+ce.html) |
|
|
||||||
| `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [License](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE) |
|
| `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [License](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE) |
|
||||||
| `semeru` | [IBM Semeru Runtime Open Edition](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [License](https://openjdk.java.net/legal/gplv2+ce.html) |
|
| `semeru` | [IBM Semeru Runtime Open Edition](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [License](https://openjdk.java.net/legal/gplv2+ce.html) |
|
||||||
| `temurin` | [Eclipse Temurin](https://adoptium.net/) | [License](https://adoptium.net/about.html) |
|
| `temurin` | [Eclipse Temurin](https://adoptium.net/) | [License](https://adoptium.net/about.html) |
|
||||||
@@ -233,7 +231,7 @@ Additional distribution notes:
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| Major version | `8`, `11`, `17`, `21`, `25` |
|
| Major version | `8`, `11`, `17`, `21`, `25` |
|
||||||
| Specific feature or patch version | `11.0`, `11.0.4`, `17.0`, `8.0.282+8` |
|
| Specific feature or patch version | `11.0`, `11.0.4`, `17.0`, `8.0.282+8` |
|
||||||
| JEP 322 multi-field versions | `11.0.9.1`, `18.0.1.1`, `26.0.2.1+1` |
|
| JEP 322 multi-field versions | `11.0.9.1`, `18.0.1.1` |
|
||||||
| Early access | `15-ea`, `15.0.0-ea`, `27-ea` |
|
| Early access | `15-ea`, `15.0.0-ea`, `27-ea` |
|
||||||
| Latest stable GA release | `latest` |
|
| Latest stable GA release | `latest` |
|
||||||
|
|
||||||
@@ -247,34 +245,7 @@ GitHub-hosted runners primarily pre-cache Eclipse Temurin JDKs. See the installe
|
|||||||
|
|
||||||
Distributions or individual releases without an authoritative checksum continue to install normally, with the omission reported in debug logs. Installations resolved directly from the runner tool cache — including JDKs preinstalled on the runner image and JDKs installed by an earlier step of the same job — are not downloaded again and are not reverified, even when `verify-signature: true` is set. Use `force-download: true` to always download and verify the archive.
|
Distributions or individual releases without an authoritative checksum continue to install normally, with the omission reported in debug logs. Installations resolved directly from the runner tool cache — including JDKs preinstalled on the runner image and JDKs installed by an earlier step of the same job — are not downloaded again and are not reverified, even when `verify-signature: true` is set. Use `force-download: true` to always download and verify the archive.
|
||||||
|
|
||||||
Package signature verification is supported for `temurin` and `microsoft`. When `verify-signature` is omitted, the action checks the signature and warns if GPG is unavailable or verification fails, but does not enforce the result. Explicitly setting `verify-signature: true` enforces verification and makes these failures fatal. Setting `verify-signature: true` for an unsupported distribution also fails the workflow.
|
Use `verify-signature: true` to verify package signatures for distributions that support it. Currently supported distributions are `temurin` and `microsoft`; setting it for an unsupported distribution fails the workflow.
|
||||||
|
|
||||||
> [!WARNING]
|
|
||||||
> Requesting explicit signature verification with verify-signature can fail a build after an unexpected but legitimate vendor signing-key rotation, because the action's bundled keys may not yet include the new key. Confirm a new key through the vendor's trusted documentation before using it.
|
|
||||||
|
|
||||||
After confirming a legitimate rotation, configure the updated key with `verify-signature-public-key`. The input accepts one or more ASCII-armored public keys; concatenate complete armored key blocks when both old and new vendor keys are needed during a transition. Custom keys replace, rather than extend, the keys bundled with the selected distribution.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/setup-java@v6
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: '25'
|
|
||||||
verify-signature: true
|
|
||||||
verify-signature-public-key: |
|
|
||||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
...vendor key material...
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
|
||||||
```
|
|
||||||
|
|
||||||
As a temporary fallback while a legitimate rotation is being investigated, set `verify-signature: false`. This disables package signature verification, although authoritative checksum verification still applies when the vendor publishes a checksum.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/setup-java@v6
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: '25'
|
|
||||||
verify-signature: false
|
|
||||||
```
|
|
||||||
|
|
||||||
## Caching
|
## Caching
|
||||||
|
|
||||||
@@ -291,7 +262,7 @@ Set `cache` to `maven`, `gradle`, or `sbt` to cache dependencies with minimal co
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -310,7 +281,7 @@ The primary dependency cache key is `setup-java-<runner-os>-<node-arch>-<package
|
|||||||
Use `cache-dependency-path` to override the files used for key hashing, especially in monorepos:
|
Use `cache-dependency-path` to override the files used for key hashing, especially in monorepos:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -323,7 +294,7 @@ Use `cache-dependency-path` to override the files used for key hashing, especial
|
|||||||
Use `cache-path` when the build tool stores dependencies outside the default location:
|
Use `cache-path` when the build tool stores dependencies outside the default location:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -362,7 +333,7 @@ The JDK cache stores the downloaded JDK installation so later runs skip the down
|
|||||||
Set `cache-read-only: true` to restore dependency, wrapper, and JDK caches without saving changes in the post action. This is useful for pull requests, merge queues, short-lived branches, and matrix fan-out jobs that should only consume caches produced elsewhere.
|
Set `cache-read-only: true` to restore dependency, wrapper, and JDK caches without saving changes in the post action. This is useful for pull requests, merge queues, short-lived branches, and matrix fan-out jobs that should only consume caches produced elsewhere.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -378,7 +349,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -393,7 +364,7 @@ jobs:
|
|||||||
goal: [test, verify, package]
|
goal: [test, verify, package]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -411,7 +382,7 @@ env:
|
|||||||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
|
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -425,7 +396,7 @@ Install multiple Java versions by providing a multiline `java-version` value. Al
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: |
|
java-version: |
|
||||||
@@ -452,7 +423,7 @@ jobs:
|
|||||||
name: Java ${{ matrix.java }}
|
name: Java ${{ matrix.java }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
@@ -469,7 +440,7 @@ jobs:
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -481,17 +452,12 @@ steps:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
For dependencies hosted outside Maven Central, use `mvn-repositories` to add
|
|
||||||
resolution repositories to an active profile in the generated `settings.xml`.
|
|
||||||
Repository IDs can match `mvn-server-credentials` IDs when authentication is
|
|
||||||
required. See [Resolving Maven dependencies from custom repositories](docs/advanced-usage.md#resolving-maven-dependencies-from-custom-repositories).
|
|
||||||
|
|
||||||
### GPG signing
|
### GPG signing
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v7
|
||||||
- uses: actions/setup-java@v6
|
- uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
@@ -546,7 +512,7 @@ The scripts and documentation in this project are released under the [MIT Licens
|
|||||||
|
|
||||||
## Contributions
|
## Contributions
|
||||||
|
|
||||||
Contributions are welcome. See our [Contributor's Guide](docs/CONTRIBUTING.md).
|
Contributions are welcome. See our [Contributor's Guide](docs/contributors.md).
|
||||||
|
|
||||||
## Code of Conduct
|
## Code of Conduct
|
||||||
|
|
||||||
|
|||||||
+28
-479
@@ -26,7 +26,7 @@ jest.unstable_mockModule('@actions/core', () => ({
|
|||||||
setOutput: jest.fn(),
|
setOutput: jest.fn(),
|
||||||
getInput: jest.fn(),
|
getInput: jest.fn(),
|
||||||
getBooleanInput: jest.fn(),
|
getBooleanInput: jest.fn(),
|
||||||
getMultilineInput: jest.fn(() => []),
|
getMultilineInput: jest.fn(),
|
||||||
addPath: jest.fn(),
|
addPath: jest.fn(),
|
||||||
exportVariable: jest.fn(),
|
exportVariable: jest.fn(),
|
||||||
saveState: jest.fn(),
|
saveState: jest.fn(),
|
||||||
@@ -57,18 +57,6 @@ const {M2_DIR, MVN_SETTINGS_FILE, STATE_GPG_HOME} =
|
|||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const m2Dir = path.join(__dirname, M2_DIR);
|
const m2Dir = path.join(__dirname, M2_DIR);
|
||||||
const settingsFile = path.join(m2Dir, MVN_SETTINGS_FILE);
|
const settingsFile = path.join(m2Dir, MVN_SETTINGS_FILE);
|
||||||
const credentials = (id: string, username: string, password: string) => [
|
|
||||||
{id, usernameEnvVar: username, passwordEnvVar: password}
|
|
||||||
];
|
|
||||||
const repositorySettings = (
|
|
||||||
repositories: auth.MavenRepository[],
|
|
||||||
includeCentral = true,
|
|
||||||
prioritizeCentral = true
|
|
||||||
): auth.MavenRepositorySettings => ({
|
|
||||||
repositories,
|
|
||||||
includeCentral,
|
|
||||||
prioritizeCentral
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('auth tests', () => {
|
describe('auth tests', () => {
|
||||||
let spyOSHomedir: any;
|
let spyOSHomedir: any;
|
||||||
@@ -85,9 +73,6 @@ describe('auth tests', () => {
|
|||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
(core.getInput as jest.Mock).mockReset();
|
(core.getInput as jest.Mock).mockReset();
|
||||||
(core.getMultilineInput as jest.Mock).mockReset();
|
|
||||||
(core.getMultilineInput as jest.Mock).mockReturnValue([]);
|
|
||||||
(core.warning as jest.Mock).mockReset();
|
|
||||||
(core.exportVariable as jest.Mock).mockReset();
|
(core.exportVariable as jest.Mock).mockReset();
|
||||||
(gpg.importKey as jest.Mock).mockReset();
|
(gpg.importKey as jest.Mock).mockReset();
|
||||||
(gpg.removeGpgHome as jest.Mock).mockReset();
|
(gpg.removeGpgHome as jest.Mock).mockReset();
|
||||||
@@ -115,7 +100,9 @@ describe('auth tests', () => {
|
|||||||
await io.rmRF(altHome); // ensure it doesn't already exist
|
await io.rmRF(altHome); // ensure it doesn't already exist
|
||||||
|
|
||||||
await auth.createAuthenticationSettings(
|
await auth.createAuthenticationSettings(
|
||||||
credentials(id, username, password),
|
id,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
altHome,
|
altHome,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@@ -126,7 +113,7 @@ describe('auth tests', () => {
|
|||||||
expect(fs.existsSync(altHome)).toBe(true);
|
expect(fs.existsSync(altHome)).toBe(true);
|
||||||
expect(fs.existsSync(altSettingsFile)).toBe(true);
|
expect(fs.existsSync(altSettingsFile)).toBe(true);
|
||||||
expect(fs.readFileSync(altSettingsFile, 'utf-8')).toEqual(
|
expect(fs.readFileSync(altSettingsFile, 'utf-8')).toEqual(
|
||||||
auth.generate(credentials(id, username, password))
|
auth.generate(id, username, password)
|
||||||
);
|
);
|
||||||
|
|
||||||
await io.rmRF(altHome);
|
await io.rmRF(altHome);
|
||||||
@@ -138,7 +125,9 @@ describe('auth tests', () => {
|
|||||||
const password = 'TOKEN';
|
const password = 'TOKEN';
|
||||||
|
|
||||||
await auth.createAuthenticationSettings(
|
await auth.createAuthenticationSettings(
|
||||||
credentials(id, username, password),
|
id,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
m2Dir,
|
m2Dir,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@@ -146,7 +135,7 @@ describe('auth tests', () => {
|
|||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
expect(fs.existsSync(settingsFile)).toBe(true);
|
expect(fs.existsSync(settingsFile)).toBe(true);
|
||||||
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
|
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
|
||||||
auth.generate(credentials(id, username, password))
|
auth.generate(id, username, password)
|
||||||
);
|
);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
@@ -157,7 +146,9 @@ describe('auth tests', () => {
|
|||||||
const gpgPassphrase = 'GPG';
|
const gpgPassphrase = 'GPG';
|
||||||
|
|
||||||
await auth.createAuthenticationSettings(
|
await auth.createAuthenticationSettings(
|
||||||
credentials(id, username, password),
|
id,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
m2Dir,
|
m2Dir,
|
||||||
true,
|
true,
|
||||||
gpgPassphrase
|
gpgPassphrase
|
||||||
@@ -166,7 +157,7 @@ describe('auth tests', () => {
|
|||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
expect(fs.existsSync(settingsFile)).toBe(true);
|
expect(fs.existsSync(settingsFile)).toBe(true);
|
||||||
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
|
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
|
||||||
auth.generate(credentials(id, username, password), gpgPassphrase)
|
auth.generate(id, username, password, gpgPassphrase)
|
||||||
);
|
);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
@@ -227,7 +218,9 @@ describe('auth tests', () => {
|
|||||||
expect(fs.existsSync(settingsFile)).toBe(true);
|
expect(fs.existsSync(settingsFile)).toBe(true);
|
||||||
|
|
||||||
await auth.createAuthenticationSettings(
|
await auth.createAuthenticationSettings(
|
||||||
credentials(id, username, password),
|
id,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
m2Dir,
|
m2Dir,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
@@ -235,7 +228,7 @@ describe('auth tests', () => {
|
|||||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
expect(fs.existsSync(settingsFile)).toBe(true);
|
expect(fs.existsSync(settingsFile)).toBe(true);
|
||||||
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
|
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
|
||||||
auth.generate(credentials(id, username, password))
|
auth.generate(id, username, password)
|
||||||
);
|
);
|
||||||
}, 100000);
|
}, 100000);
|
||||||
|
|
||||||
@@ -250,7 +243,9 @@ describe('auth tests', () => {
|
|||||||
expect(fs.existsSync(settingsFile)).toBe(true);
|
expect(fs.existsSync(settingsFile)).toBe(true);
|
||||||
|
|
||||||
await auth.createAuthenticationSettings(
|
await auth.createAuthenticationSettings(
|
||||||
credentials(id, username, password),
|
id,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
m2Dir,
|
m2Dir,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@@ -278,9 +273,7 @@ describe('auth tests', () => {
|
|||||||
</servers>
|
</servers>
|
||||||
</settings>`;
|
</settings>`;
|
||||||
|
|
||||||
expect(auth.generate(credentials(id, username, password))).toEqual(
|
expect(auth.generate(id, username, password)).toEqual(expectedSettings);
|
||||||
expectedSettings
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates valid settings.xml with additional configuration', () => {
|
it('generates valid settings.xml with additional configuration', () => {
|
||||||
@@ -313,9 +306,9 @@ describe('auth tests', () => {
|
|||||||
</activeProfiles>
|
</activeProfiles>
|
||||||
</settings>`;
|
</settings>`;
|
||||||
|
|
||||||
expect(
|
expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(
|
||||||
auth.generate(credentials(id, username, password), gpgPassphrase)
|
expectedSettings
|
||||||
).toEqual(expectedSettings);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not add a gpg profile when the passphrase env var is the maven-gpg-plugin default', () => {
|
it('does not add a gpg profile when the passphrase env var is the maven-gpg-plugin default', () => {
|
||||||
@@ -337,9 +330,9 @@ describe('auth tests', () => {
|
|||||||
</servers>
|
</servers>
|
||||||
</settings>`;
|
</settings>`;
|
||||||
|
|
||||||
expect(
|
expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(
|
||||||
auth.generate(credentials(id, username, password), gpgPassphrase)
|
expectedSettings
|
||||||
).toEqual(expectedSettings);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('escapes settings.xml values while preserving parsed semantics', () => {
|
it('escapes settings.xml values while preserving parsed semantics', () => {
|
||||||
@@ -348,10 +341,7 @@ describe('auth tests', () => {
|
|||||||
const password = `TOKEN&<>"'é`;
|
const password = `TOKEN&<>"'é`;
|
||||||
const gpgPassphrase = `GPG&<>"'é`;
|
const gpgPassphrase = `GPG&<>"'é`;
|
||||||
|
|
||||||
const xml = auth.generate(
|
const xml = auth.generate(id, username, password, gpgPassphrase);
|
||||||
credentials(id, username, password),
|
|
||||||
gpgPassphrase
|
|
||||||
);
|
|
||||||
const parsed = parseXmlObject(xml) as any;
|
const parsed = parseXmlObject(xml) as any;
|
||||||
|
|
||||||
expect(parsed.settings.interactiveMode).toBe('false');
|
expect(parsed.settings.interactiveMode).toBe('false');
|
||||||
@@ -362,447 +352,6 @@ describe('auth tests', () => {
|
|||||||
expect(parsed.settings.activeProfiles.activeProfile).toBe('setup-java-gpg');
|
expect(parsed.settings.activeProfiles.activeProfile).toBe('setup-java-gpg');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates ordered settings.xml entries for multiple servers', () => {
|
|
||||||
const servers = [
|
|
||||||
{
|
|
||||||
id: 'releases',
|
|
||||||
usernameEnvVar: 'RELEASES_USERNAME',
|
|
||||||
passwordEnvVar: 'RELEASES_PASSWORD'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'snapshots',
|
|
||||||
usernameEnvVar: 'SNAPSHOTS_USERNAME',
|
|
||||||
passwordEnvVar: 'SNAPSHOTS_PASSWORD'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const parsed = parseXmlObject(auth.generate(servers)) as any;
|
|
||||||
|
|
||||||
expect(parsed.settings.servers.server).toEqual([
|
|
||||||
{
|
|
||||||
id: 'releases',
|
|
||||||
username: '${env.RELEASES_USERNAME}',
|
|
||||||
password: '${env.RELEASES_PASSWORD}'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'snapshots',
|
|
||||||
username: '${env.SNAPSHOTS_USERNAME}',
|
|
||||||
password: '${env.SNAPSHOTS_PASSWORD}'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('generates an active profile with Central before custom repositories by default', () => {
|
|
||||||
const parsed = parseXmlObject(
|
|
||||||
auth.generate(
|
|
||||||
credentials('packages', 'USERNAME', 'PASSWORD'),
|
|
||||||
undefined,
|
|
||||||
repositorySettings([
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com/maven',
|
|
||||||
snapshotsEnabled: true
|
|
||||||
}
|
|
||||||
])
|
|
||||||
)
|
|
||||||
) as any;
|
|
||||||
|
|
||||||
expect(parsed.settings.profiles.profile).toEqual({
|
|
||||||
id: 'setup-java-repositories',
|
|
||||||
repositories: {
|
|
||||||
repository: [
|
|
||||||
{
|
|
||||||
id: 'central',
|
|
||||||
url: 'https://repo.maven.apache.org/maven2',
|
|
||||||
snapshots: {enabled: 'false'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com/maven',
|
|
||||||
snapshots: {enabled: 'true'}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
expect(parsed.settings.activeProfiles.activeProfile).toBe(
|
|
||||||
'setup-java-repositories'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('places custom repositories before Central when configured', () => {
|
|
||||||
const parsed = parseXmlObject(
|
|
||||||
auth.generate(
|
|
||||||
credentials('packages', 'USERNAME', 'PASSWORD'),
|
|
||||||
undefined,
|
|
||||||
repositorySettings(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'first',
|
|
||||||
url: 'https://first.example.com',
|
|
||||||
snapshotsEnabled: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'second',
|
|
||||||
url: 'https://second.example.com',
|
|
||||||
snapshotsEnabled: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
true,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) as any;
|
|
||||||
|
|
||||||
expect(
|
|
||||||
parsed.settings.profiles.profile.repositories.repository.map(
|
|
||||||
(repository: {id: string}) => repository.id
|
|
||||||
)
|
|
||||||
).toEqual(['first', 'second', 'central']);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('excludes Central from the generated repository profile when configured', () => {
|
|
||||||
const parsed = parseXmlObject(
|
|
||||||
auth.generate(
|
|
||||||
credentials('packages', 'USERNAME', 'PASSWORD'),
|
|
||||||
undefined,
|
|
||||||
repositorySettings(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com',
|
|
||||||
snapshotsEnabled: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) as any;
|
|
||||||
|
|
||||||
expect(parsed.settings.profiles.profile.repositories.repository).toEqual([
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com',
|
|
||||||
snapshots: {enabled: 'false'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'central',
|
|
||||||
url: 'https://repo.maven.apache.org/maven2',
|
|
||||||
releases: {enabled: 'false'},
|
|
||||||
snapshots: {enabled: 'false'}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('combines repository and GPG configuration in shared profile blocks', () => {
|
|
||||||
const parsed = parseXmlObject(
|
|
||||||
auth.generate(
|
|
||||||
credentials('packages', 'USERNAME', 'PASSWORD'),
|
|
||||||
'GPG_PASSPHRASE',
|
|
||||||
repositorySettings(
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com',
|
|
||||||
snapshotsEnabled: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) as any;
|
|
||||||
|
|
||||||
expect(parsed.settings.profiles.profile).toEqual([
|
|
||||||
{
|
|
||||||
id: 'setup-java-repositories',
|
|
||||||
repositories: {
|
|
||||||
repository: [
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com',
|
|
||||||
snapshots: {enabled: 'false'}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'central',
|
|
||||||
url: 'https://repo.maven.apache.org/maven2',
|
|
||||||
releases: {enabled: 'false'},
|
|
||||||
snapshots: {enabled: 'false'}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'setup-java-gpg',
|
|
||||||
properties: {['gpg.passphraseEnvName']: 'GPG_PASSPHRASE'}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
expect(parsed.settings.activeProfiles.activeProfile).toEqual([
|
|
||||||
'setup-java-repositories',
|
|
||||||
'setup-java-gpg'
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('escapes repository values while preserving parsed semantics', () => {
|
|
||||||
const repository = {
|
|
||||||
id: `private&<>"'é`,
|
|
||||||
url: `https://repo.example.com/a?x=1&y=<value>"'é`,
|
|
||||||
snapshotsEnabled: true
|
|
||||||
};
|
|
||||||
const xml = auth.generate(
|
|
||||||
credentials('packages', 'USERNAME', 'PASSWORD'),
|
|
||||||
undefined,
|
|
||||||
repositorySettings([repository], false)
|
|
||||||
);
|
|
||||||
const parsed = parseXmlObject(xml) as any;
|
|
||||||
|
|
||||||
expect(
|
|
||||||
parsed.settings.profiles.profile.repositories.repository.find(
|
|
||||||
(entry: {id: string}) => entry.id === repository.id
|
|
||||||
)
|
|
||||||
).toEqual({
|
|
||||||
id: repository.id,
|
|
||||||
url: repository.url,
|
|
||||||
snapshots: {enabled: 'true'}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('parses and trims multiline Maven server credentials', () => {
|
|
||||||
expect(
|
|
||||||
auth.parseMavenServerCredentials([
|
|
||||||
'',
|
|
||||||
' releases : RELEASES_USERNAME : RELEASES_PASSWORD ',
|
|
||||||
'snapshots:SNAPSHOTS_USERNAME:SNAPSHOTS_PASSWORD'
|
|
||||||
])
|
|
||||||
).toEqual([
|
|
||||||
{
|
|
||||||
id: 'releases',
|
|
||||||
usernameEnvVar: 'RELEASES_USERNAME',
|
|
||||||
passwordEnvVar: 'RELEASES_PASSWORD'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'snapshots',
|
|
||||||
usernameEnvVar: 'SNAPSHOTS_USERNAME',
|
|
||||||
passwordEnvVar: 'SNAPSHOTS_PASSWORD'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('parses Maven repositories while preserving colons in URLs', () => {
|
|
||||||
expect(
|
|
||||||
auth.parseMavenRepositories(
|
|
||||||
[
|
|
||||||
'',
|
|
||||||
' private : https://repo.example.com:8443/maven : true ',
|
|
||||||
'releases:https://repo.example.com/releases:false'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
)
|
|
||||||
).toEqual([
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com:8443/maven',
|
|
||||||
snapshotsEnabled: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'releases',
|
|
||||||
url: 'https://repo.example.com/releases',
|
|
||||||
snapshotsEnabled: false
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
{
|
|
||||||
entries: ['private'],
|
|
||||||
error:
|
|
||||||
'Invalid mvn-repositories entry at line 1. Expected format: repository-id:repository-url:snapshots-enabled'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entries: ['private:https://repo.example.com'],
|
|
||||||
error:
|
|
||||||
"Invalid snapshots-enabled value '//repo.example.com' in mvn-repositories entry at line 1. Expected true or false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entries: ['private::true'],
|
|
||||||
error:
|
|
||||||
'Invalid mvn-repositories entry at line 1. repository-id, repository URL, and snapshots-enabled are required'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entries: ['private:https://repo.example.com:sometimes'],
|
|
||||||
error:
|
|
||||||
"Invalid snapshots-enabled value 'sometimes' in mvn-repositories entry at line 1. Expected true or false"
|
|
||||||
}
|
|
||||||
])('rejects malformed Maven repositories: $entries', ({entries, error}) => {
|
|
||||||
expect(() => auth.parseMavenRepositories(entries, true)).toThrow(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('rejects duplicate Maven repository ids', () => {
|
|
||||||
expect(() =>
|
|
||||||
auth.parseMavenRepositories(
|
|
||||||
[
|
|
||||||
'private:https://first.example.com:false',
|
|
||||||
'private:https://second.example.com:true'
|
|
||||||
],
|
|
||||||
true
|
|
||||||
)
|
|
||||||
).toThrow("Duplicate repository-id 'private' in mvn-repositories input");
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reserves the Central repository id only when automatic Central inclusion is enabled', () => {
|
|
||||||
const central = 'central:https://custom.example.com/maven:false';
|
|
||||||
|
|
||||||
expect(() => auth.parseMavenRepositories([central], true)).toThrow(
|
|
||||||
"Repository-id 'central' is reserved when mvn-repositories-include-central is enabled"
|
|
||||||
);
|
|
||||||
expect(auth.parseMavenRepositories([central], false)).toEqual([
|
|
||||||
{
|
|
||||||
id: 'central',
|
|
||||||
url: 'https://custom.example.com/maven',
|
|
||||||
snapshotsEnabled: false
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('uses an explicit Central repository instead of adding a disabled override', () => {
|
|
||||||
const parsed = parseXmlObject(
|
|
||||||
auth.generate(
|
|
||||||
credentials('packages', 'USERNAME', 'PASSWORD'),
|
|
||||||
undefined,
|
|
||||||
repositorySettings(
|
|
||||||
auth.parseMavenRepositories(
|
|
||||||
['central:https://mirror.example.com/maven:true'],
|
|
||||||
false
|
|
||||||
),
|
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
) as any;
|
|
||||||
|
|
||||||
expect(parsed.settings.profiles.profile.repositories.repository).toEqual({
|
|
||||||
id: 'central',
|
|
||||||
url: 'https://mirror.example.com/maven',
|
|
||||||
snapshots: {enabled: 'true'}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reads Maven repository settings and Central controls', () => {
|
|
||||||
(core.getMultilineInput as jest.Mock).mockImplementation((name: string) =>
|
|
||||||
name === 'mvn-repositories'
|
|
||||||
? ['private:https://repo.example.com:true']
|
|
||||||
: []
|
|
||||||
);
|
|
||||||
(core.getInput as jest.Mock).mockImplementation((name: string) => {
|
|
||||||
const inputs: Record<string, string> = {
|
|
||||||
'mvn-repositories-include-central': 'false',
|
|
||||||
'mvn-repositories-prioritize-central': 'false'
|
|
||||||
};
|
|
||||||
return inputs[name] ?? '';
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(auth.getMavenRepositorySettings()).toEqual({
|
|
||||||
repositories: [
|
|
||||||
{
|
|
||||||
id: 'private',
|
|
||||||
url: 'https://repo.example.com',
|
|
||||||
snapshotsEnabled: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
includeCentral: false,
|
|
||||||
prioritizeCentral: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not read repository controls when no repositories are configured', () => {
|
|
||||||
expect(auth.getMavenRepositorySettings()).toBeUndefined();
|
|
||||||
expect(core.getInput).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
{
|
|
||||||
entries: ['releases:RELEASES_USERNAME'],
|
|
||||||
error:
|
|
||||||
'Invalid mvn-server-credentials entry at line 1. Expected format: server-id:USERNAME_ENV:PASSWORD_ENV'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entries: ['', 'releases:RELEASES_USERNAME:RELEASES_PASSWORD:EXTRA'],
|
|
||||||
error:
|
|
||||||
'Invalid mvn-server-credentials entry at line 2. Expected format: server-id:USERNAME_ENV:PASSWORD_ENV'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entries: ['releases::RELEASES_PASSWORD'],
|
|
||||||
error:
|
|
||||||
'Invalid mvn-server-credentials entry at line 1. server-id, username environment variable, and password environment variable are required'
|
|
||||||
}
|
|
||||||
])(
|
|
||||||
'rejects malformed Maven server credentials: $entries',
|
|
||||||
({entries, error}) => {
|
|
||||||
expect(() => auth.parseMavenServerCredentials(entries)).toThrow(error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it('rejects duplicate Maven server ids', () => {
|
|
||||||
expect(() =>
|
|
||||||
auth.parseMavenServerCredentials([
|
|
||||||
'releases:RELEASES_USERNAME:RELEASES_PASSWORD',
|
|
||||||
'releases:OTHER_USERNAME:OTHER_PASSWORD'
|
|
||||||
])
|
|
||||||
).toThrow("Duplicate server-id 'releases' in mvn-server-credentials input");
|
|
||||||
});
|
|
||||||
|
|
||||||
it('uses multiline Maven server credentials instead of single-server inputs', () => {
|
|
||||||
(core.getMultilineInput as jest.Mock).mockReturnValue([
|
|
||||||
'releases:RELEASES_USERNAME:RELEASES_PASSWORD',
|
|
||||||
'snapshots:SNAPSHOTS_USERNAME:SNAPSHOTS_PASSWORD'
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(auth.getMavenServerSettings()).toEqual([
|
|
||||||
{
|
|
||||||
id: 'releases',
|
|
||||||
usernameEnvVar: 'RELEASES_USERNAME',
|
|
||||||
passwordEnvVar: 'RELEASES_PASSWORD'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'snapshots',
|
|
||||||
usernameEnvVar: 'SNAPSHOTS_USERNAME',
|
|
||||||
passwordEnvVar: 'SNAPSHOTS_PASSWORD'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
expect(core.getInput).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('uses the existing single-server inputs when multiline credentials are absent', () => {
|
|
||||||
(core.getInput as jest.Mock).mockImplementation((name: string) =>
|
|
||||||
name === 'server-id' ? 'github' : ''
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(auth.getMavenServerSettings()).toEqual([
|
|
||||||
{
|
|
||||||
id: 'github',
|
|
||||||
usernameEnvVar: 'GITHUB_ACTOR',
|
|
||||||
passwordEnvVar: 'GITHUB_TOKEN'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('preserves deprecated single-server aliases as fallback inputs', () => {
|
|
||||||
(core.getInput as jest.Mock).mockImplementation((name: string) => {
|
|
||||||
const inputs: Record<string, string> = {
|
|
||||||
'server-id': 'legacy',
|
|
||||||
'server-username': 'LEGACY_USERNAME',
|
|
||||||
'server-password': 'LEGACY_PASSWORD'
|
|
||||||
};
|
|
||||||
return inputs[name] ?? '';
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(auth.getMavenServerSettings()).toEqual([
|
|
||||||
{
|
|
||||||
id: 'legacy',
|
|
||||||
usernameEnvVar: 'LEGACY_USERNAME',
|
|
||||||
passwordEnvVar: 'LEGACY_PASSWORD'
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
expect(core.warning).toHaveBeenCalledTimes(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
function xmlElementText(xml: string, tagName: string): string {
|
function xmlElementText(xml: string, tagName: string): string {
|
||||||
const match = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`).exec(xml);
|
const match = new RegExp(`<${tagName}>([\\s\\S]*?)</${tagName}>`).exec(xml);
|
||||||
expect(match).not.toBeNull();
|
expect(match).not.toBeNull();
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ function createRegisteredJdk(version = '21.0.8+9') {
|
|||||||
architecture: 'x64',
|
architecture: 'x64',
|
||||||
version,
|
version,
|
||||||
source: `sha256:${path.basename(root)}`,
|
source: `sha256:${path.basename(root)}`,
|
||||||
verification: 'disabled',
|
verification: 'unverified',
|
||||||
path: jdkPath
|
path: jdkPath
|
||||||
};
|
};
|
||||||
registerJdk(jdk);
|
registerJdk(jdk);
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"filename": "java-21-openjdk-21.0.8.0.9-1.portable.jdk.x86_64.tar.xz",
|
|
||||||
"direct_download_uri": "https://developers.redhat.com/content-gateway/file/pub/openjdk/java-21-openjdk-21.0.8.0.9-1.portable.jdk.x86_64.tar.xz",
|
|
||||||
"checksum": "91a6f3284cbded9de17f65985a4fca48dd4fd0aa295162178631c23ade335aad",
|
|
||||||
"checksum_type": "sha256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"message": ""
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
{
|
|
||||||
"result": [
|
|
||||||
{
|
|
||||||
"id": "redhat-21.0.8-jdk-linux-x64",
|
|
||||||
"archive_type": "tar.xz",
|
|
||||||
"distribution": "redhat",
|
|
||||||
"java_version": "21.0.8+9",
|
|
||||||
"release_status": "ga",
|
|
||||||
"operating_system": "linux",
|
|
||||||
"architecture": "x64",
|
|
||||||
"package_type": "jdk",
|
|
||||||
"directly_downloadable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "redhat-21.0.7-jdk-linux-x64",
|
|
||||||
"archive_type": "tar.xz",
|
|
||||||
"distribution": "redhat",
|
|
||||||
"java_version": "21.0.7+6",
|
|
||||||
"release_status": "ga",
|
|
||||||
"operating_system": "linux",
|
|
||||||
"architecture": "x64",
|
|
||||||
"package_type": "jdk",
|
|
||||||
"directly_downloadable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "redhat-17.0.16-jdk-linux-x64",
|
|
||||||
"archive_type": "tar.xz",
|
|
||||||
"distribution": "redhat",
|
|
||||||
"java_version": "17.0.16+8",
|
|
||||||
"release_status": "ga",
|
|
||||||
"operating_system": "linux",
|
|
||||||
"architecture": "x64",
|
|
||||||
"package_type": "jdk",
|
|
||||||
"directly_downloadable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "redhat-9-jdk-linux-x64",
|
|
||||||
"archive_type": "tar.xz",
|
|
||||||
"distribution": "redhat",
|
|
||||||
"java_version": "9+181",
|
|
||||||
"release_status": "ga",
|
|
||||||
"operating_system": "linux",
|
|
||||||
"architecture": "x64",
|
|
||||||
"package_type": "jdk",
|
|
||||||
"directly_downloadable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "redhat-21.0.8-jre-linux-x64",
|
|
||||||
"archive_type": "tar.xz",
|
|
||||||
"distribution": "redhat",
|
|
||||||
"java_version": "21.0.8+9",
|
|
||||||
"release_status": "ga",
|
|
||||||
"operating_system": "linux",
|
|
||||||
"architecture": "x64",
|
|
||||||
"package_type": "jre",
|
|
||||||
"directly_downloadable": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "redhat-17.0.16-jdk-windows-x64",
|
|
||||||
"archive_type": "zip",
|
|
||||||
"distribution": "redhat",
|
|
||||||
"java_version": "17.0.16+8",
|
|
||||||
"release_status": "ga",
|
|
||||||
"operating_system": "windows",
|
|
||||||
"architecture": "x64",
|
|
||||||
"package_type": "jdk",
|
|
||||||
"directly_downloadable": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"message": "6 package(s) found"
|
|
||||||
}
|
|
||||||
@@ -71,11 +71,8 @@ jest.unstable_mockModule('@actions/tool-cache', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
jest.unstable_mockModule('../../src/jdk-cache.js', () => ({
|
jest.unstable_mockModule('../../src/jdk-cache.js', () => ({
|
||||||
getJdkVerificationIdentity: jest.fn(
|
getJdkVerificationIdentity: jest.fn((verified: boolean, key?: string) =>
|
||||||
(verified: boolean, enforced: boolean, key?: string) =>
|
verified ? (key ? 'verified:custom' : 'verified:bundled') : 'unverified'
|
||||||
verified
|
|
||||||
? `${enforced ? 'enforced' : 'check-and-warn'}:${key ? 'custom' : 'bundled'}`
|
|
||||||
: 'disabled'
|
|
||||||
),
|
),
|
||||||
registerJdk: jest.fn(),
|
registerJdk: jest.fn(),
|
||||||
restoreJdk: jest.fn()
|
restoreJdk: jest.fn()
|
||||||
@@ -398,10 +395,8 @@ describe('setupJava', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(jdkCache.getJdkVerificationIdentity as jest.Mock).mockImplementation(
|
(jdkCache.getJdkVerificationIdentity as jest.Mock).mockImplementation(
|
||||||
(verified: boolean, enforced: boolean, key?: string) =>
|
(verified: boolean, key?: string) =>
|
||||||
verified
|
verified ? (key ? 'verified:custom' : 'verified:bundled') : 'unverified'
|
||||||
? `${enforced ? 'enforced' : 'check-and-warn'}:${key ? 'custom' : 'bundled'}`
|
|
||||||
: 'disabled'
|
|
||||||
);
|
);
|
||||||
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
||||||
spyGetToolcachePath.mockImplementation(
|
spyGetToolcachePath.mockImplementation(
|
||||||
@@ -831,7 +826,7 @@ describe('setupJava', () => {
|
|||||||
expect(jdkCache.registerJdk).toHaveBeenCalledWith(
|
expect(jdkCache.registerJdk).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
version: actualJavaVersion,
|
version: actualJavaVersion,
|
||||||
verification: 'disabled'
|
verification: 'unverified'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -891,7 +886,7 @@ describe('setupJava', () => {
|
|||||||
architecture: 'x86',
|
architecture: 'x86',
|
||||||
version: actualJavaVersion,
|
version: actualJavaVersion,
|
||||||
source: `some/random_url/java/${actualJavaVersion}`,
|
source: `some/random_url/java/${actualJavaVersion}`,
|
||||||
verification: 'disabled',
|
verification: 'unverified',
|
||||||
path: path.join(toolCachePath, 'Java_Empty_jdk', actualJavaVersion)
|
path: path.join(toolCachePath, 'Java_Empty_jdk', actualJavaVersion)
|
||||||
});
|
});
|
||||||
expect(downloadTool).not.toHaveBeenCalled();
|
expect(downloadTool).not.toHaveBeenCalled();
|
||||||
@@ -924,7 +919,7 @@ describe('setupJava', () => {
|
|||||||
architecture: 'x86',
|
architecture: 'x86',
|
||||||
version: actualJavaVersion,
|
version: actualJavaVersion,
|
||||||
source: `some/random_url/java/${actualJavaVersion}`,
|
source: `some/random_url/java/${actualJavaVersion}`,
|
||||||
verification: 'disabled',
|
verification: 'unverified',
|
||||||
path: path.join(toolCachePath, 'Java_Empty_jdk', actualJavaVersion)
|
path: path.join(toolCachePath, 'Java_Empty_jdk', actualJavaVersion)
|
||||||
};
|
};
|
||||||
expect(jdkCache.restoreJdk).toHaveBeenCalledWith(expectedIdentity);
|
expect(jdkCache.restoreJdk).toHaveBeenCalledWith(expectedIdentity);
|
||||||
@@ -1758,8 +1753,6 @@ describe('normalizeVersion', () => {
|
|||||||
['11.0.9.1', {version: '11.0.9+1', stable: true, latest: false}],
|
['11.0.9.1', {version: '11.0.9+1', stable: true, latest: false}],
|
||||||
['12.0.2.1.0', {version: '12.0.2+1.0', stable: true, latest: false}],
|
['12.0.2.1.0', {version: '12.0.2+1.0', stable: true, latest: false}],
|
||||||
['18.0.1.1-ea', {version: '18.0.1+1', stable: false, latest: false}],
|
['18.0.1.1-ea', {version: '18.0.1+1', stable: false, latest: false}],
|
||||||
['26.0.2.1+1', {version: '26.0.2+1.1', stable: true, latest: false}],
|
|
||||||
['25.0.4.1+1', {version: '25.0.4+1.1', stable: true, latest: false}],
|
|
||||||
['latest', {version: 'x', stable: true, latest: true}],
|
['latest', {version: 'x', stable: true, latest: true}],
|
||||||
['LATEST', {version: 'x', stable: true, latest: true}],
|
['LATEST', {version: 'x', stable: true, latest: true}],
|
||||||
[' Latest ', {version: 'x', stable: true, latest: true}]
|
[' Latest ', {version: 'x', stable: true, latest: true}]
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ describe('getJavaDistribution', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(['8', '23.x', '23.0.1.1', '23.0.1.1+1', '<24'])(
|
it.each(['8', '23.x', '23.0.1.1', '<24'])(
|
||||||
"rejects Temurin java-package 'jdk+jmods' for version %s",
|
"rejects Temurin java-package 'jdk+jmods' for version %s",
|
||||||
async version => {
|
async version => {
|
||||||
await expect(
|
await expect(
|
||||||
@@ -96,7 +96,7 @@ describe('getJavaDistribution', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
it.each(['24', '24.0.1.1', '25.0.4.1+1', '25-ea', '>=21', 'latest'])(
|
it.each(['24', '24.0.1.1', '25-ea', '>=21', 'latest'])(
|
||||||
"accepts Temurin java-package 'jdk+jmods' for version %s",
|
"accepts Temurin java-package 'jdk+jmods' for version %s",
|
||||||
async version => {
|
async version => {
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import type {IncomingMessage} from 'http';
|
|||||||
import {Readable} from 'stream';
|
import {Readable} from 'stream';
|
||||||
|
|
||||||
import manifestData from '../data/jetbrains.json' with {type: 'json'};
|
import manifestData from '../data/jetbrains.json' with {type: 'json'};
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
// Mock @actions/core before importing source modules that depend on it
|
// Mock @actions/core before importing source modules that depend on it
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
jest.unstable_mockModule('@actions/core', () => ({
|
||||||
@@ -77,10 +78,7 @@ function response(
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
jest.setTimeout(10_000);
|
|
||||||
|
|
||||||
let spyHttpClient: any;
|
let spyHttpClient: any;
|
||||||
let spyHttpClientHead: any;
|
|
||||||
let spyCoreError: any;
|
let spyCoreError: any;
|
||||||
const originalGitHubToken = process.env.GITHUB_TOKEN;
|
const originalGitHubToken = process.env.GITHUB_TOKEN;
|
||||||
|
|
||||||
@@ -93,10 +91,6 @@ describe('getAvailableVersions', () => {
|
|||||||
headers: {},
|
headers: {},
|
||||||
result: []
|
result: []
|
||||||
});
|
});
|
||||||
spyHttpClientHead = jest.spyOn(HttpClient.prototype, 'head');
|
|
||||||
spyHttpClientHead.mockResolvedValue({
|
|
||||||
message: {statusCode: 200}
|
|
||||||
} as any);
|
|
||||||
|
|
||||||
// Mock core.error to suppress error logs
|
// Mock core.error to suppress error logs
|
||||||
spyCoreError = core.error as jest.Mock;
|
spyCoreError = core.error as jest.Mock;
|
||||||
@@ -137,7 +131,9 @@ describe('getAvailableVersions', () => {
|
|||||||
const availableVersions = await distribution['getAvailableVersions']();
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
expect(availableVersions).not.toBeNull();
|
expect(availableVersions).not.toBeNull();
|
||||||
|
|
||||||
expect(availableVersions.length).toBe(manifestData.length + 2);
|
const length =
|
||||||
|
os.platform() === 'win32' ? manifestData.length : manifestData.length + 2;
|
||||||
|
expect(availableVersions.length).toBe(length);
|
||||||
}, 10_000);
|
}, 10_000);
|
||||||
|
|
||||||
it('continues a stable request after an all-prerelease page', async () => {
|
it('continues a stable request after an all-prerelease page', async () => {
|
||||||
@@ -360,7 +356,6 @@ describe('getAvailableVersions', () => {
|
|||||||
|
|
||||||
it('retries a GitHub rate limit using Retry-After', async () => {
|
it('retries a GitHub rate limit using Retry-After', async () => {
|
||||||
spyHttpClient.mockRestore();
|
spyHttpClient.mockRestore();
|
||||||
spyHttpClientHead.mockRestore();
|
|
||||||
const sleep = jest.fn(async () => undefined);
|
const sleep = jest.fn(async () => undefined);
|
||||||
const requestRaw = jest
|
const requestRaw = jest
|
||||||
.spyOn(HttpClient.prototype, 'requestRaw')
|
.spyOn(HttpClient.prototype, 'requestRaw')
|
||||||
|
|||||||
@@ -253,39 +253,6 @@ describe('findPackageForDownload', () => {
|
|||||||
expect(result.version).toBe(expected);
|
expect(result.version).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('compound build versions', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
distribution['getAvailableVersions'] = async () =>
|
|
||||||
['1', '1.1', '1.2', '1.10'].map(build => ({
|
|
||||||
featureVersion: 25,
|
|
||||||
interimVersion: 0,
|
|
||||||
updateVersion: 4,
|
|
||||||
buildVersion: 1,
|
|
||||||
version: `25.0.4+${build}`,
|
|
||||||
downloadUrl: `https://download.bell-sw.com/java/25.0.4+${build}/bellsoft-jdk25.0.4+${build}-macos-aarch64.tar.gz`
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['25.0.4+1.1', '25.0.4+1.1'],
|
|
||||||
['25.0.4+1', '25.0.4+1'],
|
|
||||||
['25.0.4', '25.0.4+1.10'],
|
|
||||||
['25', '25.0.4+1.10']
|
|
||||||
])('version is %s -> %s', async (input, expected) => {
|
|
||||||
const result = await distribution['findPackageForDownload'](input);
|
|
||||||
expect(result).toEqual({
|
|
||||||
version: expected,
|
|
||||||
url: `https://download.bell-sw.com/java/${expected}/bellsoft-jdk${expected}-macos-aarch64.tar.gz`
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not substitute a different compound build', async () => {
|
|
||||||
await expect(
|
|
||||||
distribution['findPackageForDownload']('25.0.4+1.3')
|
|
||||||
).rejects.toThrow(/No matching version found for SemVer/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error', async () => {
|
it('should throw an error', async () => {
|
||||||
await expect(distribution['findPackageForDownload']('17')).rejects.toThrow(
|
await expect(distribution['findPackageForDownload']('17')).rejects.toThrow(
|
||||||
/No matching version found for SemVer/
|
/No matching version found for SemVer/
|
||||||
@@ -368,36 +335,6 @@ describe('convertVersionToSemver', () => {
|
|||||||
buildVersion: 13
|
buildVersion: 13
|
||||||
},
|
},
|
||||||
'11.0.0+13'
|
'11.0.0+13'
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
version: '25.0.4+1.1',
|
|
||||||
featureVersion: 25,
|
|
||||||
interimVersion: 0,
|
|
||||||
updateVersion: 4,
|
|
||||||
buildVersion: 1
|
|
||||||
},
|
|
||||||
'25.0.4+1.1'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
version: '25+36',
|
|
||||||
featureVersion: 25,
|
|
||||||
interimVersion: 0,
|
|
||||||
updateVersion: 0,
|
|
||||||
buildVersion: 36
|
|
||||||
},
|
|
||||||
'25.0.0+36'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
version: '8u202',
|
|
||||||
featureVersion: 8,
|
|
||||||
interimVersion: 0,
|
|
||||||
updateVersion: 202,
|
|
||||||
buildVersion: 8
|
|
||||||
},
|
|
||||||
'8.0.202+8'
|
|
||||||
]
|
]
|
||||||
])('%s -> %s', (input, expected) => {
|
])('%s -> %s', (input, expected) => {
|
||||||
const actual = distributions['convertVersionToSemver']({
|
const actual = distributions['convertVersionToSemver']({
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ jest.unstable_mockModule('@actions/tool-cache', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
jest.unstable_mockModule('../../src/jdk-cache.js', () => ({
|
jest.unstable_mockModule('../../src/jdk-cache.js', () => ({
|
||||||
getJdkVerificationIdentity: jest.fn(() => 'disabled'),
|
getJdkVerificationIdentity: jest.fn(() => 'unverified'),
|
||||||
registerJdk: jest.fn(),
|
registerJdk: jest.fn(),
|
||||||
restoreJdk: jest.fn()
|
restoreJdk: jest.fn()
|
||||||
}));
|
}));
|
||||||
@@ -106,7 +106,7 @@ describe('setupJava', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(jdkCache.getJdkVerificationIdentity as jest.Mock).mockReturnValue(
|
(jdkCache.getJdkVerificationIdentity as jest.Mock).mockReturnValue(
|
||||||
'disabled'
|
'unverified'
|
||||||
);
|
);
|
||||||
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
||||||
spyGetToolcachePath.mockImplementation(
|
spyGetToolcachePath.mockImplementation(
|
||||||
@@ -283,7 +283,7 @@ describe('setupJava', () => {
|
|||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
distribution: 'jdkfile',
|
distribution: 'jdkfile',
|
||||||
version: actualJavaVersion,
|
version: actualJavaVersion,
|
||||||
verification: 'disabled'
|
verification: 'unverified'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -398,12 +398,13 @@ describe('downloadTool', () => {
|
|||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('verifies signatures by default', async () => {
|
it('verifies signature when enabled', async () => {
|
||||||
const signedDistribution = new MicrosoftDistributions({
|
const signedDistribution = new MicrosoftDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
architecture: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false,
|
||||||
|
verifySignature: true
|
||||||
});
|
});
|
||||||
|
|
||||||
await signedDistribution['downloadTool']({
|
await signedDistribution['downloadTool']({
|
||||||
@@ -444,64 +445,6 @@ describe('downloadTool', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('warns with key rotation recovery guidance when default verification fails', async () => {
|
|
||||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
|
||||||
const signedDistribution = new MicrosoftDistributions({
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
|
|
||||||
await signedDistribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz',
|
|
||||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(core.warning).toHaveBeenCalledWith(
|
|
||||||
expect.stringMatching(
|
|
||||||
/bad signature.*https:\/\/github\.com\/actions\/setup-java#download-integrity-and-signatures/
|
|
||||||
)
|
|
||||||
);
|
|
||||||
expect(spyExtractJdkFile).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails with recovery guidance when verification is explicitly enabled', async () => {
|
|
||||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
|
||||||
const signedDistribution = new MicrosoftDistributions({
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false,
|
|
||||||
verifySignature: true
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
signedDistribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz',
|
|
||||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
|
||||||
})
|
|
||||||
).rejects.toThrow(
|
|
||||||
/bad signature.*https:\/\/github\.com\/actions\/setup-java#download-integrity-and-signatures/
|
|
||||||
);
|
|
||||||
expect(spyExtractJdkFile).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('warns when the signature is missing during default verification', async () => {
|
|
||||||
await distribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz'
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(core.warning).toHaveBeenCalledWith(
|
|
||||||
"Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version 17.0.14+7."
|
|
||||||
);
|
|
||||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
|
||||||
expect(spyExtractJdkFile).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails when signature is missing and verification is enabled', async () => {
|
it('fails when signature is missing and verification is enabled', async () => {
|
||||||
const signedDistribution = new MicrosoftDistributions({
|
const signedDistribution = new MicrosoftDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
import {beforeEach, describe, expect, it, jest} from '@jest/globals';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
const mockReaddirSync = jest.fn();
|
|
||||||
const realFs = await import('fs');
|
|
||||||
jest.unstable_mockModule('fs', () => ({
|
|
||||||
...realFs,
|
|
||||||
default: {...realFs.default, readdirSync: mockReaddirSync},
|
|
||||||
readdirSync: mockReaddirSync
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
|
||||||
info: jest.fn(),
|
|
||||||
debug: jest.fn(),
|
|
||||||
isDebug: jest.fn(() => false),
|
|
||||||
startGroup: jest.fn(),
|
|
||||||
endGroup: jest.fn()
|
|
||||||
}));
|
|
||||||
|
|
||||||
const realUtil = await import('../../src/util.js');
|
|
||||||
const mockCacheJdkDir = jest.fn();
|
|
||||||
const mockExtractJdkFile = jest.fn();
|
|
||||||
const mockRenameWinArchive = jest.fn();
|
|
||||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
|
||||||
...realUtil,
|
|
||||||
cacheJdkDir: mockCacheJdkDir,
|
|
||||||
extractJdkFile: mockExtractJdkFile,
|
|
||||||
renameWinArchive: mockRenameWinArchive
|
|
||||||
}));
|
|
||||||
|
|
||||||
const {RedHatDistribution} =
|
|
||||||
await import('../../src/distributions/redhat/installer.js');
|
|
||||||
|
|
||||||
const release = {
|
|
||||||
version: '21.0.8+9',
|
|
||||||
url: 'https://developers.redhat.com/openjdk-21.tar.xz',
|
|
||||||
checksum: {
|
|
||||||
algorithm: 'sha256' as const,
|
|
||||||
value: 'a'.repeat(64)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const createDistribution = () =>
|
|
||||||
new RedHatDistribution({
|
|
||||||
version: '21',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.clearAllMocks();
|
|
||||||
mockReaddirSync.mockReturnValue(['jdk-21']);
|
|
||||||
mockExtractJdkFile.mockResolvedValue('/tmp/extracted');
|
|
||||||
mockCacheJdkDir.mockResolvedValue('/toolcache/Java_RedHat_jdk/21.0.8-9/x64');
|
|
||||||
mockRenameWinArchive.mockReturnValue('/tmp/download.zip');
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Red Hat package installation', () => {
|
|
||||||
it('extracts and caches Linux tar.xz archives', async () => {
|
|
||||||
const distribution = createDistribution();
|
|
||||||
distribution['downloadAndVerify'] = jest
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue('/tmp/download');
|
|
||||||
distribution['getArchiveType'] = () => 'tar.xz';
|
|
||||||
|
|
||||||
const result = await distribution['downloadTool'](release);
|
|
||||||
|
|
||||||
expect(mockExtractJdkFile).toHaveBeenCalledWith('/tmp/download', 'tar.xz');
|
|
||||||
expect(mockRenameWinArchive).not.toHaveBeenCalled();
|
|
||||||
expect(mockCacheJdkDir).toHaveBeenCalledWith(
|
|
||||||
path.join('/tmp/extracted', 'jdk-21'),
|
|
||||||
'Java_RedHat_jdk',
|
|
||||||
'21.0.8-9',
|
|
||||||
'x64'
|
|
||||||
);
|
|
||||||
expect(result).toEqual({
|
|
||||||
version: '21.0.8+9',
|
|
||||||
path: '/toolcache/Java_RedHat_jdk/21.0.8-9/x64'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renames downloaded Windows ZIP archives before extraction', async () => {
|
|
||||||
const distribution = createDistribution();
|
|
||||||
distribution['downloadAndVerify'] = jest
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue('/tmp/download');
|
|
||||||
distribution['getArchiveType'] = () => 'zip';
|
|
||||||
|
|
||||||
await distribution['downloadTool'](release);
|
|
||||||
|
|
||||||
expect(mockRenameWinArchive).toHaveBeenCalledWith('/tmp/download');
|
|
||||||
expect(mockExtractJdkFile).toHaveBeenCalledWith('/tmp/download.zip', 'zip');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails when the extracted archive is empty', async () => {
|
|
||||||
mockReaddirSync.mockReturnValue([]);
|
|
||||||
const distribution = createDistribution();
|
|
||||||
distribution['downloadAndVerify'] = jest
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue('/tmp/download');
|
|
||||||
distribution['getArchiveType'] = () => 'tar.xz';
|
|
||||||
|
|
||||||
await expect(distribution['downloadTool'](release)).rejects.toThrow(
|
|
||||||
'The Red Hat archive for Java 21.0.8+9 was empty.'
|
|
||||||
);
|
|
||||||
expect(mockCacheJdkDir).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,181 +0,0 @@
|
|||||||
import {afterEach, describe, expect, it, jest} from '@jest/globals';
|
|
||||||
import {HttpClient} from '@actions/http-client';
|
|
||||||
import packageDetails from '../data/redhat-package-details.json' with {type: 'json'};
|
|
||||||
import packages from '../data/redhat-packages.json' with {type: 'json'};
|
|
||||||
import {RedHatDistribution} from '../../src/distributions/redhat/installer.js';
|
|
||||||
|
|
||||||
const createDistribution = (
|
|
||||||
version: string,
|
|
||||||
packageType = 'jdk'
|
|
||||||
): RedHatDistribution => {
|
|
||||||
const distribution = new RedHatDistribution({
|
|
||||||
version,
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType,
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
distribution['getOperatingSystem'] = () => 'linux';
|
|
||||||
distribution['getArchiveType'] = () => 'tar.xz';
|
|
||||||
return distribution;
|
|
||||||
};
|
|
||||||
|
|
||||||
const mockDisco = (
|
|
||||||
packageResponse: unknown = packages,
|
|
||||||
detailsResponse: unknown = packageDetails
|
|
||||||
) =>
|
|
||||||
jest.spyOn(HttpClient.prototype, 'getJson').mockImplementation(async url => ({
|
|
||||||
result: url.includes('/packages?') ? packageResponse : detailsResponse,
|
|
||||||
statusCode: 200,
|
|
||||||
headers: {}
|
|
||||||
}));
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Red Hat package resolution', () => {
|
|
||||||
it('resolves the newest matching release and authoritative checksum', async () => {
|
|
||||||
const getJson = mockDisco();
|
|
||||||
const distribution = createDistribution('21');
|
|
||||||
|
|
||||||
const release = await distribution['findPackageForDownload']('21');
|
|
||||||
|
|
||||||
expect(release).toEqual({
|
|
||||||
version: '21.0.8+9',
|
|
||||||
url: packageDetails.result[0].direct_download_uri,
|
|
||||||
checksum: {
|
|
||||||
algorithm: 'sha256',
|
|
||||||
value: packageDetails.result[0].checksum,
|
|
||||||
source:
|
|
||||||
'https://api.foojay.io/disco/v3.0/ids/redhat-21.0.8-jdk-linux-x64'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
expect(getJson).toHaveBeenNthCalledWith(
|
|
||||||
1,
|
|
||||||
expect.stringContaining(
|
|
||||||
'distro=redhat&release_status=ga&operating_system=linux&architecture=x64&package_type=jdk&archive_type=tar.xz&directly_downloadable=true'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
expect(getJson).toHaveBeenNthCalledWith(
|
|
||||||
2,
|
|
||||||
'https://api.foojay.io/disco/v3.0/ids/redhat-21.0.8-jdk-linux-x64'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('normalizes feature-only Disco versions before matching', async () => {
|
|
||||||
mockDisco(undefined, {
|
|
||||||
result: [
|
|
||||||
{
|
|
||||||
...packageDetails.result[0],
|
|
||||||
direct_download_uri: 'https://developers.redhat.com/openjdk-9.tar.xz'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
message: ''
|
|
||||||
});
|
|
||||||
const distribution = createDistribution('9');
|
|
||||||
|
|
||||||
const release = await distribution['findPackageForDownload']('9');
|
|
||||||
|
|
||||||
expect(release.version).toBe('9.0.0+181');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('selects the requested package type', async () => {
|
|
||||||
const getJson = mockDisco();
|
|
||||||
const distribution = createDistribution('21', 'jre');
|
|
||||||
|
|
||||||
await distribution['findPackageForDownload']('21');
|
|
||||||
|
|
||||||
expect(getJson).toHaveBeenNthCalledWith(
|
|
||||||
1,
|
|
||||||
expect.stringContaining('package_type=jre')
|
|
||||||
);
|
|
||||||
expect(getJson).toHaveBeenNthCalledWith(
|
|
||||||
2,
|
|
||||||
'https://api.foojay.io/disco/v3.0/ids/redhat-21.0.8-jre-linux-x64'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('maps Windows to ZIP packages', async () => {
|
|
||||||
const getJson = mockDisco();
|
|
||||||
const distribution = createDistribution('17');
|
|
||||||
distribution['getOperatingSystem'] = () => 'windows';
|
|
||||||
distribution['getArchiveType'] = () => 'zip';
|
|
||||||
|
|
||||||
await distribution['findPackageForDownload']('17');
|
|
||||||
|
|
||||||
expect(getJson).toHaveBeenNthCalledWith(
|
|
||||||
1,
|
|
||||||
expect.stringContaining(
|
|
||||||
'operating_system=windows&architecture=x64&package_type=jdk&archive_type=zip'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
expect(getJson).toHaveBeenNthCalledWith(
|
|
||||||
2,
|
|
||||||
'https://api.foojay.io/disco/v3.0/ids/redhat-17.0.16-jdk-windows-x64'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('rejects Alpine before requesting glibc package metadata', async () => {
|
|
||||||
const getJson = mockDisco();
|
|
||||||
const distribution = new RedHatDistribution({
|
|
||||||
version: '21',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(() => distribution['getOperatingSystem'](true)).toThrow(
|
|
||||||
"Distribution 'redhat' does not support Alpine Linux because Red Hat portable archives require glibc."
|
|
||||||
);
|
|
||||||
expect(getJson).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('rejects early-access versions before requesting metadata', async () => {
|
|
||||||
const getJson = mockDisco();
|
|
||||||
const distribution = createDistribution('21-ea');
|
|
||||||
|
|
||||||
await expect(distribution['findPackageForDownload']('21')).rejects.toThrow(
|
|
||||||
'Early access versions are not supported'
|
|
||||||
);
|
|
||||||
expect(getJson).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('reports available versions when no release matches', async () => {
|
|
||||||
mockDisco();
|
|
||||||
const distribution = createDistribution('25');
|
|
||||||
|
|
||||||
await expect(distribution['findPackageForDownload']('25')).rejects.toThrow(
|
|
||||||
"No matching version found for SemVer '25'.\nDistribution: RedHat"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails when the package detail has no direct Red Hat URL', async () => {
|
|
||||||
mockDisco(packages, {result: [], message: ''});
|
|
||||||
const distribution = createDistribution('21');
|
|
||||||
|
|
||||||
await expect(distribution['findPackageForDownload']('21')).rejects.toThrow(
|
|
||||||
'returned no direct Red Hat download URL'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails when the package detail has no SHA-256 checksum', async () => {
|
|
||||||
mockDisco(packages, {
|
|
||||||
result: [{...packageDetails.result[0], checksum: ''}],
|
|
||||||
message: ''
|
|
||||||
});
|
|
||||||
const distribution = createDistribution('21');
|
|
||||||
|
|
||||||
await expect(distribution['findPackageForDownload']('21')).rejects.toThrow(
|
|
||||||
'returned no SHA-256 checksum'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails with a targeted error when package metadata is missing', async () => {
|
|
||||||
mockDisco(null);
|
|
||||||
const distribution = createDistribution('21');
|
|
||||||
|
|
||||||
await expect(distribution['findPackageForDownload']('21')).rejects.toThrow(
|
|
||||||
'Could not fetch Red Hat package metadata from Foojay Disco'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -73,7 +73,6 @@ jest.unstable_mockModule('../../src/util.js', () => ({
|
|||||||
jest.unstable_mockModule('../../src/gpg.js', () => ({
|
jest.unstable_mockModule('../../src/gpg.js', () => ({
|
||||||
importKey: jest.fn(),
|
importKey: jest.fn(),
|
||||||
removeGpgHome: jest.fn(),
|
removeGpgHome: jest.fn(),
|
||||||
isGpgAvailable: jest.fn(),
|
|
||||||
verifyPackageSignature: jest.fn()
|
verifyPackageSignature: jest.fn()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -293,8 +292,7 @@ describe('getAvailableVersions', () => {
|
|||||||
it.each([
|
it.each([
|
||||||
['amd64', 'x64'],
|
['amd64', 'x64'],
|
||||||
['arm', 'arm'],
|
['arm', 'arm'],
|
||||||
['arm64', 'aarch64'],
|
['arm64', 'aarch64']
|
||||||
['riscv64', 'riscv64']
|
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
@@ -378,97 +376,6 @@ describe('findPackageForDownload', () => {
|
|||||||
expect(resolvedVersion.version).toBe('16.0.2+7');
|
expect(resolvedVersion.version).toBe('16.0.2+7');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('OpenJDK patch (respin) versions', () => {
|
|
||||||
const makeRelease = (
|
|
||||||
semverVersion: string,
|
|
||||||
openjdkVersion: string,
|
|
||||||
versionData: Record<string, number>
|
|
||||||
) => ({
|
|
||||||
binaries: [
|
|
||||||
{
|
|
||||||
package: {
|
|
||||||
link: `https://example.com/${openjdkVersion}.tar.gz`,
|
|
||||||
checksum: `checksum-${openjdkVersion}`,
|
|
||||||
checksum_link: `https://example.com/${openjdkVersion}.sha256.txt`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
version_data: {
|
|
||||||
semver: semverVersion,
|
|
||||||
openjdk_version: openjdkVersion,
|
|
||||||
minor: 0,
|
|
||||||
...versionData
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const respinManifest = [
|
|
||||||
makeRelease('26.0.2+101', '26.0.2.1+1', {
|
|
||||||
major: 26,
|
|
||||||
security: 2,
|
|
||||||
patch: 1,
|
|
||||||
build: 1
|
|
||||||
}),
|
|
||||||
makeRelease('26.0.2+10', '26.0.2+10', {
|
|
||||||
major: 26,
|
|
||||||
security: 2,
|
|
||||||
build: 10
|
|
||||||
}),
|
|
||||||
makeRelease('25.0.4+101.0.LTS', '25.0.4.1+1-LTS', {
|
|
||||||
major: 25,
|
|
||||||
security: 4,
|
|
||||||
patch: 1,
|
|
||||||
build: 1
|
|
||||||
}),
|
|
||||||
makeRelease('25.0.4+7.0.LTS', '25.0.4+7-LTS', {
|
|
||||||
major: 25,
|
|
||||||
security: 4,
|
|
||||||
build: 7
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['26.0.2.1+1', '26.0.2+101'],
|
|
||||||
['26.0.2+10', '26.0.2+10'],
|
|
||||||
['26', '26.0.2+101'],
|
|
||||||
['26.0.2', '26.0.2+101'],
|
|
||||||
['25.0.4.1+1', '25.0.4+101.0.LTS'],
|
|
||||||
['25.0.4+7', '25.0.4+7.0.LTS'],
|
|
||||||
['25.0.4', '25.0.4+101.0.LTS']
|
|
||||||
])('%s resolves to %s', async (input, expected) => {
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: input,
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
distribution['getAvailableVersions'] = async () => respinManifest as any;
|
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](
|
|
||||||
distribution['version']
|
|
||||||
);
|
|
||||||
expect(resolvedVersion.version).toBe(expected);
|
|
||||||
expect(resolvedVersion).not.toHaveProperty('openjdkVersion');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not match a non-existent respin', async () => {
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: '26.0.2.2+1',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
distribution['getAvailableVersions'] = async () => respinManifest as any;
|
|
||||||
await expect(
|
|
||||||
distribution['findPackageForDownload'](distribution['version'])
|
|
||||||
).rejects.toThrow(/No matching version found for SemVer '26.0.2\+2.1'/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('version is found but binaries list is empty', async () => {
|
it('version is found but binaries list is empty', async () => {
|
||||||
const distribution = new TemurinDistribution(
|
const distribution = new TemurinDistribution(
|
||||||
{
|
{
|
||||||
@@ -530,7 +437,6 @@ describe('downloadTool', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyDownloadTool = tc.downloadTool as jest.Mock;
|
spyDownloadTool = tc.downloadTool as jest.Mock;
|
||||||
spyDownloadTool.mockResolvedValue('/tmp/jdk.tar.gz');
|
spyDownloadTool.mockResolvedValue('/tmp/jdk.tar.gz');
|
||||||
(gpg.isGpgAvailable as jest.Mock).mockResolvedValue(true);
|
|
||||||
spyVerifySignature = gpg.verifyPackageSignature as jest.Mock;
|
spyVerifySignature = gpg.verifyPackageSignature as jest.Mock;
|
||||||
spyVerifySignature.mockResolvedValue(undefined);
|
spyVerifySignature.mockResolvedValue(undefined);
|
||||||
spyExtractJdkFile = util.extractJdkFile as jest.Mock;
|
spyExtractJdkFile = util.extractJdkFile as jest.Mock;
|
||||||
@@ -551,13 +457,14 @@ describe('downloadTool', () => {
|
|||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('verifies signatures by default', async () => {
|
it('verifies signature when enabled', async () => {
|
||||||
const distribution = new TemurinDistribution(
|
const distribution = new TemurinDistribution(
|
||||||
{
|
{
|
||||||
version: '17',
|
version: '17',
|
||||||
architecture: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false,
|
||||||
|
verifySignature: true
|
||||||
},
|
},
|
||||||
TemurinImplementation.Hotspot
|
TemurinImplementation.Hotspot
|
||||||
);
|
);
|
||||||
@@ -575,154 +482,6 @@ describe('downloadTool', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not verify signatures when explicitly disabled', async () => {
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false,
|
|
||||||
verifySignature: false
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
|
|
||||||
await distribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz',
|
|
||||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('skips implicit signature verification when gpg is unavailable', async () => {
|
|
||||||
(gpg.isGpgAvailable as jest.Mock).mockResolvedValue(false);
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
distribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz',
|
|
||||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
|
||||||
})
|
|
||||||
).resolves.toEqual({version: '17.0.14+7', path: '/tmp/toolcache'});
|
|
||||||
|
|
||||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
|
||||||
expect(core.warning).toHaveBeenCalledWith(
|
|
||||||
"Input 'verify-signature' is enabled, but gpg is not available."
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails when signature verification is explicitly enabled without gpg', async () => {
|
|
||||||
(gpg.isGpgAvailable as jest.Mock).mockResolvedValue(false);
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false,
|
|
||||||
verifySignature: true
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
distribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz',
|
|
||||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
|
||||||
})
|
|
||||||
).rejects.toThrow(
|
|
||||||
"Input 'verify-signature' is enabled, but gpg is not available."
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('warns when implicit signature verification fails', async () => {
|
|
||||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
distribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz',
|
|
||||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
|
||||||
})
|
|
||||||
).resolves.toEqual({version: '17.0.14+7', path: '/tmp/toolcache'});
|
|
||||||
|
|
||||||
expect(core.warning).toHaveBeenCalledWith(
|
|
||||||
expect.stringContaining(
|
|
||||||
'https://github.com/actions/setup-java#download-integrity-and-signatures'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails when explicitly requested signature verification fails', async () => {
|
|
||||||
spyVerifySignature.mockRejectedValue(new Error('bad signature'));
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false,
|
|
||||||
verifySignature: true
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
distribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz',
|
|
||||||
signatureUrl: 'https://example.com/jdk.tar.gz.sig'
|
|
||||||
})
|
|
||||||
).rejects.toThrow(
|
|
||||||
/Failed to verify signature for Temurin version 17\.0\.14\+7.*bad signature.*https:\/\/github\.com\/actions\/setup-java#download-integrity-and-signatures/
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('warns when a signature is missing and verification is implicit', async () => {
|
|
||||||
const distribution = new TemurinDistribution(
|
|
||||||
{
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
},
|
|
||||||
TemurinImplementation.Hotspot
|
|
||||||
);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
distribution['downloadTool']({
|
|
||||||
version: '17.0.14+7',
|
|
||||||
url: 'https://example.com/jdk.tar.gz'
|
|
||||||
})
|
|
||||||
).resolves.toEqual({version: '17.0.14+7', path: '/tmp/toolcache'});
|
|
||||||
|
|
||||||
expect(core.warning).toHaveBeenCalledWith(
|
|
||||||
"Input 'verify-signature' is enabled, but no signature URL was found for Temurin version 17.0.14+7."
|
|
||||||
);
|
|
||||||
expect(spyVerifySignature).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('downloads and adds matching JMODs to the JDK', async () => {
|
it('downloads and adds matching JMODs to the JDK', async () => {
|
||||||
spyDownloadTool
|
spyDownloadTool
|
||||||
.mockResolvedValueOnce('/tmp/jdk.tar.gz')
|
.mockResolvedValueOnce('/tmp/jdk.tar.gz')
|
||||||
@@ -740,8 +499,7 @@ describe('downloadTool', () => {
|
|||||||
version: '25',
|
version: '25',
|
||||||
architecture: 'x64',
|
architecture: 'x64',
|
||||||
packageType: 'jdk+jmods',
|
packageType: 'jdk+jmods',
|
||||||
checkLatest: false,
|
checkLatest: false
|
||||||
verifySignature: false
|
|
||||||
},
|
},
|
||||||
TemurinImplementation.Hotspot
|
TemurinImplementation.Hotspot
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -334,69 +334,6 @@ describe('findPackageForDownload', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hotfix builds with a 4-segment java_version', () => {
|
|
||||||
// Mirrors the Azul Metadata API: 25.0.4.1 hotfix is reported as
|
|
||||||
// java_version=[25,0,4,1], openjdk_build_number=1 (SDKMAN '25.0.4+1.1').
|
|
||||||
const hotfixManifest = [
|
|
||||||
{
|
|
||||||
package_uuid: 'uuid-25.0.4+7',
|
|
||||||
name: 'zulu25.36.15-ca-jdk25.0.4-linux_x64.tar.gz',
|
|
||||||
download_url:
|
|
||||||
'https://cdn.azul.com/zulu/bin/zulu25.36.15-ca-jdk25.0.4-linux_x64.tar.gz',
|
|
||||||
java_version: [25, 0, 4],
|
|
||||||
openjdk_build_number: 7,
|
|
||||||
distro_version: [25, 36, 15, 0],
|
|
||||||
latest: false,
|
|
||||||
availability_type: 'ca'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
package_uuid: 'uuid-25.0.4+1.1',
|
|
||||||
name: 'zulu25.36.205-ca-jdk25.0.4.1-linux_x64.tar.gz',
|
|
||||||
download_url:
|
|
||||||
'https://cdn.azul.com/zulu/bin/zulu25.36.205-ca-jdk25.0.4.1-linux_x64.tar.gz',
|
|
||||||
java_version: [25, 0, 4, 1],
|
|
||||||
openjdk_build_number: 1,
|
|
||||||
distro_version: [25, 36, 205, 0],
|
|
||||||
latest: true,
|
|
||||||
availability_type: 'ca'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
package_uuid: 'uuid-25.0.3+9',
|
|
||||||
name: 'zulu25.34.17-ca-jdk25.0.3-linux_x64.tar.gz',
|
|
||||||
download_url:
|
|
||||||
'https://cdn.azul.com/zulu/bin/zulu25.34.17-ca-jdk25.0.3-linux_x64.tar.gz',
|
|
||||||
java_version: [25, 0, 3],
|
|
||||||
openjdk_build_number: 9,
|
|
||||||
distro_version: [25, 34, 17, 0],
|
|
||||||
latest: false,
|
|
||||||
availability_type: 'ca'
|
|
||||||
}
|
|
||||||
] as IZuluVersions[];
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['25.0.4+1.1', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
|
|
||||||
['25', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
|
|
||||||
['25.0.4', '25.0.4+1.1', 'uuid-25.0.4+1.1'],
|
|
||||||
['25.0.4+7', '25.0.4+7', 'uuid-25.0.4+7'],
|
|
||||||
['25.0.3', '25.0.3+9', 'uuid-25.0.3+9']
|
|
||||||
])('version is %s -> %s', async (input, expected, uuid) => {
|
|
||||||
const distribution = new ZuluDistribution({
|
|
||||||
version: input,
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
distribution['getAvailableVersions'] = async () => hotfixManifest;
|
|
||||||
const result = await distribution['findPackageForDownload'](
|
|
||||||
distribution['version']
|
|
||||||
);
|
|
||||||
expect(result.version).toBe(expected);
|
|
||||||
expect(result.url).toBe(
|
|
||||||
hotfixManifest.find(item => item.package_uuid === uuid)!.download_url
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error', async () => {
|
it('should throw an error', async () => {
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '18',
|
version: '18',
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
import {afterAll, beforeAll, describe, expect, it} from '@jest/globals';
|
|
||||||
import {spawnSync} from 'child_process';
|
|
||||||
import fs from 'fs';
|
|
||||||
import os from 'os';
|
|
||||||
import path from 'path';
|
|
||||||
import {fileURLToPath, pathToFileURL} from 'url';
|
|
||||||
|
|
||||||
const dist = fileURLToPath(new URL('../dist/', import.meta.url));
|
|
||||||
let tempDir: string;
|
|
||||||
let linkedDist: string;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-java-entrypoints-'));
|
|
||||||
linkedDist = path.join(tempDir, 'linked # dist');
|
|
||||||
fs.symlinkSync(dist, linkedDist, 'junction');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
fs.rmSync(tempDir, {recursive: true, force: true});
|
|
||||||
});
|
|
||||||
|
|
||||||
function execute(args: string[], input?: string) {
|
|
||||||
return spawnSync(process.execPath, args, {
|
|
||||||
encoding: 'utf8',
|
|
||||||
input,
|
|
||||||
timeout: 10000,
|
|
||||||
env: {
|
|
||||||
PATH: process.env.PATH,
|
|
||||||
SystemRoot: process.env.SystemRoot
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
describe.each([
|
|
||||||
['setup', 1, 'java-version or java-version-file input expected'],
|
|
||||||
['cleanup', 0, '']
|
|
||||||
] as const)('%s entrypoint', (name, exitCode, output) => {
|
|
||||||
it.each(['direct', 'symlink', 'preserved symlink'])(
|
|
||||||
'executes through a %s path',
|
|
||||||
mode => {
|
|
||||||
const entry = path.join(
|
|
||||||
mode === 'direct' ? dist : linkedDist,
|
|
||||||
name,
|
|
||||||
'index.js'
|
|
||||||
);
|
|
||||||
const args =
|
|
||||||
mode === 'preserved symlink'
|
|
||||||
? ['--preserve-symlinks-main', entry]
|
|
||||||
: [entry];
|
|
||||||
const result = execute(args);
|
|
||||||
|
|
||||||
expect(result.error).toBeUndefined();
|
|
||||||
expect(result.status).toBe(exitCode);
|
|
||||||
expect(result.stderr).toBe('');
|
|
||||||
expect(result.stdout).not.toContain('skipping the execution');
|
|
||||||
if (output) {
|
|
||||||
expect(result.stdout).toContain(output);
|
|
||||||
} else {
|
|
||||||
expect(result.stdout).toBe('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each(['eval', 'stdin', 'file'])(
|
|
||||||
'does not execute when imported from %s',
|
|
||||||
mode => {
|
|
||||||
const moduleUrl = pathToFileURL(path.join(dist, name, 'index.js')).href;
|
|
||||||
const source = `const {run} = await import(${JSON.stringify(moduleUrl)}); console.log(typeof run);`;
|
|
||||||
const importer = path.join(tempDir, `${name}-importer.mjs`);
|
|
||||||
fs.writeFileSync(importer, source);
|
|
||||||
const args =
|
|
||||||
mode === 'file'
|
|
||||||
? [importer]
|
|
||||||
: mode === 'eval'
|
|
||||||
? ['--input-type=module', '-e', source]
|
|
||||||
: ['--input-type=module', '-'];
|
|
||||||
const result = execute(args, mode === 'stdin' ? source : undefined);
|
|
||||||
|
|
||||||
expect(result.error).toBeUndefined();
|
|
||||||
expect(result.status).toBe(0);
|
|
||||||
expect(result.stderr).toBe('');
|
|
||||||
expect(result.stdout).toContain('skipping the execution');
|
|
||||||
expect(result.stdout).toContain('function');
|
|
||||||
expect(result.stdout).not.toContain('::error::');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
+1
-125
@@ -9,18 +9,10 @@ import {
|
|||||||
} from '@jest/globals';
|
} from '@jest/globals';
|
||||||
import {fileURLToPath} from 'url';
|
import {fileURLToPath} from 'url';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as os from 'os';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const mockTmpDir = jest.fn(os.tmpdir);
|
|
||||||
|
|
||||||
jest.unstable_mockModule('os', () => ({
|
|
||||||
...os,
|
|
||||||
default: {...os, tmpdir: mockTmpDir},
|
|
||||||
tmpdir: mockTmpDir
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.unstable_mockModule('@actions/exec', () => ({
|
jest.unstable_mockModule('@actions/exec', () => ({
|
||||||
exec: jest.fn()
|
exec: jest.fn()
|
||||||
@@ -42,7 +34,6 @@ describe('gpg tests', () => {
|
|||||||
await io.rmRF(tempDir);
|
await io.rmRF(tempDir);
|
||||||
await io.mkdirP(tempDir);
|
await io.mkdirP(tempDir);
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
mockTmpDir.mockImplementation(os.tmpdir);
|
|
||||||
(exec.exec as jest.Mock<any>).mockResolvedValue(0);
|
(exec.exec as jest.Mock<any>).mockResolvedValue(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -231,94 +222,6 @@ describe('gpg tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('verifyPackageSignature', () => {
|
describe('verifyPackageSignature', () => {
|
||||||
describe.each(['long', 'canonical macOS'])('%s TMPDIR', tempDirKind => {
|
|
||||||
afterEach(() => {
|
|
||||||
process.env['RUNNER_TEMP'] = tempDir;
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
'success',
|
|
||||||
'import failure',
|
|
||||||
'verification failure',
|
|
||||||
'gpgconf unavailable'
|
|
||||||
])(
|
|
||||||
'uses a short macOS home or RUNNER_TEMP elsewhere and cleans up after %s',
|
|
||||||
async outcome => {
|
|
||||||
const longRunnerTemp = path.join(
|
|
||||||
tempDir,
|
|
||||||
'long-runner-path-'.repeat(8)
|
|
||||||
);
|
|
||||||
const signaturePath = path.join(tempDir, 'jdk.tar.gz.sig');
|
|
||||||
const expectedParent =
|
|
||||||
process.platform === 'darwin' ? '/tmp' : longRunnerTemp;
|
|
||||||
let gpgHome = '';
|
|
||||||
process.env['RUNNER_TEMP'] = longRunnerTemp;
|
|
||||||
mockTmpDir.mockReturnValue(
|
|
||||||
tempDirKind === 'long'
|
|
||||||
? longRunnerTemp
|
|
||||||
: `/private/var/folders/ab/${'c'.repeat(31)}/T`
|
|
||||||
);
|
|
||||||
fs.mkdirSync(longRunnerTemp, {recursive: true});
|
|
||||||
fs.writeFileSync(signaturePath, 'signature');
|
|
||||||
(tc.downloadTool as jest.Mock<any>).mockResolvedValue(signaturePath);
|
|
||||||
(exec.exec as jest.Mock<any>).mockImplementation(
|
|
||||||
async (command: string, args: string[]) => {
|
|
||||||
gpgHome = path.join(expectedParent, path.posix.basename(args[1]));
|
|
||||||
expect(args[1]).toBe(gpg.toGpgPath(gpgHome));
|
|
||||||
if (command === 'gpgconf') {
|
|
||||||
expect(fs.existsSync(gpgHome)).toBe(true);
|
|
||||||
if (outcome === 'gpgconf unavailable') {
|
|
||||||
throw new Error('gpgconf unavailable');
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
expect(
|
|
||||||
Buffer.byteLength(path.join(gpgHome, 'S.gpg-agent.browser'))
|
|
||||||
).toBeLessThan(104);
|
|
||||||
}
|
|
||||||
expect(
|
|
||||||
fs.readFileSync(path.join(gpgHome, 'public-key-0.asc'), 'utf8')
|
|
||||||
).toBe('public key');
|
|
||||||
if (process.platform !== 'win32') {
|
|
||||||
expect(fs.statSync(gpgHome).mode & 0o777).toBe(0o700);
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(outcome === 'import failure' && args.includes('--import')) ||
|
|
||||||
(outcome === 'verification failure' &&
|
|
||||||
args.includes('--verify'))
|
|
||||||
) {
|
|
||||||
throw new Error(outcome);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const verification = gpg.verifyPackageSignature(
|
|
||||||
path.join(tempDir, 'jdk.tar.gz'),
|
|
||||||
'https://example.com/jdk.tar.gz.sig',
|
|
||||||
'public key'
|
|
||||||
);
|
|
||||||
if (outcome === 'success' || outcome === 'gpgconf unavailable') {
|
|
||||||
await verification;
|
|
||||||
} else {
|
|
||||||
await expect(verification).rejects.toThrow(outcome);
|
|
||||||
}
|
|
||||||
expect(exec.exec).toHaveBeenCalledTimes(
|
|
||||||
outcome === 'import failure' ? 2 : 3
|
|
||||||
);
|
|
||||||
expect(exec.exec).toHaveBeenLastCalledWith(
|
|
||||||
'gpgconf',
|
|
||||||
['--homedir', gpg.toGpgPath(gpgHome), '--kill', 'gpg-agent'],
|
|
||||||
{silent: true, ignoreReturnCode: true}
|
|
||||||
);
|
|
||||||
expect(fs.existsSync(gpgHome)).toBe(false);
|
|
||||||
expect(fs.existsSync(signaturePath)).toBe(false);
|
|
||||||
expect(fs.readdirSync(longRunnerTemp)).toEqual([]);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('imports bundled key and verifies package', async () => {
|
it('imports bundled key and verifies package', async () => {
|
||||||
const publicKeyContent =
|
const publicKeyContent =
|
||||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\ntest\n-----END PGP PUBLIC KEY BLOCK-----';
|
'-----BEGIN PGP PUBLIC KEY BLOCK-----\ntest\n-----END PGP PUBLIC KEY BLOCK-----';
|
||||||
@@ -342,7 +245,7 @@ describe('gpg tests', () => {
|
|||||||
expect.any(String),
|
expect.any(String),
|
||||||
'--batch',
|
'--batch',
|
||||||
'--import',
|
'--import',
|
||||||
expect.stringContaining('public-key-0.asc')
|
expect.stringContaining('public-key.asc')
|
||||||
],
|
],
|
||||||
expect.objectContaining({silent: true})
|
expect.objectContaining({silent: true})
|
||||||
);
|
);
|
||||||
@@ -360,32 +263,5 @@ describe('gpg tests', () => {
|
|||||||
expect.objectContaining({silent: true})
|
expect.objectContaining({silent: true})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('imports multiple bundled keys before verifying the package', async () => {
|
|
||||||
(tc.downloadTool as jest.Mock<any>).mockResolvedValue(
|
|
||||||
'/tmp/jdk.tar.gz.sig'
|
|
||||||
);
|
|
||||||
|
|
||||||
await gpg.verifyPackageSignature(
|
|
||||||
'/tmp/jdk.tar.gz',
|
|
||||||
'https://example.com/jdk.tar.gz.sig',
|
|
||||||
['public-key-a', 'public-key-b']
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(exec.exec).toHaveBeenNthCalledWith(
|
|
||||||
1,
|
|
||||||
'gpg',
|
|
||||||
[
|
|
||||||
'--homedir',
|
|
||||||
expect.any(String),
|
|
||||||
'--batch',
|
|
||||||
'--import',
|
|
||||||
expect.stringContaining('public-key-0.asc'),
|
|
||||||
expect.stringContaining('public-key-1.asc')
|
|
||||||
],
|
|
||||||
expect.objectContaining({silent: true})
|
|
||||||
);
|
|
||||||
expect(exec.exec).toHaveBeenCalledTimes(3);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
|
|
||||||
import fs from 'fs';
|
|
||||||
import {isMainModule} from '../src/is-main-module.js';
|
|
||||||
|
|
||||||
describe('main module detection', () => {
|
|
||||||
const originalArgv = process.argv;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
process.argv = [process.execPath, 'entrypoint.js'];
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
process.argv = originalArgv;
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([undefined, '-'])(
|
|
||||||
'skips filesystem access when argv[1] is %s',
|
|
||||||
entrypoint => {
|
|
||||||
process.argv =
|
|
||||||
entrypoint === undefined
|
|
||||||
? [process.execPath]
|
|
||||||
: [process.execPath, entrypoint];
|
|
||||||
const realpath = jest.spyOn(fs, 'realpathSync');
|
|
||||||
|
|
||||||
expect(isMainModule(import.meta.url)).toBe(false);
|
|
||||||
expect(realpath).not.toHaveBeenCalled();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each(['ENOENT', 'ENOTDIR'])(
|
|
||||||
'treats a non-file entrypoint returning %s as an import',
|
|
||||||
code => {
|
|
||||||
jest.spyOn(fs, 'realpathSync').mockImplementation(() => {
|
|
||||||
throw Object.assign(new Error('No file-based entrypoint'), {code});
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(isMainModule(import.meta.url)).toBe(false);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it('propagates unexpected filesystem errors', () => {
|
|
||||||
const error = Object.assign(new Error('Permission denied'), {
|
|
||||||
code: 'EACCES'
|
|
||||||
});
|
|
||||||
jest.spyOn(fs, 'realpathSync').mockImplementation(() => {
|
|
||||||
throw error;
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(() => isMainModule(import.meta.url)).toThrow(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -25,7 +25,6 @@ describe('Java platform capabilities', () => {
|
|||||||
['aarch64', 'aarch64'],
|
['aarch64', 'aarch64'],
|
||||||
['arm64', 'aarch64'],
|
['arm64', 'aarch64'],
|
||||||
['ppc64le', 'ppc64le'],
|
['ppc64le', 'ppc64le'],
|
||||||
['RiScV64', 'riscv64'],
|
|
||||||
['s390x', 's390x']
|
['s390x', 's390x']
|
||||||
])('normalizes architecture %s to %s', (input, expected) => {
|
])('normalizes architecture %s to %s', (input, expected) => {
|
||||||
expect(normalizeArchitecture(input)).toBe(expected);
|
expect(normalizeArchitecture(input)).toBe(expected);
|
||||||
@@ -69,12 +68,6 @@ describe('Java platform capabilities', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows Temurin on Linux riscv64', () => {
|
|
||||||
expect(validateJavaPlatform('temurin', 'linux', 'riscv64', '25')).toBe(
|
|
||||||
'riscv64'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('rejects OS-specific restrictions with a consistent diagnostic', () => {
|
it('rejects OS-specific restrictions with a consistent diagnostic', () => {
|
||||||
expect(() =>
|
expect(() =>
|
||||||
validateJavaPlatform('oracle', 'win32', 'arm64', '21')
|
validateJavaPlatform('oracle', 'win32', 'arm64', '21')
|
||||||
@@ -122,7 +115,6 @@ describe('Java platform capabilities', () => {
|
|||||||
'aarch64',
|
'aarch64',
|
||||||
'ppc64le',
|
'ppc64le',
|
||||||
'ppc64',
|
'ppc64',
|
||||||
'riscv64',
|
|
||||||
's390x'
|
's390x'
|
||||||
]) {
|
]) {
|
||||||
expect(content).toContain(architecture);
|
expect(content).toContain(architecture);
|
||||||
|
|||||||
+18
-45
@@ -43,7 +43,7 @@ const jdk = {
|
|||||||
architecture: 'x64',
|
architecture: 'x64',
|
||||||
version: '21.0.8+9',
|
version: '21.0.8+9',
|
||||||
source: 'sha256:abc123',
|
source: 'sha256:abc123',
|
||||||
verification: 'disabled',
|
verification: 'unverified',
|
||||||
path: '/toolcache/Java_temurin_jdk/21.0.8-9'
|
path: '/toolcache/Java_temurin_jdk/21.0.8-9'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,59 +117,32 @@ describe('JDK cache', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('separates verification policies and keys', () => {
|
it('separates unverified, bundled-key, and custom-key caches', () => {
|
||||||
const disabled = getJdkVerificationIdentity(false, false);
|
const unverified = getJdkVerificationIdentity(false);
|
||||||
const checkAndWarnBundled = getJdkVerificationIdentity(true, false);
|
const bundled = getJdkVerificationIdentity(true);
|
||||||
const enforcedBundled = getJdkVerificationIdentity(true, true);
|
|
||||||
const customA = getJdkVerificationIdentity(
|
const customA = getJdkVerificationIdentity(
|
||||||
true,
|
|
||||||
true,
|
true,
|
||||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nkey-a\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n'
|
'-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nkey-a\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n'
|
||||||
);
|
);
|
||||||
const customANormalized = getJdkVerificationIdentity(
|
const customANormalized = getJdkVerificationIdentity(
|
||||||
true,
|
|
||||||
true,
|
true,
|
||||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey-a\n-----END PGP PUBLIC KEY BLOCK-----'
|
'-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey-a\n-----END PGP PUBLIC KEY BLOCK-----'
|
||||||
);
|
);
|
||||||
const customB = getJdkVerificationIdentity(true, true, 'different-key');
|
const customB = getJdkVerificationIdentity(true, 'different-key');
|
||||||
const checkAndWarnCustomA = getJdkVerificationIdentity(
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\nkey-a\n-----END PGP PUBLIC KEY BLOCK-----'
|
|
||||||
);
|
|
||||||
const customList = getJdkVerificationIdentity(true, true, [
|
|
||||||
'key-a',
|
|
||||||
'key-b'
|
|
||||||
]);
|
|
||||||
const customListWithDifferentBoundary = getJdkVerificationIdentity(
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
['key-ak', 'ey-b']
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
expect(new Set([unverified, bundled, customA, customB])).toHaveProperty(
|
||||||
new Set([
|
'size',
|
||||||
disabled,
|
4
|
||||||
checkAndWarnBundled,
|
);
|
||||||
enforcedBundled,
|
|
||||||
customA,
|
|
||||||
customB
|
|
||||||
])
|
|
||||||
).toHaveProperty('size', 5);
|
|
||||||
expect(disabled).toBe('disabled');
|
|
||||||
expect(checkAndWarnBundled).toBe('check-and-warn:bundled');
|
|
||||||
expect(enforcedBundled).toBe('enforced:bundled');
|
|
||||||
expect(checkAndWarnCustomA).not.toBe(customA);
|
|
||||||
expect(customA).toBe(customANormalized);
|
expect(customA).toBe(customANormalized);
|
||||||
expect(customA).not.toContain('key-a');
|
expect(customA).not.toContain('key-a');
|
||||||
expect(customList).not.toBe(customListWithDifferentBoundary);
|
|
||||||
expect(
|
expect(
|
||||||
new Set(
|
new Set(
|
||||||
[disabled, checkAndWarnBundled, enforcedBundled, customA, customB].map(
|
[unverified, bundled, customA, customB].map(verification =>
|
||||||
verification => buildJdkCacheKey({...jdk, verification})
|
buildJdkCacheKey({...jdk, verification})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).toHaveProperty('size', 5);
|
).toHaveProperty('size', 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('restores and records an exact JDK cache hit', async () => {
|
it('restores and records an exact JDK cache hit', async () => {
|
||||||
@@ -237,12 +210,12 @@ describe('JDK cache', () => {
|
|||||||
|
|
||||||
it('saves only the key matching the installation that occupies the path', async () => {
|
it('saves only the key matching the installation that occupies the path', async () => {
|
||||||
const jdkPath = createInstallation();
|
const jdkPath = createInstallation();
|
||||||
const enforced = {...jdk, path: jdkPath, verification: 'enforced:bundled'};
|
const verified = {...jdk, path: jdkPath, verification: 'verified:bundled'};
|
||||||
const disabled = {...jdk, path: jdkPath};
|
const unverified = {...jdk, path: jdkPath};
|
||||||
|
|
||||||
registerJdk(enforced);
|
registerJdk(verified);
|
||||||
writeInstallation(jdkPath, 'force-downloaded-without-verification');
|
writeInstallation(jdkPath, 'force-downloaded-without-verification');
|
||||||
registerJdk(disabled);
|
registerJdk(unverified);
|
||||||
(core.getState as jest.Mock).mockReturnValue(lastState());
|
(core.getState as jest.Mock).mockReturnValue(lastState());
|
||||||
(cache.saveCache as jest.Mock).mockResolvedValue(1);
|
(cache.saveCache as jest.Mock).mockResolvedValue(1);
|
||||||
|
|
||||||
@@ -250,11 +223,11 @@ describe('JDK cache', () => {
|
|||||||
|
|
||||||
expect(cache.saveCache).not.toHaveBeenCalledWith(
|
expect(cache.saveCache).not.toHaveBeenCalledWith(
|
||||||
[jdkPath],
|
[jdkPath],
|
||||||
buildJdkCacheKey(enforced)
|
buildJdkCacheKey(verified)
|
||||||
);
|
);
|
||||||
expect(cache.saveCache).toHaveBeenCalledWith(
|
expect(cache.saveCache).toHaveBeenCalledWith(
|
||||||
[jdkPath],
|
[jdkPath],
|
||||||
buildJdkCacheKey(disabled)
|
buildJdkCacheKey(unverified)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ jest.unstable_mockModule('@actions/core', () => ({
|
|||||||
|
|
||||||
jest.unstable_mockModule('fs', () => ({
|
jest.unstable_mockModule('fs', () => ({
|
||||||
default: {
|
default: {
|
||||||
...jest.requireActual<typeof import('fs')>('fs'),
|
|
||||||
readFileSync: jest.fn()
|
readFileSync: jest.fn()
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ jest.unstable_mockModule('@actions/core', () => ({
|
|||||||
|
|
||||||
jest.unstable_mockModule('fs', () => ({
|
jest.unstable_mockModule('fs', () => ({
|
||||||
default: {
|
default: {
|
||||||
...jest.requireActual<typeof import('fs')>('fs'),
|
|
||||||
readFileSync: jest.fn()
|
readFileSync: jest.fn()
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -162,37 +161,6 @@ describe('setup action orchestration', () => {
|
|||||||
expect(factory.getJavaDistribution).not.toHaveBeenCalled();
|
expect(factory.getJavaDistribution).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
|
||||||
['temurin', undefined, undefined],
|
|
||||||
['zulu', undefined, undefined],
|
|
||||||
['temurin', false, false],
|
|
||||||
['zulu', true, true]
|
|
||||||
])(
|
|
||||||
'passes signature verification input for %s with explicit value %s as %s',
|
|
||||||
async (distribution, explicitValue, expectedValue) => {
|
|
||||||
inputs.set('distribution', distribution);
|
|
||||||
multilineInputs.set('java-version', ['21']);
|
|
||||||
if (explicitValue !== undefined) {
|
|
||||||
inputs.set('verify-signature', String(explicitValue));
|
|
||||||
booleanInputs.set('verify-signature', explicitValue);
|
|
||||||
}
|
|
||||||
(factory.getJavaDistribution as jest.Mock).mockReturnValue({
|
|
||||||
setupJava: jest.fn(async () => ({
|
|
||||||
version: '21.0.4+7',
|
|
||||||
path: '/opt/java/21'
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(factory.getJavaDistribution).toHaveBeenCalledWith(
|
|
||||||
distribution,
|
|
||||||
expect.objectContaining({verifySignature: expectedValue}),
|
|
||||||
''
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it('requires distribution when it cannot be inferred from the version file', async () => {
|
it('requires distribution when it cannot be inferred from the version file', async () => {
|
||||||
inputs.set('java-version-file', '.java-version');
|
inputs.set('java-version-file', '.java-version');
|
||||||
(fs.readFileSync as jest.Mock).mockReturnValue(Buffer.from('21'));
|
(fs.readFileSync as jest.Mock).mockReturnValue(Buffer.from('21'));
|
||||||
@@ -232,6 +200,7 @@ describe('setup action orchestration', () => {
|
|||||||
booleanInputs.set('check-latest', true);
|
booleanInputs.set('check-latest', true);
|
||||||
booleanInputs.set('force-download', true);
|
booleanInputs.set('force-download', true);
|
||||||
booleanInputs.set('set-default', false);
|
booleanInputs.set('set-default', false);
|
||||||
|
booleanInputs.set('verify-signature', true);
|
||||||
inputs.set('verify-signature-public-key', 'public-key');
|
inputs.set('verify-signature-public-key', 'public-key');
|
||||||
(fs.readFileSync as jest.Mock).mockReturnValue(
|
(fs.readFileSync as jest.Mock).mockReturnValue(
|
||||||
Buffer.from('java=21.0.5-tem')
|
Buffer.from('java=21.0.5-tem')
|
||||||
@@ -263,7 +232,7 @@ describe('setup action orchestration', () => {
|
|||||||
forceDownload: true,
|
forceDownload: true,
|
||||||
cacheJdk: false,
|
cacheJdk: false,
|
||||||
setDefault: false,
|
setDefault: false,
|
||||||
verifySignature: undefined,
|
verifySignature: true,
|
||||||
verifySignaturePublicKey: 'public-key'
|
verifySignaturePublicKey: 'public-key'
|
||||||
},
|
},
|
||||||
'/tmp/java.tar.gz'
|
'/tmp/java.tar.gz'
|
||||||
|
|||||||
@@ -405,18 +405,6 @@ describe('extractJdkFile', () => {
|
|||||||
expect(io.which).not.toHaveBeenCalled();
|
expect(io.which).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('extracts xz-compressed tarballs with xz tar flags', async () => {
|
|
||||||
(tc.extractTar as jest.Mock).mockResolvedValue('/extracted' as never);
|
|
||||||
|
|
||||||
await expect(extractJdkFile('/tmp/jdk.tar.xz')).resolves.toBe('/extracted');
|
|
||||||
expect(tc.extractTar).toHaveBeenCalledWith(
|
|
||||||
'/tmp/jdk.tar.xz',
|
|
||||||
undefined,
|
|
||||||
'xJ'
|
|
||||||
);
|
|
||||||
expect(io.which).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('uses the bundled tar.exe for zip archives on Windows', async () => {
|
it('uses the bundled tar.exe for zip archives on Windows', async () => {
|
||||||
setPlatform('win32');
|
setPlatform('win32');
|
||||||
const systemRoot = path.join(workDir, 'Windows');
|
const systemRoot = path.join(workDir, 'Windows');
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ const core = await import('@actions/core');
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
convertVersionToSemver,
|
convertVersionToSemver,
|
||||||
normalizeJavaVersionToSemver,
|
|
||||||
getNextPageUrlFromLinkHeader,
|
getNextPageUrlFromLinkHeader,
|
||||||
getVersionFromFileContent,
|
getVersionFromFileContent,
|
||||||
isVersionSatisfies,
|
isVersionSatisfies,
|
||||||
@@ -189,22 +188,6 @@ describe('convertVersionToSemver', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('normalizeJavaVersionToSemver', () => {
|
|
||||||
it.each([
|
|
||||||
['17', '17'],
|
|
||||||
['17.0.8', '17.0.8'],
|
|
||||||
['17.0.8+7', '17.0.8+7'],
|
|
||||||
['11.0.9.1', '11.0.9+1'],
|
|
||||||
['12.0.2.1.0', '12.0.2+1.0'],
|
|
||||||
['26.0.2.1+1', '26.0.2+1.1'],
|
|
||||||
['17.0.8.1+1080.1', '17.0.8+1.1080.1'],
|
|
||||||
['>=11.0.9.1', '>=11.0.9.1'],
|
|
||||||
['17.x', '17.x']
|
|
||||||
])('%s -> %s', (input: string, expected: string) => {
|
|
||||||
expect(normalizeJavaVersionToSemver(input)).toBe(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getNextPageUrlFromLinkHeader', () => {
|
describe('getNextPageUrlFromLinkHeader', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
@@ -280,7 +263,6 @@ describe('validatePaginationUrl', () => {
|
|||||||
describe('getVersionFromFileContent', () => {
|
describe('getVersionFromFileContent', () => {
|
||||||
describe('.sdkmanrc', () => {
|
describe('.sdkmanrc', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['java=26-tem', '26', 'temurin'],
|
|
||||||
['java=11.0.20.1-tem', '11.0.20', 'temurin'],
|
['java=11.0.20.1-tem', '11.0.20', 'temurin'],
|
||||||
['java = 11.0.20.1-tem', '11.0.20', 'temurin'],
|
['java = 11.0.20.1-tem', '11.0.20', 'temurin'],
|
||||||
['java=11.0.20.1-tem # a comment in sdkmanrc', '11.0.20', 'temurin'],
|
['java=11.0.20.1-tem # a comment in sdkmanrc', '11.0.20', 'temurin'],
|
||||||
@@ -293,8 +275,6 @@ describe('getVersionFromFileContent', () => {
|
|||||||
['java=21.0.5-graal', '21.0.5', 'graalvm'],
|
['java=21.0.5-graal', '21.0.5', 'graalvm'],
|
||||||
['java=17.0.9-graalce', '17.0.9', 'graalvm'],
|
['java=17.0.9-graalce', '17.0.9', 'graalvm'],
|
||||||
['java=11.0.25-librca', '11.0.25', 'liberica'],
|
['java=11.0.25-librca', '11.0.25', 'liberica'],
|
||||||
['java=25.0.4+1.1-librca', '25.0.4+1.1', 'liberica'],
|
|
||||||
['java=25.0.4+1.1-zulu', '25.0.4+1.1', 'zulu'],
|
|
||||||
['java=11.0.25-ms', '11.0.25', 'microsoft'],
|
['java=11.0.25-ms', '11.0.25', 'microsoft'],
|
||||||
['java=21.0.5-oracle', '21.0.5', 'oracle'],
|
['java=21.0.5-oracle', '21.0.5', 'oracle'],
|
||||||
['java=11.0.25-sapmchn', '11.0.25', 'sapmachine'],
|
['java=11.0.25-sapmchn', '11.0.25', 'sapmachine'],
|
||||||
|
|||||||
+4
-17
@@ -17,7 +17,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: 'jdk'
|
default: 'jdk'
|
||||||
architecture:
|
architecture:
|
||||||
description: "The architecture of the package (`x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, `riscv64`, or `s390x`). Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized to `x86`, `x64`, `armv7`, and `aarch64`. Supported values vary by distribution and operating system. Defaults to the action runner's architecture."
|
description: "The architecture of the package (`x86`, `x64`, `armv7`, `aarch64`, `ppc64le`, `ppc64`, or `s390x`). Aliases `ia32`, `amd64`, `arm`, and `arm64` are normalized to `x86`, `x64`, `armv7`, and `aarch64`. Supported values vary by distribution and operating system. Defaults to the action runner's architecture."
|
||||||
required: false
|
required: false
|
||||||
jdk-file:
|
jdk-file:
|
||||||
description: 'Path to where the compressed JDK is located'
|
description: 'Path to where the compressed JDK is located'
|
||||||
@@ -39,10 +39,11 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: true
|
default: true
|
||||||
verify-signature:
|
verify-signature:
|
||||||
description: 'Check downloaded Java package signatures when supported by the selected distribution. When omitted, failures produce warnings. Explicitly setting this to true enforces verification and makes failures fatal, including failures caused by an unexpected vendor signing-key rotation.'
|
description: 'Verify downloaded Java package signatures when supported by the selected distribution'
|
||||||
required: false
|
required: false
|
||||||
|
default: false
|
||||||
verify-signature-public-key:
|
verify-signature-public-key:
|
||||||
description: 'One or more ASCII-armored GPG public keys used to verify downloaded package signatures. Concatenate multiple armored key blocks. Custom keys replace the bundled keys for the selected distribution.'
|
description: 'ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.'
|
||||||
required: false
|
required: false
|
||||||
server-id:
|
server-id:
|
||||||
description: 'ID of the distributionManagement repository in the pom.xml
|
description: 'ID of the distributionManagement repository in the pom.xml
|
||||||
@@ -63,20 +64,6 @@ inputs:
|
|||||||
server-password:
|
server-password:
|
||||||
description: 'Deprecated alias for server-password-env-var'
|
description: 'Deprecated alias for server-password-env-var'
|
||||||
required: false
|
required: false
|
||||||
mvn-server-credentials:
|
|
||||||
description: 'Multiline list of Maven server credentials in the format `server-id:USERNAME_ENV:PASSWORD_ENV`. When set, replaces the single server configured by server-id, server-username-env-var, and server-password-env-var.'
|
|
||||||
required: false
|
|
||||||
mvn-repositories:
|
|
||||||
description: 'Multiline list of Maven dependency repositories in the format `repository-id:repository-url:snapshots-enabled`.'
|
|
||||||
required: false
|
|
||||||
mvn-repositories-include-central:
|
|
||||||
description: 'Include Maven Central in the generated dependency repositories profile. When false, Central is disabled unless an explicit repository with ID `central` is declared.'
|
|
||||||
required: false
|
|
||||||
default: true
|
|
||||||
mvn-repositories-prioritize-central:
|
|
||||||
description: 'Place Maven Central before custom dependency repositories. Has no effect when Maven Central is excluded.'
|
|
||||||
required: false
|
|
||||||
default: true
|
|
||||||
settings-path:
|
settings-path:
|
||||||
description: 'Path to where the settings.xml file will be written. Default is ~/.m2.'
|
description: 'Path to where the settings.xml file will be written. Default is ~/.m2.'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
Vendored
+6
-15
@@ -122,25 +122,16 @@ function getInstallationIdentity(jdkPath, architecture) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getJdkVerificationIdentity(verifySignature, enforceSignatureVerification, publicKey) {
|
function getJdkVerificationIdentity(verifySignature, publicKey) {
|
||||||
if (!verifySignature) {
|
if (!verifySignature) {
|
||||||
return 'disabled';
|
return 'unverified';
|
||||||
}
|
}
|
||||||
const verificationPolicy = enforceSignatureVerification
|
|
||||||
? 'enforced'
|
|
||||||
: 'check-and-warn';
|
|
||||||
if (!publicKey) {
|
if (!publicKey) {
|
||||||
return `${verificationPolicy}:bundled`;
|
return 'verified:bundled';
|
||||||
}
|
}
|
||||||
const publicKeys = Array.isArray(publicKey) ? publicKey : [publicKey];
|
const normalizedKey = publicKey.replace(/\r\n?/g, '\n').trim();
|
||||||
const normalizedKeys = publicKeys.map(key => key.replace(/\r\n?/g, '\n').trim());
|
const fingerprint = createHash('sha256').update(normalizedKey).digest('hex');
|
||||||
const fingerprintSource = Array.isArray(publicKey)
|
return `verified:custom:sha256:${fingerprint}`;
|
||||||
? normalizedKeys.map(key => `${Buffer.byteLength(key)}:${key}`).join('')
|
|
||||||
: normalizedKeys[0];
|
|
||||||
const fingerprint = createHash('sha256')
|
|
||||||
.update(fingerprintSource)
|
|
||||||
.digest('hex');
|
|
||||||
return `${verificationPolicy}:custom:sha256:${fingerprint}`;
|
|
||||||
}
|
}
|
||||||
async function saveJdkCaches() {
|
async function saveJdkCaches() {
|
||||||
const state = lib_core/* getState */.Gu(STATE_JDK_CACHES);
|
const state = lib_core/* getState */.Gu(STATE_JDK_CACHES);
|
||||||
|
|||||||
Vendored
+25
-216
@@ -18360,102 +18360,9 @@ function readAttributeStr(xmlData, i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Walk `attrStr` once, left to right, splitting it into attribute tokens.
|
* Select all the attributes whether valid or invalid.
|
||||||
*
|
|
||||||
* This replaces a regex that used to do the same job
|
|
||||||
* (`(\s*)([^\s=]+)(\s*=)?(\s*(['"])(([\s\S])*?)\5)?`). That regex led with an
|
|
||||||
* optional whitespace group followed by a required "non-whitespace" group.
|
|
||||||
* On a long run of whitespace that never resolves into an attribute name
|
|
||||||
* (e.g. a tag with thousands of trailing spaces before `>`), the engine
|
|
||||||
* backtracks the whitespace group one character at a time before giving up
|
|
||||||
* and moving to the next starting position — one full backtrack per
|
|
||||||
* position, which is quadratic in the length of the run.
|
|
||||||
*
|
|
||||||
* A single forward-only scan can never backtrack, so it can't be made slow
|
|
||||||
* this way no matter how much whitespace the input contains — it's always
|
|
||||||
* proportional to the length of the string, once.
|
|
||||||
*
|
|
||||||
* Each returned token mirrors the shape the old regex match array had, so
|
|
||||||
* the validation logic below (which reads token[1]..token[6]) didn't need
|
|
||||||
* to change:
|
|
||||||
* token.startIndex - where this token begins in attrStr
|
|
||||||
* token[1] - leading whitespace before the name
|
|
||||||
* token[2] - the attribute name
|
|
||||||
* token[3] - whitespace + '=' if present, else undefined
|
|
||||||
* token[4] - marker (any defined value) if a quoted value was found
|
|
||||||
* token[5] - the quote character used ('"' or "'")
|
|
||||||
* token[6] - the value's text, without the surrounding quotes
|
|
||||||
*
|
|
||||||
* A malformed leading character (e.g. a stray '=' with no name before it)
|
|
||||||
* is simply skipped over, one character at a time — the same outcome the
|
|
||||||
* old regex produced by failing to match at that position and retrying at
|
|
||||||
* the next one.
|
|
||||||
*/
|
*/
|
||||||
function scanAttributeTokens(attrStr) {
|
const validAttrStrRegxp = new RegExp('(\\s*)([^\\s=]+)(\\s*=)?(\\s*([\'"])(([\\s\\S])*?)\\5)?', 'g');
|
||||||
const tokens = [];
|
|
||||||
const len = attrStr.length;
|
|
||||||
let i = 0;
|
|
||||||
|
|
||||||
while (i < len) {
|
|
||||||
const tokenStart = i;
|
|
||||||
|
|
||||||
// Leading whitespace before the name.
|
|
||||||
while (i < len && isWhiteSpace(attrStr[i])) i++;
|
|
||||||
if (i >= len) break; // trailing whitespace only — nothing left to read
|
|
||||||
|
|
||||||
if (attrStr[i] === '=') {
|
|
||||||
// No name before this '=' — not a valid attribute start. Move past
|
|
||||||
// just this one character and try again from the next position.
|
|
||||||
i = tokenStart + 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const leadingWs = attrStr.slice(tokenStart, i);
|
|
||||||
|
|
||||||
// Attribute name — everything up to the next whitespace or '='.
|
|
||||||
const nameStart = i;
|
|
||||||
while (i < len && !isWhiteSpace(attrStr[i]) && attrStr[i] !== '=') i++;
|
|
||||||
const name = attrStr.slice(nameStart, i);
|
|
||||||
|
|
||||||
// Optional whitespace + '='.
|
|
||||||
let equalsGroup; // whitespace + '=' text, or undefined if absent
|
|
||||||
let j = i;
|
|
||||||
while (j < len && isWhiteSpace(attrStr[j])) j++;
|
|
||||||
if (j < len && attrStr[j] === '=') {
|
|
||||||
equalsGroup = attrStr.slice(i, j + 1);
|
|
||||||
i = j + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optional whitespace + quoted value.
|
|
||||||
let quoteChar;
|
|
||||||
let value;
|
|
||||||
let k = i;
|
|
||||||
while (k < len && isWhiteSpace(attrStr[k])) k++;
|
|
||||||
if (k < len && (attrStr[k] === '"' || attrStr[k] === "'")) {
|
|
||||||
const valueStart = k + 1;
|
|
||||||
const closeIdx = attrStr.indexOf(attrStr[k], valueStart);
|
|
||||||
if (closeIdx !== -1) {
|
|
||||||
quoteChar = attrStr[k];
|
|
||||||
value = attrStr.slice(valueStart, closeIdx);
|
|
||||||
i = closeIdx + 1;
|
|
||||||
}
|
|
||||||
// No closing quote found anywhere in the rest of the string — leave
|
|
||||||
// quoteChar/value undefined, same as the old regex's group failing
|
|
||||||
// to match a backreference-less run.
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = { startIndex: tokenStart };
|
|
||||||
token[1] = leadingWs;
|
|
||||||
token[2] = name;
|
|
||||||
token[3] = equalsGroup;
|
|
||||||
token[4] = quoteChar !== undefined ? true : undefined;
|
|
||||||
token[5] = quoteChar;
|
|
||||||
token[6] = value;
|
|
||||||
tokens.push(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tokens;
|
|
||||||
}
|
|
||||||
|
|
||||||
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
|
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
|
||||||
|
|
||||||
@@ -18464,7 +18371,7 @@ function validateAttributeString(attrStr, options) {
|
|||||||
|
|
||||||
//if(attrStr.trim().length === 0) return true; //empty string
|
//if(attrStr.trim().length === 0) return true; //empty string
|
||||||
|
|
||||||
const matches = scanAttributeTokens(attrStr);
|
const matches = getAllMatches(attrStr, validAttrStrRegxp);
|
||||||
const attrNames = {};
|
const attrNames = {};
|
||||||
|
|
||||||
for (let i = 0; i < matches.length; i++) {
|
for (let i = 0; i < matches.length; i++) {
|
||||||
@@ -18566,6 +18473,7 @@ function getLineNumberForPosition(xmlData, index) {
|
|||||||
function getPositionFromMatch(match) {
|
function getPositionFromMatch(match) {
|
||||||
return match.startIndex + match[1].length;
|
return match.startIndex + match[1].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./node_modules/fast-xml-parser/src/fxp.js
|
;// CONCATENATED MODULE: ./node_modules/fast-xml-parser/src/fxp.js
|
||||||
|
|
||||||
|
|
||||||
@@ -18772,26 +18680,12 @@ class XmlNode {
|
|||||||
this.child.push({ [node.tagname]: node.child });
|
this.child.push({ [node.tagname]: node.child });
|
||||||
}
|
}
|
||||||
// if requested, add the startIndex
|
// if requested, add the startIndex
|
||||||
this.addStartIndex(startIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
addStartIndex(startIndex) {
|
|
||||||
if (startIndex !== undefined) {
|
if (startIndex !== undefined) {
|
||||||
// Note: for now we just overwrite the metadata. If we had more complex metadata,
|
// Note: for now we just overwrite the metadata. If we had more complex metadata,
|
||||||
// we might need to do an object append here: metadata = { ...metadata, startIndex }
|
// we might need to do an object append here: metadata = { ...metadata, startIndex }
|
||||||
this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
|
this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addEndIndex(endIndex) {
|
|
||||||
const lastChild = this.child[this.child.length - 1];
|
|
||||||
// endIndex is write-once: when updateTag drops a node, the last child is a
|
|
||||||
// previously completed sibling whose endIndex must not be overwritten
|
|
||||||
if (lastChild !== undefined && lastChild[METADATA_SYMBOL] !== undefined
|
|
||||||
&& lastChild[METADATA_SYMBOL].endIndex === undefined) {
|
|
||||||
lastChild[METADATA_SYMBOL].endIndex = endIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** symbol used for metadata */
|
/** symbol used for metadata */
|
||||||
static getMetaDataSymbol() {
|
static getMetaDataSymbol() {
|
||||||
return METADATA_SYMBOL;
|
return METADATA_SYMBOL;
|
||||||
@@ -18824,23 +18718,8 @@ class DocTypeReader {
|
|||||||
i = i + 9;
|
i = i + 9;
|
||||||
let angleBracketsCount = 1;
|
let angleBracketsCount = 1;
|
||||||
let hasBody = false, comment = false;
|
let hasBody = false, comment = false;
|
||||||
let quoteChar = null; // tracks an open SYSTEM/PUBLIC literal before the '[' body
|
|
||||||
let exp = "";
|
let exp = "";
|
||||||
for (; i < xmlData.length; i++) {
|
for (; i < xmlData.length; i++) {
|
||||||
// Inside a quoted external-identifier literal — XML allows '<'
|
|
||||||
// and '>' as plain data here, so they must not be interpreted
|
|
||||||
// as DOCTYPE structure until the matching quote closes.
|
|
||||||
if (quoteChar !== null) {
|
|
||||||
if (xmlData[i] === quoteChar) quoteChar = null;
|
|
||||||
exp += xmlData[i];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!hasBody && !comment && (xmlData[i] === '"' || xmlData[i] === "'")) {
|
|
||||||
quoteChar = xmlData[i];
|
|
||||||
exp += xmlData[i];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xmlData[i] === '<' && !comment) { //Determine the tag type
|
if (xmlData[i] === '<' && !comment) { //Determine the tag type
|
||||||
if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
|
if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
|
||||||
i += 7;
|
i += 7;
|
||||||
@@ -18895,7 +18774,7 @@ class DocTypeReader {
|
|||||||
exp += xmlData[i];
|
exp += xmlData[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quoteChar !== null || angleBracketsCount !== 0) {
|
if (angleBracketsCount !== 0) {
|
||||||
throw new Error(`Unclosed DOCTYPE`);
|
throw new Error(`Unclosed DOCTYPE`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -19610,11 +19489,7 @@ function resolveEnotation(str, trimmedStr, options) {
|
|||||||
*/
|
*/
|
||||||
function trimZeros(numStr) {
|
function trimZeros(numStr) {
|
||||||
if (numStr && numStr.indexOf(".") !== -1) {//float
|
if (numStr && numStr.indexOf(".") !== -1) {//float
|
||||||
//remove ending zeros without the O(n^2) backtracking that /0+$/ hits
|
numStr = numStr.replace(/0+$/, ""); //remove ending zeros
|
||||||
//when the string doesn't end in 0 but has a long internal zero-run
|
|
||||||
let end = numStr.length;
|
|
||||||
while (end > 0 && numStr.charCodeAt(end - 1) === 48 /* '0' */) end--;
|
|
||||||
numStr = numStr.slice(0, end);
|
|
||||||
if (numStr === ".") numStr = "0";
|
if (numStr === ".") numStr = "0";
|
||||||
else if (numStr[0] === ".") numStr = "0" + numStr;
|
else if (numStr[0] === ".") numStr = "0" + numStr;
|
||||||
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
|
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
|
||||||
@@ -23090,12 +22965,7 @@ const parseXml = function (xmlData) {
|
|||||||
this.matcher.pop();
|
this.matcher.pop();
|
||||||
this.isCurrentNodeStopNode = false; // Reset flag when closing tag
|
this.isCurrentNodeStopNode = false; // Reset flag when closing tag
|
||||||
|
|
||||||
//a closing tag with no matching opening tag leaves the stack empty
|
currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope
|
||||||
currentNode = this.tagsNodeStack.pop() || xmlObj;//avoid recursion, set the parent tag scope
|
|
||||||
|
|
||||||
if (options.captureMetaData && currentNode) {
|
|
||||||
currentNode.addEndIndex(closeIndex + 1);
|
|
||||||
}
|
|
||||||
textData = "";
|
textData = "";
|
||||||
i = closeIndex;
|
i = closeIndex;
|
||||||
} else if (c1 === 63) { //'?'
|
} else if (c1 === 63) { //'?'
|
||||||
@@ -23121,11 +22991,6 @@ const parseXml = function (xmlData) {
|
|||||||
childNode[":@"] = attsMap
|
childNode[":@"] = attsMap
|
||||||
}
|
}
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
// closeIndex points at '?' of the closing '?>'
|
|
||||||
currentNode.addEndIndex(tagData.closeIndex + 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -23290,10 +23155,6 @@ const parseXml = function (xmlData) {
|
|||||||
this.isCurrentNodeStopNode = false; // Reset flag
|
this.isCurrentNodeStopNode = false; // Reset flag
|
||||||
|
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
currentNode.addEndIndex(i + 1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//selfClosing tag
|
//selfClosing tag
|
||||||
if (isSelfClosing) {
|
if (isSelfClosing) {
|
||||||
@@ -23304,10 +23165,6 @@ const parseXml = function (xmlData) {
|
|||||||
childNode[":@"] = prefixedAttrs;
|
childNode[":@"] = prefixedAttrs;
|
||||||
}
|
}
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
currentNode.addEndIndex(closeIndex + 1);
|
|
||||||
}
|
|
||||||
this.matcher.pop(); // Pop self-closing tag
|
this.matcher.pop(); // Pop self-closing tag
|
||||||
this.isCurrentNodeStopNode = false; // Reset flag
|
this.isCurrentNodeStopNode = false; // Reset flag
|
||||||
}
|
}
|
||||||
@@ -23317,10 +23174,6 @@ const parseXml = function (xmlData) {
|
|||||||
childNode[":@"] = prefixedAttrs;
|
childNode[":@"] = prefixedAttrs;
|
||||||
}
|
}
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
currentNode.addEndIndex(result.closeIndex + 1);
|
|
||||||
}
|
|
||||||
this.matcher.pop(); // Pop unpaired tag
|
this.matcher.pop(); // Pop unpaired tag
|
||||||
this.isCurrentNodeStopNode = false; // Reset flag
|
this.isCurrentNodeStopNode = false; // Reset flag
|
||||||
i = result.closeIndex;
|
i = result.closeIndex;
|
||||||
@@ -59590,24 +59443,6 @@ const EXPANSION_MAX = 100_000;
|
|||||||
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
||||||
// characters) so legitimate input is unaffected.
|
// characters) so legitimate input is unaffected.
|
||||||
const EXPANSION_MAX_LENGTH = 4_000_000;
|
const EXPANSION_MAX_LENGTH = 4_000_000;
|
||||||
// `expand_` recurses once per level of brace *nesting* - both when expanding a
|
|
||||||
// set's comma members and when re-wrapping a set whose body is a single part.
|
|
||||||
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
|
||||||
// level per chained group), which left nesting depth unbounded: about 3,100
|
|
||||||
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
|
||||||
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
|
||||||
// will follow nesting. It sits far above any realistic pattern and well below
|
|
||||||
// the depth at which the stack runs out.
|
|
||||||
const EXPANSION_MAX_DEPTH = 1_000;
|
|
||||||
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
|
||||||
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
|
||||||
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
|
||||||
// full passes over a string that itself grows by one `escClose` sentinel each
|
|
||||||
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
|
||||||
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
|
||||||
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
|
||||||
// times the scan may restart. Real `{a},b}` input needs a handful.
|
|
||||||
const EXPANSION_MAX_REWRITES = 1_000;
|
|
||||||
function numeric(str) {
|
function numeric(str) {
|
||||||
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
||||||
}
|
}
|
||||||
@@ -59627,52 +59462,37 @@ function unescapeBraces(str) {
|
|||||||
.replace(escCommaPattern, ',')
|
.replace(escCommaPattern, ',')
|
||||||
.replace(escPeriodPattern, '.');
|
.replace(escPeriodPattern, '.');
|
||||||
}
|
}
|
||||||
// Like `target.push(...items)` but doesn't overflow the stack
|
|
||||||
function pushAll(target, items) {
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
|
||||||
target.push(items[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Basically just str.split(","), but handling cases
|
* Basically just str.split(","), but handling cases
|
||||||
* where we have nested braced sections, which should be
|
* where we have nested braced sections, which should be
|
||||||
* treated as individual members, like {a,{b,c},d}
|
* treated as individual members, like {a,{b,c},d}
|
||||||
*/
|
*/
|
||||||
function parseCommaParts(str) {
|
function parseCommaParts(str) {
|
||||||
|
if (!str) {
|
||||||
|
return [''];
|
||||||
|
}
|
||||||
const parts = [];
|
const parts = [];
|
||||||
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
|
||||||
// chain of them exhaust the stack - the parsing-side counterpart to
|
|
||||||
// the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or
|
|
||||||
// `maxLength` can bound, since it happens before expansion.
|
|
||||||
//
|
|
||||||
// The part the next chunk continues
|
|
||||||
let carry = '';
|
|
||||||
for (;;) {
|
|
||||||
const m = balanced('{', '}', str);
|
const m = balanced('{', '}', str);
|
||||||
if (!m) {
|
if (!m) {
|
||||||
const tail = str.split(',');
|
return str.split(',');
|
||||||
tail[0] = carry + tail[0];
|
|
||||||
pushAll(parts, tail);
|
|
||||||
return parts;
|
|
||||||
}
|
}
|
||||||
const { pre, body, post } = m;
|
const { pre, body, post } = m;
|
||||||
const p = pre.split(',');
|
const p = pre.split(',');
|
||||||
p[0] = carry + p[0];
|
|
||||||
p[p.length - 1] += '{' + body + '}';
|
p[p.length - 1] += '{' + body + '}';
|
||||||
if (!post.length) {
|
const postParts = parseCommaParts(post);
|
||||||
pushAll(parts, p);
|
if (post.length) {
|
||||||
|
;
|
||||||
|
p[p.length - 1] += postParts.shift();
|
||||||
|
p.push.apply(p, postParts);
|
||||||
|
}
|
||||||
|
parts.push.apply(parts, p);
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
carry = p.pop();
|
|
||||||
pushAll(parts, p);
|
|
||||||
str = post;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function expand(str, options = {}) {
|
function expand(str, options = {}) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES, } = options;
|
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
// I don't know why Bash 4.3 does this, but it does.
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
// Anything starting with {} will have the first two bytes preserved
|
||||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||||
@@ -59682,7 +59502,7 @@ function expand(str, options = {}) {
|
|||||||
if (str.slice(0, 2) === '{}') {
|
if (str.slice(0, 2) === '{}') {
|
||||||
str = '\\{\\}' + str.slice(2);
|
str = '\\{\\}' + str.slice(2);
|
||||||
}
|
}
|
||||||
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
||||||
}
|
}
|
||||||
function embrace(str) {
|
function embrace(str) {
|
||||||
return '{' + str + '}';
|
return '{' + str + '}';
|
||||||
@@ -59777,13 +59597,7 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|||||||
}
|
}
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
function expand_(str, max, maxLength, isTop) {
|
||||||
// Too deeply nested to keep following: treat the rest as literal, the same
|
|
||||||
// way a group that cannot expand is already handled. Truncating rather than
|
|
||||||
// throwing keeps `expand` total, matching `max` and `maxLength`.
|
|
||||||
if (depth > maxDepth) {
|
|
||||||
return [str];
|
|
||||||
}
|
|
||||||
// Consume the string's top-level brace groups left to right, threading a
|
// Consume the string's top-level brace groups left to right, threading a
|
||||||
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
||||||
// rather than recursing on `m.post` once per group - keeps the native stack
|
// rather than recursing on `m.post` once per group - keeps the native stack
|
||||||
@@ -59795,9 +59609,6 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
||||||
// is on the final strings, so it is applied to whichever `combine` produces
|
// is on the final strings, so it is applied to whichever `combine` produces
|
||||||
// them (the one with no brace set left in the tail).
|
// them (the one with no brace set left in the tail).
|
||||||
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
|
||||||
// re-reads the whole string, so leaving this unbounded is quadratic.
|
|
||||||
let rewrites = 0;
|
|
||||||
let dropEmpties = false;
|
let dropEmpties = false;
|
||||||
let firstGroup = true;
|
let firstGroup = true;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -59822,8 +59633,7 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
const isOptions = m.body.indexOf(',') >= 0;
|
const isOptions = m.body.indexOf(',') >= 0;
|
||||||
if (!isSequence && !isOptions) {
|
if (!isSequence && !isOptions) {
|
||||||
// {a},b}
|
// {a},b}
|
||||||
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
if (m.post.match(/,(?!,).*\}/)) {
|
||||||
rewrites++;
|
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
str = m.pre + '{' + m.body + escClose + m.post;
|
||||||
isTop = true;
|
isTop = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -59843,7 +59653,7 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
let n = parseCommaParts(m.body);
|
let n = parseCommaParts(m.body);
|
||||||
if (n.length === 1 && n[0] !== undefined) {
|
if (n.length === 1 && n[0] !== undefined) {
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
// x{{a,b}}y ==> x{a}y x{b}y
|
||||||
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
n = expand_(n[0], max, maxLength, false).map(embrace);
|
||||||
//XXX is this necessary? Can't seem to hit it in tests.
|
//XXX is this necessary? Can't seem to hit it in tests.
|
||||||
/* c8 ignore start */
|
/* c8 ignore start */
|
||||||
if (n.length === 1) {
|
if (n.length === 1) {
|
||||||
@@ -59869,13 +59679,12 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
values = [];
|
values = [];
|
||||||
let valuesLength = 0;
|
let valuesLength = 0;
|
||||||
outer: for (let j = 0; j < n.length; j++) {
|
outer: for (let j = 0; j < n.length; j++) {
|
||||||
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
const expanded = expand_(n[j], max, maxLength, false);
|
||||||
for (let k = 0; k < expanded.length; k++) {
|
for (let k = 0; k < expanded.length; k++) {
|
||||||
const v = expanded[k];
|
const v = expanded[k];
|
||||||
if (dropsEmpties && !v)
|
if (dropsEmpties && !v)
|
||||||
continue;
|
continue;
|
||||||
if (values.length >= max ||
|
if (values.length >= max || valuesLength + v.length > maxLength) {
|
||||||
valuesLength + v.length > maxLength) {
|
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
values.push(v);
|
values.push(v);
|
||||||
|
|||||||
Vendored
+191
-523
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -65,7 +65,7 @@ class LocalDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__/
|
|||||||
architecture: this.architecture,
|
architecture: this.architecture,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
source,
|
source,
|
||||||
verification: getJdkVerificationIdentity(false, false),
|
verification: getJdkVerificationIdentity(false),
|
||||||
path: this.getJdkCachePath(this.version)
|
path: this.getJdkCachePath(this.version)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+10
-37
@@ -42,8 +42,6 @@ Fa133tP85xzJEq1XeXm8WeLFo2wV
|
|||||||
=rHCS
|
=rHCS
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`;
|
-----END PGP PUBLIC KEY BLOCK-----`;
|
||||||
|
|
||||||
// EXTERNAL MODULE: ./src/constants.ts
|
|
||||||
var constants = __webpack_require__(7242);
|
|
||||||
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js + 7 modules
|
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js + 7 modules
|
||||||
var core = __webpack_require__(3838);
|
var core = __webpack_require__(3838);
|
||||||
// EXTERNAL MODULE: ./node_modules/@actions/tool-cache/lib/tool-cache.js + 2 modules
|
// EXTERNAL MODULE: ./node_modules/@actions/tool-cache/lib/tool-cache.js + 2 modules
|
||||||
@@ -64,7 +62,6 @@ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
||||||
constructor(installerOptions) {
|
constructor(installerOptions) {
|
||||||
super('Microsoft', installerOptions);
|
super('Microsoft', installerOptions);
|
||||||
@@ -73,7 +70,6 @@ class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
|||||||
core/* info */.pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
core/* info */.pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
||||||
if (this.verifySignature) {
|
if (this.verifySignature) {
|
||||||
try {
|
|
||||||
if (!javaRelease.signatureUrl) {
|
if (!javaRelease.signatureUrl) {
|
||||||
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`);
|
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`);
|
||||||
}
|
}
|
||||||
@@ -82,14 +78,7 @@ class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
|||||||
await gpg/* verifyPackageSignature */.Yi(javaArchivePath, javaRelease.signatureUrl, this.verifySignaturePublicKey ?? MICROSOFT_PUBLIC_KEY);
|
await gpg/* verifyPackageSignature */.Yi(javaArchivePath, javaRelease.signatureUrl, this.verifySignaturePublicKey ?? MICROSOFT_PUBLIC_KEY);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw new Error(`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${error.message} ${constants/* SIGNATURE_VERIFICATION_FAILURE_HELP */.kQ}`, { cause: error });
|
throw new Error(`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${error.message}`, { cause: error });
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
if (this.verifySignatureExplicitlyRequested) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
core/* warning */.$e(error instanceof Error ? error.message : `Unknown error: ${error}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core/* info */.pq(`Extracting Java archive...`);
|
core/* info */.pq(`Extracting Java archive...`);
|
||||||
@@ -178,8 +167,7 @@ class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
|||||||
/* harmony export */ Fh: () => (/* binding */ importKey),
|
/* harmony export */ Fh: () => (/* binding */ importKey),
|
||||||
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
||||||
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
||||||
/* harmony export */ nY: () => (/* binding */ toGpgPath),
|
/* harmony export */ nY: () => (/* binding */ toGpgPath)
|
||||||
/* harmony export */ o6: () => (/* binding */ isGpgAvailable)
|
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* unused harmony export GPG_HOME_PREFIX */
|
/* unused harmony export GPG_HOME_PREFIX */
|
||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
||||||
@@ -201,9 +189,6 @@ class MicrosoftDistributions extends base_installer/* JavaBase */.O {
|
|||||||
|
|
||||||
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||||
async function isGpgAvailable() {
|
|
||||||
return Boolean(await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .which */ .K7('gpg', false));
|
|
||||||
}
|
|
||||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||||
@@ -215,8 +200,8 @@ function toGpgPath(p) {
|
|||||||
.replace(/\\/g, '/')
|
.replace(/\\/g, '/')
|
||||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||||
}
|
}
|
||||||
function createGpgHome(prefix, tempDir = _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4()) {
|
function createGpgHome(prefix) {
|
||||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(tempDir, prefix));
|
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4(), prefix));
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
||||||
}
|
}
|
||||||
@@ -263,24 +248,19 @@ async function removeGpgHome(gpgHome) {
|
|||||||
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await stopGpgAgent(resolvedGpgHome);
|
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
|
||||||
}
|
|
||||||
async function stopGpgAgent(gpgHome) {
|
|
||||||
try {
|
try {
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||||
}
|
}
|
||||||
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||||
}
|
}
|
||||||
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
||||||
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
||||||
let gpgHome;
|
let gpgHome;
|
||||||
try {
|
try {
|
||||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||||
const tempDir = process.platform === 'darwin' ? '/tmp' : _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4();
|
|
||||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
try {
|
try {
|
||||||
@@ -292,21 +272,15 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
|||||||
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const publicKeys = Array.isArray(publicKeyContent)
|
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, 'public-key.asc');
|
||||||
? publicKeyContent
|
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' });
|
||||||
: [publicKeyContent];
|
|
||||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
|
||||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, `public-key-${index}.asc`);
|
|
||||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKey, { encoding: 'utf-8' });
|
|
||||||
return toGpgPath(publicKeyFile);
|
|
||||||
});
|
|
||||||
const options = { silent: true };
|
const options = { silent: true };
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||||
'--homedir',
|
'--homedir',
|
||||||
toGpgPath(gpgHome),
|
toGpgPath(gpgHome),
|
||||||
'--batch',
|
'--batch',
|
||||||
'--import',
|
'--import',
|
||||||
...publicKeyFiles
|
toGpgPath(publicKeyFile)
|
||||||
], options);
|
], options);
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||||
'--homedir',
|
'--homedir',
|
||||||
@@ -318,7 +292,6 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
|||||||
], options);
|
], options);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
await stopGpgAgent(gpgHome);
|
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-139
@@ -1,139 +0,0 @@
|
|||||||
export const id = 228;
|
|
||||||
export const ids = [228];
|
|
||||||
export const modules = {
|
|
||||||
|
|
||||||
/***/ 8228:
|
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
||||||
|
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
||||||
/* harmony export */ RedHatDistribution: () => (/* binding */ RedHatDistribution)
|
|
||||||
/* harmony export */ });
|
|
||||||
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3838);
|
|
||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9896);
|
|
||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
|
|
||||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6928);
|
|
||||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
|
|
||||||
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2088);
|
|
||||||
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(semver__WEBPACK_IMPORTED_MODULE_3__);
|
|
||||||
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4527);
|
|
||||||
/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6242);
|
|
||||||
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7444);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const DISCO_API_URL = 'https://api.foojay.io/disco/v3.0';
|
|
||||||
class RedHatDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_5__/* .JavaBase */ .O {
|
|
||||||
constructor(installerOptions) {
|
|
||||||
super('RedHat', installerOptions);
|
|
||||||
}
|
|
||||||
async findPackageForDownload(range) {
|
|
||||||
if (!this.stable) {
|
|
||||||
throw new Error('Early access versions are not supported');
|
|
||||||
}
|
|
||||||
const availablePackages = await this.getAvailablePackages();
|
|
||||||
const normalizedPackages = availablePackages
|
|
||||||
.map(item => ({
|
|
||||||
item,
|
|
||||||
version: this.normalizeDiscoVersion(item.java_version)
|
|
||||||
}))
|
|
||||||
.filter((item) => item.version !== null)
|
|
||||||
.sort((left, right) => -semver__WEBPACK_IMPORTED_MODULE_3___default().compareBuild(left.version, right.version));
|
|
||||||
const selectedPackage = normalizedPackages.find(item => (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .isVersionSatisfies */ .y)(range, item.version));
|
|
||||||
if (!selectedPackage) {
|
|
||||||
throw this.createVersionNotFoundError(range, normalizedPackages.map(item => item.version), `Operating system: ${this.getOperatingSystem()}`);
|
|
||||||
}
|
|
||||||
const detailsUrl = `${DISCO_API_URL}/ids/${selectedPackage.item.id}`;
|
|
||||||
const response = await this.http.getJson(detailsUrl);
|
|
||||||
const details = response.result?.result?.[0];
|
|
||||||
if (!details?.direct_download_uri) {
|
|
||||||
throw new Error(`Foojay Disco returned no direct Red Hat download URL for package '${selectedPackage.item.id}'.`);
|
|
||||||
}
|
|
||||||
const checksum = details.checksum?.trim();
|
|
||||||
if (details.checksum_type?.toLowerCase() !== 'sha256' || !checksum) {
|
|
||||||
throw new Error(`Foojay Disco returned no SHA-256 checksum for Red Hat package '${selectedPackage.item.id}'.`);
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
version: selectedPackage.version,
|
|
||||||
url: details.direct_download_uri,
|
|
||||||
checksum: {
|
|
||||||
algorithm: 'sha256',
|
|
||||||
value: checksum,
|
|
||||||
source: detailsUrl
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
async downloadTool(javaRelease) {
|
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
|
||||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq('Extracting Java archive...');
|
|
||||||
const archiveType = this.getArchiveType();
|
|
||||||
if (archiveType === 'zip') {
|
|
||||||
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .renameWinArchive */ .n2)(javaArchivePath);
|
|
||||||
}
|
|
||||||
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .extractJdkFile */ .PE)(javaArchivePath, archiveType);
|
|
||||||
const archiveName = fs__WEBPACK_IMPORTED_MODULE_1___default().readdirSync(extractedJavaPath)[0];
|
|
||||||
if (!archiveName) {
|
|
||||||
throw new Error(`The Red Hat archive for Java ${javaRelease.version} was empty.`);
|
|
||||||
}
|
|
||||||
const archivePath = path__WEBPACK_IMPORTED_MODULE_2___default().join(extractedJavaPath, archiveName);
|
|
||||||
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
|
||||||
return { version: javaRelease.version, path: javaPath };
|
|
||||||
}
|
|
||||||
async getAvailablePackages() {
|
|
||||||
const operatingSystem = this.getOperatingSystem();
|
|
||||||
const archiveType = this.getArchiveType();
|
|
||||||
const query = new URLSearchParams({
|
|
||||||
distro: 'redhat',
|
|
||||||
release_status: 'ga',
|
|
||||||
operating_system: operatingSystem,
|
|
||||||
architecture: this.distributionArchitecture(),
|
|
||||||
package_type: this.packageType,
|
|
||||||
archive_type: archiveType,
|
|
||||||
directly_downloadable: 'true'
|
|
||||||
});
|
|
||||||
const url = `${DISCO_API_URL}/packages?${query.toString()}`;
|
|
||||||
const response = await this.http.getJson(url);
|
|
||||||
const packages = response.result?.result;
|
|
||||||
if (!Array.isArray(packages)) {
|
|
||||||
throw new Error(`Could not fetch Red Hat package metadata from Foojay Disco: ${url}`);
|
|
||||||
}
|
|
||||||
return packages.filter(item => item.distribution === 'redhat' &&
|
|
||||||
item.release_status === 'ga' &&
|
|
||||||
item.operating_system === operatingSystem &&
|
|
||||||
item.architecture === this.distributionArchitecture() &&
|
|
||||||
item.package_type === this.packageType &&
|
|
||||||
item.archive_type === archiveType &&
|
|
||||||
item.directly_downloadable);
|
|
||||||
}
|
|
||||||
getOperatingSystem(alpine = (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_6__/* .isAlpineLinux */ .G6)()) {
|
|
||||||
if (alpine) {
|
|
||||||
throw new Error("Distribution 'redhat' does not support Alpine Linux because Red Hat portable archives require glibc.");
|
|
||||||
}
|
|
||||||
return process.platform === 'win32' ? 'windows' : 'linux';
|
|
||||||
}
|
|
||||||
getArchiveType() {
|
|
||||||
return process.platform === 'win32' ? 'zip' : 'tar.xz';
|
|
||||||
}
|
|
||||||
normalizeDiscoVersion(version) {
|
|
||||||
let normalizedVersion = version.trim();
|
|
||||||
if (/^\d+\+\d+$/.test(normalizedVersion)) {
|
|
||||||
normalizedVersion = normalizedVersion.replace('+', '.0.0+');
|
|
||||||
}
|
|
||||||
else if (/^\d+$/.test(normalizedVersion)) {
|
|
||||||
normalizedVersion = `${normalizedVersion}.0.0`;
|
|
||||||
}
|
|
||||||
else if (/^\d+\.\d+$/.test(normalizedVersion)) {
|
|
||||||
normalizedVersion = `${normalizedVersion}.0`;
|
|
||||||
}
|
|
||||||
return semver__WEBPACK_IMPORTED_MODULE_3___default().valid(normalizedVersion) ? normalizedVersion : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***/ })
|
|
||||||
|
|
||||||
};
|
|
||||||
Vendored
+8
-9
@@ -226,7 +226,6 @@ class JavaBase {
|
|||||||
floatingVersionVerified = false;
|
floatingVersionVerified = false;
|
||||||
setDefault;
|
setDefault;
|
||||||
verifySignature;
|
verifySignature;
|
||||||
verifySignatureExplicitlyRequested;
|
|
||||||
verifySignaturePublicKey;
|
verifySignaturePublicKey;
|
||||||
constructor(distribution, installerOptions) {
|
constructor(distribution, installerOptions) {
|
||||||
this.distribution = distribution;
|
this.distribution = distribution;
|
||||||
@@ -245,10 +244,7 @@ class JavaBase {
|
|||||||
installerOptions.setDefault !== undefined
|
installerOptions.setDefault !== undefined
|
||||||
? installerOptions.setDefault
|
? installerOptions.setDefault
|
||||||
: true;
|
: true;
|
||||||
this.verifySignature =
|
this.verifySignature = installerOptions.verifySignature ?? false;
|
||||||
installerOptions.verifySignature ?? this.supportsSignatureVerification();
|
|
||||||
this.verifySignatureExplicitlyRequested =
|
|
||||||
installerOptions.verifySignature === true;
|
|
||||||
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
||||||
}
|
}
|
||||||
async downloadAndVerify(javaRelease) {
|
async downloadAndVerify(javaRelease) {
|
||||||
@@ -484,7 +480,7 @@ class JavaBase {
|
|||||||
architecture: this.architecture,
|
architecture: this.architecture,
|
||||||
version: javaRelease.version,
|
version: javaRelease.version,
|
||||||
source: this.getJdkReleaseIdentity(javaRelease),
|
source: this.getJdkReleaseIdentity(javaRelease),
|
||||||
verification: getJdkVerificationIdentity(this.verifySignature, this.verifySignatureExplicitlyRequested, this.verifySignaturePublicKey),
|
verification: getJdkVerificationIdentity(this.verifySignature, this.verifySignaturePublicKey),
|
||||||
path: this.getJdkCachePath(javaRelease.version)
|
path: this.getJdkCachePath(javaRelease.version)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -730,9 +726,12 @@ class JavaBase {
|
|||||||
}
|
}
|
||||||
// Java uses a versioning scheme (JEP 322) that can contain more numeric
|
// Java uses a versioning scheme (JEP 322) that can contain more numeric
|
||||||
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
|
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
|
||||||
// exact versions to SemVer build notation ('18.0.1+1', or '26.0.2+1.1'
|
// exact versions to SemVer build notation ('18.0.1+1') so they are
|
||||||
// for '26.0.2.1+1') so they are accepted. Ranges are left untouched.
|
// accepted. Ranges and versions that already carry build metadata are
|
||||||
version = (0,util/* normalizeJavaVersionToSemver */.zZ)(version);
|
// left untouched.
|
||||||
|
if (/^\d+(\.\d+){3,}$/.test(version)) {
|
||||||
|
version = (0,util/* convertVersionToSemver */.ZY)(version);
|
||||||
|
}
|
||||||
if (!semver_default().validRange(version)) {
|
if (!semver_default().validRange(version)) {
|
||||||
throw new Error(`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`);
|
throw new Error(`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+13
-74
@@ -109,7 +109,7 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
|||||||
const formattedVersion = this.stable
|
const formattedVersion = this.stable
|
||||||
? item.version_data.semver
|
? item.version_data.semver
|
||||||
: item.version_data.semver.replace('-beta+', '+');
|
: item.version_data.semver.replace('-beta+', '+');
|
||||||
const release = {
|
return {
|
||||||
version: formattedVersion,
|
version: formattedVersion,
|
||||||
url: item.binaries[0].package.link,
|
url: item.binaries[0].package.link,
|
||||||
signatureUrl: item.binaries[0].package.signature_link,
|
signatureUrl: item.binaries[0].package.signature_link,
|
||||||
@@ -119,29 +119,15 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
|||||||
source: item.binaries[0].package.checksum_link
|
source: item.binaries[0].package.checksum_link
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return {
|
|
||||||
release,
|
|
||||||
openjdkVersion: getOpenJdkSemverVersion(item.version_data)
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
// The Adoptium API `semver` folds the JEP 322 patch field into the build
|
|
||||||
// number ('26.0.2.1+1' -> '26.0.2+101') and appends extra metadata for LTS
|
|
||||||
// releases ('25.0.4+7' -> '25.0.4+7.0.LTS'). Exact versions requested by
|
|
||||||
// users follow the OpenJDK notation instead, so also match them against a
|
|
||||||
// key derived from the OpenJDK version fields ('26.0.2+1.1', '25.0.4+7').
|
|
||||||
const isExactBuildRequest = (semver_default().parse(version)?.build.length ?? 0) > 0;
|
|
||||||
const satisfiedVersions = availableVersionsWithBinaries
|
const satisfiedVersions = availableVersionsWithBinaries
|
||||||
.filter(({ release, openjdkVersion }) => (0,util/* isVersionSatisfies */.y)(version, release.version) ||
|
.filter(item => (0,util/* isVersionSatisfies */.y)(version, item.version))
|
||||||
(isExactBuildRequest &&
|
|
||||||
openjdkVersion !== null &&
|
|
||||||
semver_default().compareBuild(version, openjdkVersion) === 0))
|
|
||||||
.map(({ release }) => release)
|
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return -semver_default().compareBuild(a.version, b.version);
|
return -semver_default().compareBuild(a.version, b.version);
|
||||||
});
|
});
|
||||||
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||||
if (!resolvedFullVersion) {
|
if (!resolvedFullVersion) {
|
||||||
const availableVersionStrings = availableVersionsWithBinaries.map(({ release }) => release.version);
|
const availableVersionStrings = availableVersionsWithBinaries.map(item => item.version);
|
||||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||||
}
|
}
|
||||||
return resolvedFullVersion;
|
return resolvedFullVersion;
|
||||||
@@ -173,10 +159,6 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
|||||||
async downloadPackage(release) {
|
async downloadPackage(release) {
|
||||||
const archivePath = await this.downloadAndVerify(release);
|
const archivePath = await this.downloadAndVerify(release);
|
||||||
if (this.verifySignature) {
|
if (this.verifySignature) {
|
||||||
try {
|
|
||||||
if (!(await gpg/* isGpgAvailable */.o6())) {
|
|
||||||
throw new Error("Input 'verify-signature' is enabled, but gpg is not available.");
|
|
||||||
}
|
|
||||||
if (!release.signatureUrl) {
|
if (!release.signatureUrl) {
|
||||||
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`);
|
throw new Error(`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`);
|
||||||
}
|
}
|
||||||
@@ -185,20 +167,7 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
|||||||
await gpg/* verifyPackageSignature */.Yi(archivePath, release.signatureUrl, this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY);
|
await gpg/* verifyPackageSignature */.Yi(archivePath, release.signatureUrl, this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
const verificationError = new Error(`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${error.message} ${constants/* SIGNATURE_VERIFICATION_FAILURE_HELP */.kQ}`, { cause: error });
|
throw new Error(`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${error.message}`, { cause: error });
|
||||||
if (this.verifySignatureExplicitlyRequested) {
|
|
||||||
throw verificationError;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core/* warning */.$e(verificationError.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
if (this.verifySignatureExplicitlyRequested) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
core/* warning */.$e(error instanceof Error ? error.message : `Unknown error: ${error}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return archivePath;
|
return archivePath;
|
||||||
@@ -293,20 +262,6 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
|
|||||||
return architecture === 'armv7' ? 'arm' : architecture;
|
return architecture === 'armv7' ? 'arm' : architecture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Builds a SemVer version from the OpenJDK version fields reported by the
|
|
||||||
* Adoptium API, e.g. '26.0.2.1+1' -> '26.0.2+1.1' and '25.0.4+7-LTS' ->
|
|
||||||
* '25.0.4+7'. Returns null if the fields cannot form a valid SemVer version.
|
|
||||||
*/
|
|
||||||
function getOpenJdkSemverVersion(versionData) {
|
|
||||||
const { major, minor, security, patch, build } = versionData;
|
|
||||||
if (build === undefined || build === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const buildMetadata = patch ? `${patch}.${build}` : `${build}`;
|
|
||||||
const version = `${major}.${minor}.${security}+${buildMetadata}`;
|
|
||||||
return semver_default().valid(version) ? version : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -318,8 +273,7 @@ function getOpenJdkSemverVersion(versionData) {
|
|||||||
/* harmony export */ Fh: () => (/* binding */ importKey),
|
/* harmony export */ Fh: () => (/* binding */ importKey),
|
||||||
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
||||||
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
||||||
/* harmony export */ nY: () => (/* binding */ toGpgPath),
|
/* harmony export */ nY: () => (/* binding */ toGpgPath)
|
||||||
/* harmony export */ o6: () => (/* binding */ isGpgAvailable)
|
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* unused harmony export GPG_HOME_PREFIX */
|
/* unused harmony export GPG_HOME_PREFIX */
|
||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
||||||
@@ -341,9 +295,6 @@ function getOpenJdkSemverVersion(versionData) {
|
|||||||
|
|
||||||
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||||
async function isGpgAvailable() {
|
|
||||||
return Boolean(await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .which */ .K7('gpg', false));
|
|
||||||
}
|
|
||||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||||
@@ -355,8 +306,8 @@ function toGpgPath(p) {
|
|||||||
.replace(/\\/g, '/')
|
.replace(/\\/g, '/')
|
||||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||||
}
|
}
|
||||||
function createGpgHome(prefix, tempDir = _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4()) {
|
function createGpgHome(prefix) {
|
||||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(tempDir, prefix));
|
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4(), prefix));
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
||||||
}
|
}
|
||||||
@@ -403,24 +354,19 @@ async function removeGpgHome(gpgHome) {
|
|||||||
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await stopGpgAgent(resolvedGpgHome);
|
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
|
||||||
}
|
|
||||||
async function stopGpgAgent(gpgHome) {
|
|
||||||
try {
|
try {
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||||
}
|
}
|
||||||
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||||
}
|
}
|
||||||
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
||||||
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
||||||
let gpgHome;
|
let gpgHome;
|
||||||
try {
|
try {
|
||||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||||
const tempDir = process.platform === 'darwin' ? '/tmp' : _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4();
|
|
||||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
try {
|
try {
|
||||||
@@ -432,21 +378,15 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
|||||||
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const publicKeys = Array.isArray(publicKeyContent)
|
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, 'public-key.asc');
|
||||||
? publicKeyContent
|
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' });
|
||||||
: [publicKeyContent];
|
|
||||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
|
||||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, `public-key-${index}.asc`);
|
|
||||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKey, { encoding: 'utf-8' });
|
|
||||||
return toGpgPath(publicKeyFile);
|
|
||||||
});
|
|
||||||
const options = { silent: true };
|
const options = { silent: true };
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||||
'--homedir',
|
'--homedir',
|
||||||
toGpgPath(gpgHome),
|
toGpgPath(gpgHome),
|
||||||
'--batch',
|
'--batch',
|
||||||
'--import',
|
'--import',
|
||||||
...publicKeyFiles
|
toGpgPath(publicKeyFile)
|
||||||
], options);
|
], options);
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||||
'--homedir',
|
'--homedir',
|
||||||
@@ -458,7 +398,6 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
|||||||
], options);
|
], options);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
await stopGpgAgent(gpgHome);
|
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-2
@@ -128,8 +128,7 @@ class LibericaDistributions extends _base_installer_js__WEBPACK_IMPORTED_MODULE_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
convertVersionToSemver(version) {
|
convertVersionToSemver(version) {
|
||||||
const { featureVersion, interimVersion, updateVersion } = version;
|
const { buildVersion, featureVersion, interimVersion, updateVersion } = version;
|
||||||
const buildVersion = version.version.split('+')[1] || version.buildVersion;
|
|
||||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join('.');
|
const mainVersion = [featureVersion, interimVersion, updateVersion].join('.');
|
||||||
if (buildVersion != 0) {
|
if (buildVersion != 0) {
|
||||||
return `${mainVersion}+${buildVersion}`;
|
return `${mainVersion}+${buildVersion}`;
|
||||||
|
|||||||
Vendored
+6
-15
@@ -127,25 +127,16 @@ function getInstallationIdentity(jdkPath, architecture) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getJdkVerificationIdentity(verifySignature, enforceSignatureVerification, publicKey) {
|
function getJdkVerificationIdentity(verifySignature, publicKey) {
|
||||||
if (!verifySignature) {
|
if (!verifySignature) {
|
||||||
return 'disabled';
|
return 'unverified';
|
||||||
}
|
}
|
||||||
const verificationPolicy = enforceSignatureVerification
|
|
||||||
? 'enforced'
|
|
||||||
: 'check-and-warn';
|
|
||||||
if (!publicKey) {
|
if (!publicKey) {
|
||||||
return `${verificationPolicy}:bundled`;
|
return 'verified:bundled';
|
||||||
}
|
}
|
||||||
const publicKeys = Array.isArray(publicKey) ? publicKey : [publicKey];
|
const normalizedKey = publicKey.replace(/\r\n?/g, '\n').trim();
|
||||||
const normalizedKeys = publicKeys.map(key => key.replace(/\r\n?/g, '\n').trim());
|
const fingerprint = (0,crypto__WEBPACK_IMPORTED_MODULE_0__.createHash)('sha256').update(normalizedKey).digest('hex');
|
||||||
const fingerprintSource = Array.isArray(publicKey)
|
return `verified:custom:sha256:${fingerprint}`;
|
||||||
? normalizedKeys.map(key => `${Buffer.byteLength(key)}:${key}`).join('')
|
|
||||||
: normalizedKeys[0];
|
|
||||||
const fingerprint = (0,crypto__WEBPACK_IMPORTED_MODULE_0__.createHash)('sha256')
|
|
||||||
.update(fingerprintSource)
|
|
||||||
.digest('hex');
|
|
||||||
return `${verificationPolicy}:custom:sha256:${fingerprint}`;
|
|
||||||
}
|
}
|
||||||
async function saveJdkCaches() {
|
async function saveJdkCaches() {
|
||||||
const state = _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getState */ .Gu(STATE_JDK_CACHES);
|
const state = _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getState */ .Gu(STATE_JDK_CACHES);
|
||||||
|
|||||||
Vendored
+26
-174
@@ -10,11 +10,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ configureAuthentication: () => (/* binding */ configureAuthentication),
|
/* harmony export */ configureAuthentication: () => (/* binding */ configureAuthentication),
|
||||||
/* harmony export */ createAuthenticationSettings: () => (/* binding */ createAuthenticationSettings),
|
/* harmony export */ createAuthenticationSettings: () => (/* binding */ createAuthenticationSettings),
|
||||||
/* harmony export */ generate: () => (/* binding */ generate),
|
/* harmony export */ generate: () => (/* binding */ generate),
|
||||||
/* harmony export */ getInputWithDeprecatedAlias: () => (/* binding */ getInputWithDeprecatedAlias),
|
/* harmony export */ getInputWithDeprecatedAlias: () => (/* binding */ getInputWithDeprecatedAlias)
|
||||||
/* harmony export */ getMavenRepositorySettings: () => (/* binding */ getMavenRepositorySettings),
|
|
||||||
/* harmony export */ getMavenServerSettings: () => (/* binding */ getMavenServerSettings),
|
|
||||||
/* harmony export */ parseMavenRepositories: () => (/* binding */ parseMavenRepositories),
|
|
||||||
/* harmony export */ parseMavenServerCredentials: () => (/* binding */ parseMavenServerCredentials)
|
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6928);
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6928);
|
||||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
@@ -38,8 +34,9 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
|
|
||||||
|
|
||||||
async function configureAuthentication() {
|
async function configureAuthentication() {
|
||||||
const servers = getMavenServerSettings();
|
const id = _actions_core__WEBPACK_IMPORTED_MODULE_1__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_ID */ .fd);
|
||||||
const repositorySettings = getMavenRepositorySettings();
|
const usernameEnvVar = getInputWithDeprecatedAlias(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_USERNAME_ENV_VAR */ .sc, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_USERNAME_DEPRECATED */ .sp, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_DEFAULT_SERVER_USERNAME */ .Wj);
|
||||||
|
const passwordEnvVar = getInputWithDeprecatedAlias(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_PASSWORD_ENV_VAR */ .r4, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_PASSWORD_DEPRECATED */ .Vt, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_DEFAULT_SERVER_PASSWORD */ .xp);
|
||||||
const settingsDirectory = _actions_core__WEBPACK_IMPORTED_MODULE_1__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SETTINGS_PATH */ .Xh) ||
|
const settingsDirectory = _actions_core__WEBPACK_IMPORTED_MODULE_1__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SETTINGS_PATH */ .Xh) ||
|
||||||
path__WEBPACK_IMPORTED_MODULE_0__.join(os__WEBPACK_IMPORTED_MODULE_4__.homedir(), _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .M2_DIR */ .iT);
|
path__WEBPACK_IMPORTED_MODULE_0__.join(os__WEBPACK_IMPORTED_MODULE_4__.homedir(), _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .M2_DIR */ .iT);
|
||||||
const overwriteSettings = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getBooleanInput */ .Vt)(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_OVERWRITE_SETTINGS */ .TS, true);
|
const overwriteSettings = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getBooleanInput */ .Vt)(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_OVERWRITE_SETTINGS */ .TS, true);
|
||||||
@@ -49,7 +46,7 @@ async function configureAuthentication() {
|
|||||||
if (gpgPrivateKey) {
|
if (gpgPrivateKey) {
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__/* .setSecret */ .Pq(gpgPrivateKey);
|
_actions_core__WEBPACK_IMPORTED_MODULE_1__/* .setSecret */ .Pq(gpgPrivateKey);
|
||||||
}
|
}
|
||||||
await createAuthenticationSettings(servers, settingsDirectory, overwriteSettings, gpgPassphraseEnvVar, repositorySettings);
|
await createAuthenticationSettings(id, usernameEnvVar, passwordEnvVar, settingsDirectory, overwriteSettings, gpgPassphraseEnvVar);
|
||||||
if (gpgPrivateKey) {
|
if (gpgPrivateKey) {
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__/* .info */ .pq('Importing private gpg key');
|
_actions_core__WEBPACK_IMPORTED_MODULE_1__/* .info */ .pq('Importing private gpg key');
|
||||||
const gpgHome = await _gpg_js__WEBPACK_IMPORTED_MODULE_5__/* .importKey */ .Fh(gpgPrivateKey);
|
const gpgHome = await _gpg_js__WEBPACK_IMPORTED_MODULE_5__/* .importKey */ .Fh(gpgPrivateKey);
|
||||||
@@ -71,106 +68,15 @@ function getInputWithDeprecatedAlias(inputName, deprecatedInputName, defaultValu
|
|||||||
}
|
}
|
||||||
return value || deprecatedValue || defaultValue || '';
|
return value || deprecatedValue || defaultValue || '';
|
||||||
}
|
}
|
||||||
// only exported for testing purposes
|
async function createAuthenticationSettings(id, usernameEnvVar, passwordEnvVar, settingsDirectory, overwriteSettings, gpgPassphraseEnvVar = undefined) {
|
||||||
function getMavenServerSettings() {
|
_actions_core__WEBPACK_IMPORTED_MODULE_1__/* .info */ .pq(`Creating ${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MVN_SETTINGS_FILE */ .vO} with server-id: ${id}`);
|
||||||
const entries = _actions_core__WEBPACK_IMPORTED_MODULE_1__/* .getMultilineInput */ .q3(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_MVN_SERVER_CREDENTIALS */ .MM);
|
|
||||||
if (entries.some(entry => entry.trim())) {
|
|
||||||
return parseMavenServerCredentials(entries);
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: _actions_core__WEBPACK_IMPORTED_MODULE_1__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_ID */ .fd),
|
|
||||||
usernameEnvVar: getInputWithDeprecatedAlias(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_USERNAME_ENV_VAR */ .sc, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_USERNAME_DEPRECATED */ .sp, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_DEFAULT_SERVER_USERNAME */ .Wj),
|
|
||||||
passwordEnvVar: getInputWithDeprecatedAlias(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_PASSWORD_ENV_VAR */ .r4, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_SERVER_PASSWORD_DEPRECATED */ .Vt, _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_DEFAULT_SERVER_PASSWORD */ .xp)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
// only exported for testing purposes
|
|
||||||
function parseMavenServerCredentials(entries) {
|
|
||||||
const servers = [];
|
|
||||||
const serverIds = new Set();
|
|
||||||
entries.forEach((entry, index) => {
|
|
||||||
if (!entry.trim()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const fields = entry.split(':');
|
|
||||||
if (fields.length !== 3) {
|
|
||||||
throw new Error(`Invalid mvn-server-credentials entry at line ${index + 1}. Expected format: server-id:USERNAME_ENV:PASSWORD_ENV`);
|
|
||||||
}
|
|
||||||
const [id, usernameEnvVar, passwordEnvVar] = fields.map(field => field.trim());
|
|
||||||
if (!id || !usernameEnvVar || !passwordEnvVar) {
|
|
||||||
throw new Error(`Invalid mvn-server-credentials entry at line ${index + 1}. server-id, username environment variable, and password environment variable are required`);
|
|
||||||
}
|
|
||||||
if (serverIds.has(id)) {
|
|
||||||
throw new Error(`Duplicate server-id '${id}' in mvn-server-credentials input`);
|
|
||||||
}
|
|
||||||
serverIds.add(id);
|
|
||||||
servers.push({ id, usernameEnvVar, passwordEnvVar });
|
|
||||||
});
|
|
||||||
return servers;
|
|
||||||
}
|
|
||||||
// only exported for testing purposes
|
|
||||||
function getMavenRepositorySettings() {
|
|
||||||
const entries = _actions_core__WEBPACK_IMPORTED_MODULE_1__/* .getMultilineInput */ .q3(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_MVN_REPOSITORIES */ .W2);
|
|
||||||
if (!entries.some(entry => entry.trim())) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const includeCentral = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getBooleanInput */ .Vt)(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_MVN_REPOSITORIES_INCLUDE_CENTRAL */ .H5, true);
|
|
||||||
return {
|
|
||||||
repositories: parseMavenRepositories(entries, includeCentral),
|
|
||||||
includeCentral,
|
|
||||||
prioritizeCentral: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getBooleanInput */ .Vt)(_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_MVN_REPOSITORIES_PRIORITIZE_CENTRAL */ .OT, true)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// only exported for testing purposes
|
|
||||||
function parseMavenRepositories(entries, includeCentral) {
|
|
||||||
const repositories = [];
|
|
||||||
const repositoryIds = new Set();
|
|
||||||
entries.forEach((entry, index) => {
|
|
||||||
if (!entry.trim()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const firstSeparator = entry.indexOf(':');
|
|
||||||
const lastSeparator = entry.lastIndexOf(':');
|
|
||||||
if (firstSeparator <= 0 || lastSeparator <= firstSeparator) {
|
|
||||||
throw new Error(`Invalid mvn-repositories entry at line ${index + 1}. Expected format: repository-id:repository-url:snapshots-enabled`);
|
|
||||||
}
|
|
||||||
const id = entry.slice(0, firstSeparator).trim();
|
|
||||||
const url = entry.slice(firstSeparator + 1, lastSeparator).trim();
|
|
||||||
const snapshotsValue = entry
|
|
||||||
.slice(lastSeparator + 1)
|
|
||||||
.trim()
|
|
||||||
.toLowerCase();
|
|
||||||
if (!id || !url || !snapshotsValue) {
|
|
||||||
throw new Error(`Invalid mvn-repositories entry at line ${index + 1}. repository-id, repository URL, and snapshots-enabled are required`);
|
|
||||||
}
|
|
||||||
if (snapshotsValue !== 'true' && snapshotsValue !== 'false') {
|
|
||||||
throw new Error(`Invalid snapshots-enabled value '${snapshotsValue}' in mvn-repositories entry at line ${index + 1}. Expected true or false`);
|
|
||||||
}
|
|
||||||
if (repositoryIds.has(id)) {
|
|
||||||
throw new Error(`Duplicate repository-id '${id}' in mvn-repositories input`);
|
|
||||||
}
|
|
||||||
if (includeCentral && id === _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MAVEN_CENTRAL_REPOSITORY_ID */ .xg) {
|
|
||||||
throw new Error(`Repository-id '${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MAVEN_CENTRAL_REPOSITORY_ID */ .xg}' is reserved when ${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .INPUT_MVN_REPOSITORIES_INCLUDE_CENTRAL */ .H5} is enabled`);
|
|
||||||
}
|
|
||||||
repositoryIds.add(id);
|
|
||||||
repositories.push({
|
|
||||||
id,
|
|
||||||
url,
|
|
||||||
snapshotsEnabled: snapshotsValue === 'true'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return repositories;
|
|
||||||
}
|
|
||||||
async function createAuthenticationSettings(servers, settingsDirectory, overwriteSettings, gpgPassphraseEnvVar = undefined, repositorySettings = undefined) {
|
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__/* .info */ .pq(`Creating ${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MVN_SETTINGS_FILE */ .vO} with server-id: ${servers.map(server => server.id).join(', ')}`);
|
|
||||||
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
||||||
// otherwise use the home/.m2/ path
|
// otherwise use the home/.m2/ path
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_2__/* .mkdirP */ .U$(settingsDirectory);
|
await _actions_io__WEBPACK_IMPORTED_MODULE_2__/* .mkdirP */ .U$(settingsDirectory);
|
||||||
await write(settingsDirectory, generate(servers, gpgPassphraseEnvVar, repositorySettings), overwriteSettings);
|
await write(settingsDirectory, generate(id, usernameEnvVar, passwordEnvVar, gpgPassphraseEnvVar), overwriteSettings);
|
||||||
}
|
}
|
||||||
// only exported for testing purposes
|
// only exported for testing purposes
|
||||||
function generate(servers, gpgPassphraseEnvVar, repositorySettings) {
|
function generate(id, usernameEnvVar, passwordEnvVar, gpgPassphraseEnvVar) {
|
||||||
// The maven-gpg-plugin reads the passphrase from the environment variable
|
// The maven-gpg-plugin reads the passphrase from the environment variable
|
||||||
// named by the `gpg.passphraseEnvName` property (default MAVEN_GPG_PASSPHRASE).
|
// named by the `gpg.passphraseEnvName` property (default MAVEN_GPG_PASSPHRASE).
|
||||||
// Only configure it when the requested env var name differs from that default;
|
// Only configure it when the requested env var name differs from that default;
|
||||||
@@ -184,54 +90,16 @@ function generate(servers, gpgPassphraseEnvVar, repositorySettings) {
|
|||||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
|
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
|
||||||
' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">',
|
' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">',
|
||||||
' <interactiveMode>false</interactiveMode>',
|
' <interactiveMode>false</interactiveMode>',
|
||||||
' <servers>'
|
' <servers>',
|
||||||
|
' <server>',
|
||||||
|
` <id>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(id)}</id>`,
|
||||||
|
` <username>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(`\${env.${usernameEnvVar}}`)}</username>`,
|
||||||
|
` <password>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(`\${env.${passwordEnvVar}}`)}</password>`,
|
||||||
|
' </server>',
|
||||||
|
' </servers>'
|
||||||
];
|
];
|
||||||
for (const server of servers) {
|
|
||||||
lines.push(' <server>', ` <id>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(server.id)}</id>`, ` <username>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(`\${env.${server.usernameEnvVar}}`)}</username>`, ` <password>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(`\${env.${server.passwordEnvVar}}`)}</password>`, ' </server>');
|
|
||||||
}
|
|
||||||
lines.push(' </servers>');
|
|
||||||
if (repositorySettings || includeGpgPassphraseProfile) {
|
|
||||||
lines.push(' <profiles>');
|
|
||||||
if (repositorySettings) {
|
|
||||||
const centralRepository = {
|
|
||||||
id: _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MAVEN_CENTRAL_REPOSITORY_ID */ .xg,
|
|
||||||
url: _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MAVEN_CENTRAL_REPOSITORY_URL */ .jv,
|
|
||||||
snapshotsEnabled: false
|
|
||||||
};
|
|
||||||
const customCentralConfigured = repositorySettings.repositories.some(repository => repository.id === _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MAVEN_CENTRAL_REPOSITORY_ID */ .xg);
|
|
||||||
const repositories = repositorySettings.includeCentral
|
|
||||||
? repositorySettings.prioritizeCentral
|
|
||||||
? [centralRepository, ...repositorySettings.repositories]
|
|
||||||
: [...repositorySettings.repositories, centralRepository]
|
|
||||||
: customCentralConfigured
|
|
||||||
? repositorySettings.repositories
|
|
||||||
: [
|
|
||||||
...repositorySettings.repositories,
|
|
||||||
{ ...centralRepository, releasesEnabled: false }
|
|
||||||
];
|
|
||||||
lines.push(' <profile>', ` <id>${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MAVEN_REPOSITORIES_PROFILE_ID */ .hq}</id>`, ' <repositories>');
|
|
||||||
for (const repository of repositories) {
|
|
||||||
lines.push(' <repository>', ` <id>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(repository.id)}</id>`, ` <url>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(repository.url)}</url>`, ...(repository.releasesEnabled === undefined
|
|
||||||
? []
|
|
||||||
: [
|
|
||||||
' <releases>',
|
|
||||||
` <enabled>${repository.releasesEnabled}</enabled>`,
|
|
||||||
' </releases>'
|
|
||||||
]), ' <snapshots>', ` <enabled>${repository.snapshotsEnabled}</enabled>`, ' </snapshots>', ' </repository>');
|
|
||||||
}
|
|
||||||
lines.push(' </repositories>', ' </profile>');
|
|
||||||
}
|
|
||||||
if (includeGpgPassphraseProfile) {
|
if (includeGpgPassphraseProfile) {
|
||||||
lines.push(' <profile>', ` <id>${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .GPG_PASSPHRASE_PROFILE_ID */ .K$}</id>`, ' <properties>', ` <gpg.passphraseEnvName>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(gpgPassphraseEnvVar)}</gpg.passphraseEnvName>`, ' </properties>', ' </profile>');
|
lines.push(' <profiles>', ' <profile>', ` <id>${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .GPG_PASSPHRASE_PROFILE_ID */ .K$}</id>`, ' <properties>', ` <gpg.passphraseEnvName>${(0,_xml_js__WEBPACK_IMPORTED_MODULE_8__/* .escapeXmlText */ .I)(gpgPassphraseEnvVar)}</gpg.passphraseEnvName>`, ' </properties>', ' </profile>', ' </profiles>', ' <activeProfiles>', ` <activeProfile>${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .GPG_PASSPHRASE_PROFILE_ID */ .K$}</activeProfile>`, ' </activeProfiles>');
|
||||||
}
|
|
||||||
lines.push(' </profiles>', ' <activeProfiles>');
|
|
||||||
if (repositorySettings) {
|
|
||||||
lines.push(` <activeProfile>${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .MAVEN_REPOSITORIES_PROFILE_ID */ .hq}</activeProfile>`);
|
|
||||||
}
|
|
||||||
if (includeGpgPassphraseProfile) {
|
|
||||||
lines.push(` <activeProfile>${_constants_js__WEBPACK_IMPORTED_MODULE_7__/* .GPG_PASSPHRASE_PROFILE_ID */ .K$}</activeProfile>`);
|
|
||||||
}
|
|
||||||
lines.push(' </activeProfiles>');
|
|
||||||
}
|
}
|
||||||
lines.push('</settings>');
|
lines.push('</settings>');
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
@@ -265,8 +133,7 @@ async function write(directory, settings, overwriteSettings) {
|
|||||||
/* harmony export */ Fh: () => (/* binding */ importKey),
|
/* harmony export */ Fh: () => (/* binding */ importKey),
|
||||||
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
/* harmony export */ Yi: () => (/* binding */ verifyPackageSignature),
|
||||||
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
/* harmony export */ mS: () => (/* binding */ removeGpgHome),
|
||||||
/* harmony export */ nY: () => (/* binding */ toGpgPath),
|
/* harmony export */ nY: () => (/* binding */ toGpgPath)
|
||||||
/* harmony export */ o6: () => (/* binding */ isGpgAvailable)
|
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* unused harmony export GPG_HOME_PREFIX */
|
/* unused harmony export GPG_HOME_PREFIX */
|
||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9896);
|
||||||
@@ -288,9 +155,6 @@ async function write(directory, settings, overwriteSettings) {
|
|||||||
|
|
||||||
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||||
async function isGpgAvailable() {
|
|
||||||
return Boolean(await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .which */ .K7('gpg', false));
|
|
||||||
}
|
|
||||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||||
@@ -302,8 +166,8 @@ function toGpgPath(p) {
|
|||||||
.replace(/\\/g, '/')
|
.replace(/\\/g, '/')
|
||||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||||
}
|
}
|
||||||
function createGpgHome(prefix, tempDir = _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4()) {
|
function createGpgHome(prefix) {
|
||||||
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(tempDir, prefix));
|
const gpgHome = fs__WEBPACK_IMPORTED_MODULE_0__.mkdtempSync(path__WEBPACK_IMPORTED_MODULE_1__.join(_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4(), prefix));
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
fs__WEBPACK_IMPORTED_MODULE_0__.chmodSync(gpgHome, 0o700);
|
||||||
}
|
}
|
||||||
@@ -350,24 +214,19 @@ async function removeGpgHome(gpgHome) {
|
|||||||
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(resolvedGpgHome)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await stopGpgAgent(resolvedGpgHome);
|
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
|
||||||
}
|
|
||||||
async function stopGpgAgent(gpgHome) {
|
|
||||||
try {
|
try {
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpgconf', ['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'], { silent: true, ignoreReturnCode: true });
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||||
}
|
}
|
||||||
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(resolvedGpgHome);
|
||||||
}
|
}
|
||||||
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
async function verifyPackageSignature(archivePath, signatureUrl, publicKeyContent) {
|
||||||
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
const signaturePath = await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .downloadTool */ .bq(signatureUrl);
|
||||||
let gpgHome;
|
let gpgHome;
|
||||||
try {
|
try {
|
||||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||||
const tempDir = process.platform === 'darwin' ? '/tmp' : _util_js__WEBPACK_IMPORTED_MODULE_6__/* .getTempDir */ .G4();
|
|
||||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
try {
|
try {
|
||||||
@@ -379,21 +238,15 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
|||||||
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
throw new Error(`Failed to create temporary GPG home directory for signature verification: ${error.message}`, { cause: error });
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const publicKeys = Array.isArray(publicKeyContent)
|
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, 'public-key.asc');
|
||||||
? publicKeyContent
|
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKeyContent, { encoding: 'utf-8' });
|
||||||
: [publicKeyContent];
|
|
||||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
|
||||||
const publicKeyFile = path__WEBPACK_IMPORTED_MODULE_1__.join(gpgHome, `public-key-${index}.asc`);
|
|
||||||
fs__WEBPACK_IMPORTED_MODULE_0__.writeFileSync(publicKeyFile, publicKey, { encoding: 'utf-8' });
|
|
||||||
return toGpgPath(publicKeyFile);
|
|
||||||
});
|
|
||||||
const options = { silent: true };
|
const options = { silent: true };
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||||
'--homedir',
|
'--homedir',
|
||||||
toGpgPath(gpgHome),
|
toGpgPath(gpgHome),
|
||||||
'--batch',
|
'--batch',
|
||||||
'--import',
|
'--import',
|
||||||
...publicKeyFiles
|
toGpgPath(publicKeyFile)
|
||||||
], options);
|
], options);
|
||||||
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
await _actions_exec__WEBPACK_IMPORTED_MODULE_4__/* .exec */ .m('gpg', [
|
||||||
'--homedir',
|
'--homedir',
|
||||||
@@ -405,7 +258,6 @@ async function verifyPackageSignature(archivePath, signatureUrl, publicKeyConten
|
|||||||
], options);
|
], options);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
await stopGpgAgent(gpgHome);
|
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(signaturePath);
|
||||||
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
await _actions_io__WEBPACK_IMPORTED_MODULE_3__/* .rmRF */ .Yz(gpgHome);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+7
-154
@@ -418,102 +418,9 @@ function readAttributeStr(xmlData, i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Walk `attrStr` once, left to right, splitting it into attribute tokens.
|
* Select all the attributes whether valid or invalid.
|
||||||
*
|
|
||||||
* This replaces a regex that used to do the same job
|
|
||||||
* (`(\s*)([^\s=]+)(\s*=)?(\s*(['"])(([\s\S])*?)\5)?`). That regex led with an
|
|
||||||
* optional whitespace group followed by a required "non-whitespace" group.
|
|
||||||
* On a long run of whitespace that never resolves into an attribute name
|
|
||||||
* (e.g. a tag with thousands of trailing spaces before `>`), the engine
|
|
||||||
* backtracks the whitespace group one character at a time before giving up
|
|
||||||
* and moving to the next starting position — one full backtrack per
|
|
||||||
* position, which is quadratic in the length of the run.
|
|
||||||
*
|
|
||||||
* A single forward-only scan can never backtrack, so it can't be made slow
|
|
||||||
* this way no matter how much whitespace the input contains — it's always
|
|
||||||
* proportional to the length of the string, once.
|
|
||||||
*
|
|
||||||
* Each returned token mirrors the shape the old regex match array had, so
|
|
||||||
* the validation logic below (which reads token[1]..token[6]) didn't need
|
|
||||||
* to change:
|
|
||||||
* token.startIndex - where this token begins in attrStr
|
|
||||||
* token[1] - leading whitespace before the name
|
|
||||||
* token[2] - the attribute name
|
|
||||||
* token[3] - whitespace + '=' if present, else undefined
|
|
||||||
* token[4] - marker (any defined value) if a quoted value was found
|
|
||||||
* token[5] - the quote character used ('"' or "'")
|
|
||||||
* token[6] - the value's text, without the surrounding quotes
|
|
||||||
*
|
|
||||||
* A malformed leading character (e.g. a stray '=' with no name before it)
|
|
||||||
* is simply skipped over, one character at a time — the same outcome the
|
|
||||||
* old regex produced by failing to match at that position and retrying at
|
|
||||||
* the next one.
|
|
||||||
*/
|
*/
|
||||||
function scanAttributeTokens(attrStr) {
|
const validAttrStrRegxp = new RegExp('(\\s*)([^\\s=]+)(\\s*=)?(\\s*([\'"])(([\\s\\S])*?)\\5)?', 'g');
|
||||||
const tokens = [];
|
|
||||||
const len = attrStr.length;
|
|
||||||
let i = 0;
|
|
||||||
|
|
||||||
while (i < len) {
|
|
||||||
const tokenStart = i;
|
|
||||||
|
|
||||||
// Leading whitespace before the name.
|
|
||||||
while (i < len && isWhiteSpace(attrStr[i])) i++;
|
|
||||||
if (i >= len) break; // trailing whitespace only — nothing left to read
|
|
||||||
|
|
||||||
if (attrStr[i] === '=') {
|
|
||||||
// No name before this '=' — not a valid attribute start. Move past
|
|
||||||
// just this one character and try again from the next position.
|
|
||||||
i = tokenStart + 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const leadingWs = attrStr.slice(tokenStart, i);
|
|
||||||
|
|
||||||
// Attribute name — everything up to the next whitespace or '='.
|
|
||||||
const nameStart = i;
|
|
||||||
while (i < len && !isWhiteSpace(attrStr[i]) && attrStr[i] !== '=') i++;
|
|
||||||
const name = attrStr.slice(nameStart, i);
|
|
||||||
|
|
||||||
// Optional whitespace + '='.
|
|
||||||
let equalsGroup; // whitespace + '=' text, or undefined if absent
|
|
||||||
let j = i;
|
|
||||||
while (j < len && isWhiteSpace(attrStr[j])) j++;
|
|
||||||
if (j < len && attrStr[j] === '=') {
|
|
||||||
equalsGroup = attrStr.slice(i, j + 1);
|
|
||||||
i = j + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optional whitespace + quoted value.
|
|
||||||
let quoteChar;
|
|
||||||
let value;
|
|
||||||
let k = i;
|
|
||||||
while (k < len && isWhiteSpace(attrStr[k])) k++;
|
|
||||||
if (k < len && (attrStr[k] === '"' || attrStr[k] === "'")) {
|
|
||||||
const valueStart = k + 1;
|
|
||||||
const closeIdx = attrStr.indexOf(attrStr[k], valueStart);
|
|
||||||
if (closeIdx !== -1) {
|
|
||||||
quoteChar = attrStr[k];
|
|
||||||
value = attrStr.slice(valueStart, closeIdx);
|
|
||||||
i = closeIdx + 1;
|
|
||||||
}
|
|
||||||
// No closing quote found anywhere in the rest of the string — leave
|
|
||||||
// quoteChar/value undefined, same as the old regex's group failing
|
|
||||||
// to match a backreference-less run.
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = { startIndex: tokenStart };
|
|
||||||
token[1] = leadingWs;
|
|
||||||
token[2] = name;
|
|
||||||
token[3] = equalsGroup;
|
|
||||||
token[4] = quoteChar !== undefined ? true : undefined;
|
|
||||||
token[5] = quoteChar;
|
|
||||||
token[6] = value;
|
|
||||||
tokens.push(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tokens;
|
|
||||||
}
|
|
||||||
|
|
||||||
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
|
//attr, ="sd", a="amit's", a="sd"b="saf", ab cd=""
|
||||||
|
|
||||||
@@ -522,7 +429,7 @@ function validateAttributeString(attrStr, options) {
|
|||||||
|
|
||||||
//if(attrStr.trim().length === 0) return true; //empty string
|
//if(attrStr.trim().length === 0) return true; //empty string
|
||||||
|
|
||||||
const matches = scanAttributeTokens(attrStr);
|
const matches = (0,_util_js__WEBPACK_IMPORTED_MODULE_0__/* .getAllMatches */ .Xe)(attrStr, validAttrStrRegxp);
|
||||||
const attrNames = {};
|
const attrNames = {};
|
||||||
|
|
||||||
for (let i = 0; i < matches.length; i++) {
|
for (let i = 0; i < matches.length; i++) {
|
||||||
@@ -625,6 +532,7 @@ function getPositionFromMatch(match) {
|
|||||||
return match.startIndex + match[1].length;
|
return match.startIndex + match[1].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6009:
|
/***/ 6009:
|
||||||
@@ -833,26 +741,12 @@ class XmlNode {
|
|||||||
this.child.push({ [node.tagname]: node.child });
|
this.child.push({ [node.tagname]: node.child });
|
||||||
}
|
}
|
||||||
// if requested, add the startIndex
|
// if requested, add the startIndex
|
||||||
this.addStartIndex(startIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
addStartIndex(startIndex) {
|
|
||||||
if (startIndex !== undefined) {
|
if (startIndex !== undefined) {
|
||||||
// Note: for now we just overwrite the metadata. If we had more complex metadata,
|
// Note: for now we just overwrite the metadata. If we had more complex metadata,
|
||||||
// we might need to do an object append here: metadata = { ...metadata, startIndex }
|
// we might need to do an object append here: metadata = { ...metadata, startIndex }
|
||||||
this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
|
this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addEndIndex(endIndex) {
|
|
||||||
const lastChild = this.child[this.child.length - 1];
|
|
||||||
// endIndex is write-once: when updateTag drops a node, the last child is a
|
|
||||||
// previously completed sibling whose endIndex must not be overwritten
|
|
||||||
if (lastChild !== undefined && lastChild[METADATA_SYMBOL] !== undefined
|
|
||||||
&& lastChild[METADATA_SYMBOL].endIndex === undefined) {
|
|
||||||
lastChild[METADATA_SYMBOL].endIndex = endIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** symbol used for metadata */
|
/** symbol used for metadata */
|
||||||
static getMetaDataSymbol() {
|
static getMetaDataSymbol() {
|
||||||
return METADATA_SYMBOL;
|
return METADATA_SYMBOL;
|
||||||
@@ -887,23 +781,8 @@ class DocTypeReader {
|
|||||||
i = i + 9;
|
i = i + 9;
|
||||||
let angleBracketsCount = 1;
|
let angleBracketsCount = 1;
|
||||||
let hasBody = false, comment = false;
|
let hasBody = false, comment = false;
|
||||||
let quoteChar = null; // tracks an open SYSTEM/PUBLIC literal before the '[' body
|
|
||||||
let exp = "";
|
let exp = "";
|
||||||
for (; i < xmlData.length; i++) {
|
for (; i < xmlData.length; i++) {
|
||||||
// Inside a quoted external-identifier literal — XML allows '<'
|
|
||||||
// and '>' as plain data here, so they must not be interpreted
|
|
||||||
// as DOCTYPE structure until the matching quote closes.
|
|
||||||
if (quoteChar !== null) {
|
|
||||||
if (xmlData[i] === quoteChar) quoteChar = null;
|
|
||||||
exp += xmlData[i];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!hasBody && !comment && (xmlData[i] === '"' || xmlData[i] === "'")) {
|
|
||||||
quoteChar = xmlData[i];
|
|
||||||
exp += xmlData[i];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xmlData[i] === '<' && !comment) { //Determine the tag type
|
if (xmlData[i] === '<' && !comment) { //Determine the tag type
|
||||||
if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
|
if (hasBody && hasSeq(xmlData, "!ENTITY", i)) {
|
||||||
i += 7;
|
i += 7;
|
||||||
@@ -958,7 +837,7 @@ class DocTypeReader {
|
|||||||
exp += xmlData[i];
|
exp += xmlData[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (quoteChar !== null || angleBracketsCount !== 0) {
|
if (angleBracketsCount !== 0) {
|
||||||
throw new Error(`Unclosed DOCTYPE`);
|
throw new Error(`Unclosed DOCTYPE`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1673,11 +1552,7 @@ function resolveEnotation(str, trimmedStr, options) {
|
|||||||
*/
|
*/
|
||||||
function trimZeros(numStr) {
|
function trimZeros(numStr) {
|
||||||
if (numStr && numStr.indexOf(".") !== -1) {//float
|
if (numStr && numStr.indexOf(".") !== -1) {//float
|
||||||
//remove ending zeros without the O(n^2) backtracking that /0+$/ hits
|
numStr = numStr.replace(/0+$/, ""); //remove ending zeros
|
||||||
//when the string doesn't end in 0 but has a long internal zero-run
|
|
||||||
let end = numStr.length;
|
|
||||||
while (end > 0 && numStr.charCodeAt(end - 1) === 48 /* '0' */) end--;
|
|
||||||
numStr = numStr.slice(0, end);
|
|
||||||
if (numStr === ".") numStr = "0";
|
if (numStr === ".") numStr = "0";
|
||||||
else if (numStr[0] === ".") numStr = "0" + numStr;
|
else if (numStr[0] === ".") numStr = "0" + numStr;
|
||||||
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
|
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substring(0, numStr.length - 1);
|
||||||
@@ -5157,12 +5032,7 @@ const parseXml = function (xmlData) {
|
|||||||
this.matcher.pop();
|
this.matcher.pop();
|
||||||
this.isCurrentNodeStopNode = false; // Reset flag when closing tag
|
this.isCurrentNodeStopNode = false; // Reset flag when closing tag
|
||||||
|
|
||||||
//a closing tag with no matching opening tag leaves the stack empty
|
currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope
|
||||||
currentNode = this.tagsNodeStack.pop() || xmlObj;//avoid recursion, set the parent tag scope
|
|
||||||
|
|
||||||
if (options.captureMetaData && currentNode) {
|
|
||||||
currentNode.addEndIndex(closeIndex + 1);
|
|
||||||
}
|
|
||||||
textData = "";
|
textData = "";
|
||||||
i = closeIndex;
|
i = closeIndex;
|
||||||
} else if (c1 === 63) { //'?'
|
} else if (c1 === 63) { //'?'
|
||||||
@@ -5188,11 +5058,6 @@ const parseXml = function (xmlData) {
|
|||||||
childNode[":@"] = attsMap
|
childNode[":@"] = attsMap
|
||||||
}
|
}
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
// closeIndex points at '?' of the closing '?>'
|
|
||||||
currentNode.addEndIndex(tagData.closeIndex + 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5357,10 +5222,6 @@ const parseXml = function (xmlData) {
|
|||||||
this.isCurrentNodeStopNode = false; // Reset flag
|
this.isCurrentNodeStopNode = false; // Reset flag
|
||||||
|
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
currentNode.addEndIndex(i + 1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//selfClosing tag
|
//selfClosing tag
|
||||||
if (isSelfClosing) {
|
if (isSelfClosing) {
|
||||||
@@ -5371,10 +5232,6 @@ const parseXml = function (xmlData) {
|
|||||||
childNode[":@"] = prefixedAttrs;
|
childNode[":@"] = prefixedAttrs;
|
||||||
}
|
}
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
currentNode.addEndIndex(closeIndex + 1);
|
|
||||||
}
|
|
||||||
this.matcher.pop(); // Pop self-closing tag
|
this.matcher.pop(); // Pop self-closing tag
|
||||||
this.isCurrentNodeStopNode = false; // Reset flag
|
this.isCurrentNodeStopNode = false; // Reset flag
|
||||||
}
|
}
|
||||||
@@ -5384,10 +5241,6 @@ const parseXml = function (xmlData) {
|
|||||||
childNode[":@"] = prefixedAttrs;
|
childNode[":@"] = prefixedAttrs;
|
||||||
}
|
}
|
||||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||||
|
|
||||||
if (options.captureMetaData) {
|
|
||||||
currentNode.addEndIndex(result.closeIndex + 1);
|
|
||||||
}
|
|
||||||
this.matcher.pop(); // Pop unpaired tag
|
this.matcher.pop(); // Pop unpaired tag
|
||||||
this.isCurrentNodeStopNode = false; // Reset flag
|
this.isCurrentNodeStopNode = false; // Reset flag
|
||||||
i = result.closeIndex;
|
i = result.closeIndex;
|
||||||
|
|||||||
Vendored
+18
-62
@@ -52431,24 +52431,6 @@ const EXPANSION_MAX = 100_000;
|
|||||||
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
||||||
// characters) so legitimate input is unaffected.
|
// characters) so legitimate input is unaffected.
|
||||||
const EXPANSION_MAX_LENGTH = 4_000_000;
|
const EXPANSION_MAX_LENGTH = 4_000_000;
|
||||||
// `expand_` recurses once per level of brace *nesting* - both when expanding a
|
|
||||||
// set's comma members and when re-wrapping a set whose body is a single part.
|
|
||||||
// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
|
|
||||||
// level per chained group), which left nesting depth unbounded: about 3,100
|
|
||||||
// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
|
|
||||||
// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
|
|
||||||
// will follow nesting. It sits far above any realistic pattern and well below
|
|
||||||
// the depth at which the stack runs out.
|
|
||||||
const EXPANSION_MAX_DEPTH = 1_000;
|
|
||||||
// Bash keeps a quirk where a brace group followed by a comma set still expands
|
|
||||||
// (`{a},b}`). The parser implements it by rewriting the string and restarting
|
|
||||||
// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
|
|
||||||
// full passes over a string that itself grows by one `escClose` sentinel each
|
|
||||||
// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
|
|
||||||
// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
|
|
||||||
// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
|
|
||||||
// times the scan may restart. Real `{a},b}` input needs a handful.
|
|
||||||
const EXPANSION_MAX_REWRITES = 1_000;
|
|
||||||
function numeric(str) {
|
function numeric(str) {
|
||||||
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
||||||
}
|
}
|
||||||
@@ -52468,52 +52450,37 @@ function unescapeBraces(str) {
|
|||||||
.replace(escCommaPattern, ',')
|
.replace(escCommaPattern, ',')
|
||||||
.replace(escPeriodPattern, '.');
|
.replace(escPeriodPattern, '.');
|
||||||
}
|
}
|
||||||
// Like `target.push(...items)` but doesn't overflow the stack
|
|
||||||
function pushAll(target, items) {
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
|
||||||
target.push(items[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Basically just str.split(","), but handling cases
|
* Basically just str.split(","), but handling cases
|
||||||
* where we have nested braced sections, which should be
|
* where we have nested braced sections, which should be
|
||||||
* treated as individual members, like {a,{b,c},d}
|
* treated as individual members, like {a,{b,c},d}
|
||||||
*/
|
*/
|
||||||
function parseCommaParts(str) {
|
function parseCommaParts(str) {
|
||||||
|
if (!str) {
|
||||||
|
return [''];
|
||||||
|
}
|
||||||
const parts = [];
|
const parts = [];
|
||||||
// Walk the brace groups iteratively. Recursing on `post` once per group let a
|
|
||||||
// chain of them exhaust the stack - the parsing-side counterpart to
|
|
||||||
// the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or
|
|
||||||
// `maxLength` can bound, since it happens before expansion.
|
|
||||||
//
|
|
||||||
// The part the next chunk continues
|
|
||||||
let carry = '';
|
|
||||||
for (;;) {
|
|
||||||
const m = balanced('{', '}', str);
|
const m = balanced('{', '}', str);
|
||||||
if (!m) {
|
if (!m) {
|
||||||
const tail = str.split(',');
|
return str.split(',');
|
||||||
tail[0] = carry + tail[0];
|
|
||||||
pushAll(parts, tail);
|
|
||||||
return parts;
|
|
||||||
}
|
}
|
||||||
const { pre, body, post } = m;
|
const { pre, body, post } = m;
|
||||||
const p = pre.split(',');
|
const p = pre.split(',');
|
||||||
p[0] = carry + p[0];
|
|
||||||
p[p.length - 1] += '{' + body + '}';
|
p[p.length - 1] += '{' + body + '}';
|
||||||
if (!post.length) {
|
const postParts = parseCommaParts(post);
|
||||||
pushAll(parts, p);
|
if (post.length) {
|
||||||
|
;
|
||||||
|
p[p.length - 1] += postParts.shift();
|
||||||
|
p.push.apply(p, postParts);
|
||||||
|
}
|
||||||
|
parts.push.apply(parts, p);
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
carry = p.pop();
|
|
||||||
pushAll(parts, p);
|
|
||||||
str = post;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function expand(str, options = {}) {
|
function expand(str, options = {}) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES, } = options;
|
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
||||||
// I don't know why Bash 4.3 does this, but it does.
|
// I don't know why Bash 4.3 does this, but it does.
|
||||||
// Anything starting with {} will have the first two bytes preserved
|
// Anything starting with {} will have the first two bytes preserved
|
||||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||||
@@ -52523,7 +52490,7 @@ function expand(str, options = {}) {
|
|||||||
if (str.slice(0, 2) === '{}') {
|
if (str.slice(0, 2) === '{}') {
|
||||||
str = '\\{\\}' + str.slice(2);
|
str = '\\{\\}' + str.slice(2);
|
||||||
}
|
}
|
||||||
return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
|
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
||||||
}
|
}
|
||||||
function embrace(str) {
|
function embrace(str) {
|
||||||
return '{' + str + '}';
|
return '{' + str + '}';
|
||||||
@@ -52618,13 +52585,7 @@ function expandSequence(body, isAlphaSequence, max, maxLength) {
|
|||||||
}
|
}
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
function expand_(str, max, maxLength, isTop) {
|
||||||
// Too deeply nested to keep following: treat the rest as literal, the same
|
|
||||||
// way a group that cannot expand is already handled. Truncating rather than
|
|
||||||
// throwing keeps `expand` total, matching `max` and `maxLength`.
|
|
||||||
if (depth > maxDepth) {
|
|
||||||
return [str];
|
|
||||||
}
|
|
||||||
// Consume the string's top-level brace groups left to right, threading a
|
// Consume the string's top-level brace groups left to right, threading a
|
||||||
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
||||||
// rather than recursing on `m.post` once per group - keeps the native stack
|
// rather than recursing on `m.post` once per group - keeps the native stack
|
||||||
@@ -52636,9 +52597,6 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
||||||
// is on the final strings, so it is applied to whichever `combine` produces
|
// is on the final strings, so it is applied to whichever `combine` produces
|
||||||
// them (the one with no brace set left in the tail).
|
// them (the one with no brace set left in the tail).
|
||||||
// How many times the `{a},b}` rewrite below has restarted the scan. Each pass
|
|
||||||
// re-reads the whole string, so leaving this unbounded is quadratic.
|
|
||||||
let rewrites = 0;
|
|
||||||
let dropEmpties = false;
|
let dropEmpties = false;
|
||||||
let firstGroup = true;
|
let firstGroup = true;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -52663,8 +52621,7 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
const isOptions = m.body.indexOf(',') >= 0;
|
const isOptions = m.body.indexOf(',') >= 0;
|
||||||
if (!isSequence && !isOptions) {
|
if (!isSequence && !isOptions) {
|
||||||
// {a},b}
|
// {a},b}
|
||||||
if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
|
if (m.post.match(/,(?!,).*\}/)) {
|
||||||
rewrites++;
|
|
||||||
str = m.pre + '{' + m.body + escClose + m.post;
|
str = m.pre + '{' + m.body + escClose + m.post;
|
||||||
isTop = true;
|
isTop = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -52684,7 +52641,7 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
let n = parseCommaParts(m.body);
|
let n = parseCommaParts(m.body);
|
||||||
if (n.length === 1 && n[0] !== undefined) {
|
if (n.length === 1 && n[0] !== undefined) {
|
||||||
// x{{a,b}}y ==> x{a}y x{b}y
|
// x{{a,b}}y ==> x{a}y x{b}y
|
||||||
n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
|
n = expand_(n[0], max, maxLength, false).map(embrace);
|
||||||
//XXX is this necessary? Can't seem to hit it in tests.
|
//XXX is this necessary? Can't seem to hit it in tests.
|
||||||
/* c8 ignore start */
|
/* c8 ignore start */
|
||||||
if (n.length === 1) {
|
if (n.length === 1) {
|
||||||
@@ -52710,13 +52667,12 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|||||||
values = [];
|
values = [];
|
||||||
let valuesLength = 0;
|
let valuesLength = 0;
|
||||||
outer: for (let j = 0; j < n.length; j++) {
|
outer: for (let j = 0; j < n.length; j++) {
|
||||||
const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
|
const expanded = expand_(n[j], max, maxLength, false);
|
||||||
for (let k = 0; k < expanded.length; k++) {
|
for (let k = 0; k < expanded.length; k++) {
|
||||||
const v = expanded[k];
|
const v = expanded[k];
|
||||||
if (dropsEmpties && !v)
|
if (dropsEmpties && !v)
|
||||||
continue;
|
continue;
|
||||||
if (values.length >= max ||
|
if (values.length >= max || valuesLength + v.length > maxLength) {
|
||||||
valuesLength + v.length > maxLength) {
|
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
values.push(v);
|
values.push(v);
|
||||||
|
|||||||
Vendored
+20
-32
@@ -13,26 +13,19 @@ export const modules = {
|
|||||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9896);
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9896);
|
||||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_2__);
|
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_2__);
|
||||||
/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6242);
|
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2088);
|
||||||
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7444);
|
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(semver__WEBPACK_IMPORTED_MODULE_3__);
|
||||||
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4527);
|
/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6242);
|
||||||
|
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7444);
|
||||||
|
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4527);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function compareNumberArrays(a, b) {
|
|
||||||
const length = Math.max(a.length, b.length);
|
class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4__/* .JavaBase */ .O {
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
const diff = (a[i] ?? 0) - (b[i] ?? 0);
|
|
||||||
if (diff !== 0) {
|
|
||||||
return diff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__/* .JavaBase */ .O {
|
|
||||||
constructor(installerOptions) {
|
constructor(installerOptions) {
|
||||||
super('Zulu', installerOptions);
|
super('Zulu', installerOptions);
|
||||||
}
|
}
|
||||||
@@ -46,24 +39,19 @@ class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__/*
|
|||||||
? [...item.java_version, item.openjdk_build_number]
|
? [...item.java_version, item.openjdk_build_number]
|
||||||
: item.java_version;
|
: item.java_version;
|
||||||
return {
|
return {
|
||||||
version: (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .convertVersionToSemver */ .ZY)(javaVersion),
|
version: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .convertVersionToSemver */ .ZY)(javaVersion),
|
||||||
url: item.download_url,
|
url: item.download_url,
|
||||||
javaVersion: item.java_version,
|
zuluVersion: (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .convertVersionToSemver */ .ZY)(item.distro_version),
|
||||||
buildNumber: item.openjdk_build_number ?? 0,
|
|
||||||
distroVersion: item.distro_version,
|
|
||||||
packageUuid: item.package_uuid
|
packageUuid: item.package_uuid
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const satisfiedVersions = availableVersions
|
const satisfiedVersions = availableVersions
|
||||||
.filter(item => (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .isVersionSatisfies */ .y)(version, item.version))
|
.filter(item => (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .isVersionSatisfies */ .y)(version, item.version))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
// Compare numerically rather than via semver build metadata: Azul
|
// Azul provides two versions: java_version and distro_version
|
||||||
// hotfix releases carry a 4th java_version segment (e.g. 25.0.4.1+1,
|
// we should sort by both fields by descending
|
||||||
// rendered as '25.0.4+1.1') that must rank above 25.0.4+7, whereas
|
return (-semver__WEBPACK_IMPORTED_MODULE_3___default().compareBuild(a.version, b.version) ||
|
||||||
// semver.compareBuild would order the build identifiers '7' > '1'.
|
-semver__WEBPACK_IMPORTED_MODULE_3___default().compareBuild(a.zuluVersion, b.zuluVersion));
|
||||||
return (-compareNumberArrays(a.javaVersion, b.javaVersion) ||
|
|
||||||
b.buildNumber - a.buildNumber ||
|
|
||||||
-compareNumberArrays(a.distroVersion, b.distroVersion));
|
|
||||||
})
|
})
|
||||||
.map((item) => ({
|
.map((item) => ({
|
||||||
version: item.version,
|
version: item.version,
|
||||||
@@ -97,21 +85,21 @@ class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__/*
|
|||||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Extracting Java archive...`);
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Extracting Java archive...`);
|
||||||
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .getDownloadArchiveExtension */ .ag)();
|
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getDownloadArchiveExtension */ .ag)();
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .renameWinArchive */ .n2)(javaArchivePath);
|
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .renameWinArchive */ .n2)(javaArchivePath);
|
||||||
}
|
}
|
||||||
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
|
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
|
||||||
const archiveName = fs__WEBPACK_IMPORTED_MODULE_2___default().readdirSync(extractedJavaPath)[0];
|
const archiveName = fs__WEBPACK_IMPORTED_MODULE_2___default().readdirSync(extractedJavaPath)[0];
|
||||||
const archivePath = path__WEBPACK_IMPORTED_MODULE_1___default().join(extractedJavaPath, archiveName);
|
const archivePath = path__WEBPACK_IMPORTED_MODULE_1___default().join(extractedJavaPath, archiveName);
|
||||||
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
||||||
return { version: javaRelease.version, path: javaPath };
|
return { version: javaRelease.version, path: javaPath };
|
||||||
}
|
}
|
||||||
async getAvailableVersions() {
|
async getAvailableVersions() {
|
||||||
const arch = this.getArchitectureOptions();
|
const arch = this.getArchitectureOptions();
|
||||||
const [bundleType, features] = this.packageType.split('+');
|
const [bundleType, features] = this.packageType.split('+');
|
||||||
const platform = this.getPlatformOption();
|
const platform = this.getPlatformOption();
|
||||||
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_5__/* .getDownloadArchiveExtension */ .ag)();
|
const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_6__/* .getDownloadArchiveExtension */ .ag)();
|
||||||
const javafx = features?.includes('fx') ?? false;
|
const javafx = features?.includes('fx') ?? false;
|
||||||
const crac = features?.includes('crac') ?? false;
|
const crac = features?.includes('crac') ?? false;
|
||||||
const releaseStatus = this.stable ? 'ga' : 'ea';
|
const releaseStatus = this.stable ? 'ga' : 'ea';
|
||||||
@@ -197,7 +185,7 @@ class ZuluDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_3__/*
|
|||||||
// The new Metadata API's "linux" value returns both glibc and musl
|
// The new Metadata API's "linux" value returns both glibc and musl
|
||||||
// packages, so target the libc the runner actually has. A glibc JDK
|
// packages, so target the libc the runner actually has. A glibc JDK
|
||||||
// cannot run on Alpine.
|
// cannot run on Alpine.
|
||||||
return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_4__/* .isAlpineLinux */ .G6)() ? 'linux_musl' : 'linux_glibc';
|
return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_5__/* .isAlpineLinux */ .G6)() ? 'linux_musl' : 'linux_glibc';
|
||||||
default:
|
default:
|
||||||
return process.platform;
|
return process.platform;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+192
-546
File diff suppressed because it is too large
Load Diff
+20
-155
@@ -27,7 +27,6 @@
|
|||||||
- [Testing against different Java distributions](#Testing-against-different-Java-distributions)
|
- [Testing against different Java distributions](#Testing-against-different-Java-distributions)
|
||||||
- [Testing against different platforms](#Testing-against-different-platforms)
|
- [Testing against different platforms](#Testing-against-different-platforms)
|
||||||
- [Publishing using Apache Maven](#Publishing-using-Apache-Maven)
|
- [Publishing using Apache Maven](#Publishing-using-Apache-Maven)
|
||||||
- [Publishing to multiple Maven servers](#publishing-to-multiple-maven-servers)
|
|
||||||
- [Apache Maven with a settings path](#apache-maven-with-a-settings-path)
|
- [Apache Maven with a settings path](#apache-maven-with-a-settings-path)
|
||||||
- [Maven transfer progress (download logs)](#Maven-transfer-progress-download-logs)
|
- [Maven transfer progress (download logs)](#Maven-transfer-progress-download-logs)
|
||||||
- [Java problem matcher (compiler annotations)](#java-problem-matcher-compiler-annotations)
|
- [Java problem matcher (compiler annotations)](#java-problem-matcher-compiler-annotations)
|
||||||
@@ -39,6 +38,15 @@
|
|||||||
|
|
||||||
See [action.yml](../action.yml) for more details on task inputs.
|
See [action.yml](../action.yml) for more details on task inputs.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The examples on this page reference `actions/setup-java@v6`, which is still in
|
||||||
|
> development on the `main` branch and is not yet published as a release tag. To
|
||||||
|
> try the V6 features documented here (`cache-jdk`, `force-download`,
|
||||||
|
> `problem-matcher`, `cache-path`, `cache-read-only`, `java-version: latest`,
|
||||||
|
> `oracle-openjdk`, and the `*-env-var` input names), reference
|
||||||
|
> `actions/setup-java@main`. For production workflows use the latest stable
|
||||||
|
> release, `actions/setup-java@v5`, as shown in the [README](../README.md).
|
||||||
|
|
||||||
## Selecting a Java distribution
|
## Selecting a Java distribution
|
||||||
`java-version` and `distribution` select what gets installed. `java-version` may be replaced by `java-version-file`, and `distribution` is optional only when `java-version-file` points to a `.sdkmanrc` or `.tool-versions` file that carries a recognized vendor identifier. In every other case both inputs must be provided. See [Supported distributions](../README.md#Supported-distributions) for a list of available options.
|
`java-version` and `distribution` select what gets installed. `java-version` may be replaced by `java-version-file`, and `distribution` is optional only when `java-version-file` points to a `.sdkmanrc` or `.tool-versions` file that carries a recognized vendor identifier. In every other case both inputs must be provided. See [Supported distributions](../README.md#Supported-distributions) for a list of available options.
|
||||||
|
|
||||||
@@ -68,19 +76,6 @@ steps:
|
|||||||
- run: java --version
|
- run: java --version
|
||||||
```
|
```
|
||||||
|
|
||||||
### Red Hat Build of OpenJDK
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v7
|
|
||||||
- uses: actions/setup-java@v6
|
|
||||||
with:
|
|
||||||
distribution: 'redhat'
|
|
||||||
java-version: '21'
|
|
||||||
java-package: jdk # optional (jdk or jre) - defaults to jdk
|
|
||||||
- run: java --version
|
|
||||||
```
|
|
||||||
|
|
||||||
### Liberica
|
### Liberica
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@@ -333,7 +328,6 @@ The package types have these meanings:
|
|||||||
| `corretto` | `jdk`, `jre` | Accepts major versions only. JDK availability follows Amazon's platform catalog. For the operating systems directly selected by `setup-java`, JRE downloads are limited to Java 8 on Windows; Linux and macOS use `jdk`. |
|
| `corretto` | `jdk`, `jre` | Accepts major versions only. JDK availability follows Amazon's platform catalog. For the operating systems directly selected by `setup-java`, JRE downloads are limited to Java 8 on Windows; Linux and macOS use `jdk`. |
|
||||||
| `oracle` | `jdk` | Stable Oracle JDK 17 and later only. |
|
| `oracle` | `jdk` | Stable Oracle JDK 17 and later only. |
|
||||||
| `oracle-openjdk` | `jdk` | Installs the GA or early-access JDK builds currently listed or archived on `jdk.java.net`; use a `-ea` version such as `27-ea` for early access. |
|
| `oracle-openjdk` | `jdk` | Installs the GA or early-access JDK builds currently listed or archived on `jdk.java.net`; use a `-ea` version such as `27-ea` for early access. |
|
||||||
| `redhat` | `jdk`, `jre` | Stable builds only. Version availability follows the Foojay Disco catalog for Red Hat Build of OpenJDK and can lag Red Hat's downloads page. |
|
|
||||||
| `dragonwell` | `jdk` | Stable builds only. The current vendor catalog provides Java 8, 11, 17, 21, and 25. |
|
| `dragonwell` | `jdk` | Stable builds only. The current vendor catalog provides Java 8, 11, 17, 21, and 25. |
|
||||||
| `sapmachine` | `jdk`, `jre` | Follows the SapMachine catalog. Both editions are represented from Java 10 onward, but individual versions and platforms can differ. |
|
| `sapmachine` | `jdk`, `jre` | Follows the SapMachine catalog. Both editions are represented from Java 10 onward, but individual versions and platforms can differ. |
|
||||||
| `graalvm` | `jdk` | Stable Oracle GraalVM for JDK 17 and later only. |
|
| `graalvm` | `jdk` | Stable Oracle GraalVM for JDK 17 and later only. |
|
||||||
@@ -539,27 +533,18 @@ tool-cache installation short-circuits setup, so a changed `jdk-file` is not
|
|||||||
re-extracted for a version that is already installed. Use
|
re-extracted for a version that is already installed. Use
|
||||||
`force-download: true` when the archive contents change but the version does not.
|
`force-download: true` when the archive contents change but the version does not.
|
||||||
|
|
||||||
The verification identity separates requests that disable signature verification,
|
The verification identity separates unverified downloads from packages verified
|
||||||
check and warn without enforcement, or explicitly enforce verification. Disabled
|
with the distribution's bundled signing key and from packages verified with each
|
||||||
and check-and-warn requests have the same non-enforcement guarantee, but they are
|
custom key. Custom public keys are represented by a SHA-256 fingerprint of
|
||||||
kept separate so an entry downloaded with verification disabled cannot prevent a
|
normalized key material; the key itself is not placed in the cache key, the logs,
|
||||||
later check-and-warn request from attempting verification. The identity also
|
or action state. A verified exact-key hit reuses content that was
|
||||||
separates the distribution's bundled signing keys from custom keys. Custom
|
signature-verified when it was downloaded by the run that saved the entry,
|
||||||
public-key sets are represented by a SHA-256 fingerprint of normalized,
|
instead of downloading and verifying it again.
|
||||||
boundary-delimited key material; the keys themselves are not placed in the cache
|
|
||||||
key, the logs, or action state. Enforced requests only restore entries created by
|
|
||||||
an enforced request whose signature verification succeeded. Check-and-warn entries
|
|
||||||
may have been saved after verification succeeded or after a verification failure
|
|
||||||
was reported as a warning.
|
|
||||||
|
|
||||||
For signature-verification defaults, enforced failure behavior, and recovery from
|
|
||||||
a legitimate vendor signing-key rotation, see
|
|
||||||
[Download integrity and signatures](../README.md#download-integrity-and-signatures).
|
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> The JDK cache **key** isolates disabled, check-and-warn, and enforced verification
|
> The JDK cache **key** is what isolates verification modes and release
|
||||||
> modes as well as release identity. A check-and-warn entry can never be restored
|
> identity: a JDK cache entry created by an unverified download can never be
|
||||||
> for a request that sets `verify-signature: true`, and vice versa.
|
> restored for a request that sets `verify-signature: true`, and vice versa.
|
||||||
> `cache-jdk` does not change how the runner tool cache is used. setup-java
|
> `cache-jdk` does not change how the runner tool cache is used. setup-java
|
||||||
> first looks for an installation in the runner tool cache — a preinstalled
|
> first looks for an installation in the runner tool cache — a preinstalled
|
||||||
> JDK, or one installed by an earlier step of the same job — and uses it as-is. Such an installation is not downloaded again, and its checksum
|
> JDK, or one installed by an earlier step of the same job — and uses it as-is. Such an installation is not downloaded again, and its checksum
|
||||||
@@ -649,7 +634,7 @@ absent from a vendor catalog.
|
|||||||
|
|
||||||
| Distribution | Linux | macOS | Windows | Other / version restrictions |
|
| Distribution | Linux | macOS | Windows | Other / version restrictions |
|
||||||
| --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- |
|
||||||
| `temurin` | `x64`, `x86`, `armv7`, `aarch64`, `ppc64le`, `riscv64`, `s390x` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | Linux `armv7` is available through Java 17. |
|
| `temurin` | `x64`, `x86`, `armv7`, `aarch64`, `ppc64le`, `s390x` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | Linux `armv7` is available through Java 17. |
|
||||||
| `zulu` | `x64`, `x86`, `armv7`, `aarch64` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | |
|
| `zulu` | `x64`, `x86`, `armv7`, `aarch64` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | |
|
||||||
| `liberica` | `x64`, `x86`, `armv7`, `aarch64`, `ppc64le` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | Solaris: `x64`. |
|
| `liberica` | `x64`, `x86`, `armv7`, `aarch64`, `ppc64le` | `x64`, `aarch64` | `x64`, `x86`, `aarch64` | Solaris: `x64`. |
|
||||||
| `liberica-nik` | `x64`, `aarch64` | `x64`, `aarch64` | `x64`, `aarch64` | |
|
| `liberica-nik` | `x64`, `aarch64` | `x64`, `aarch64` | `x64`, `aarch64` | |
|
||||||
@@ -658,7 +643,6 @@ absent from a vendor catalog.
|
|||||||
| `corretto` | `x64`, `x86`, `armv7`, `aarch64` | `x64`, `aarch64` | `x64`, `x86` | `x86` is limited to Java 11 or earlier; Linux `armv7` is available for Java 11. |
|
| `corretto` | `x64`, `x86`, `armv7`, `aarch64` | `x64`, `aarch64` | `x64`, `x86` | `x86` is limited to Java 11 or earlier; Linux `armv7` is available for Java 11. |
|
||||||
| `oracle` | `x64`, `aarch64` | `x64`, `aarch64` | `x64` | |
|
| `oracle` | `x64`, `aarch64` | `x64`, `aarch64` | `x64` | |
|
||||||
| `oracle-openjdk` | `x64`, `aarch64` | `x64`, `aarch64` | `x64` | |
|
| `oracle-openjdk` | `x64`, `aarch64` | `x64`, `aarch64` | `x64` | |
|
||||||
| `redhat` | `x64`, `aarch64`, `ppc64le` | — | `x64`, `x86` | Linux requires glibc; Alpine is unsupported. Linux `aarch64` and `ppc64le` are limited to Java 11 or earlier. Windows `x64` is limited to Java 21 or earlier and `x86` to Java 10 or earlier. |
|
|
||||||
| `dragonwell` | `x64`, `aarch64` | — | `x64` | |
|
| `dragonwell` | `x64`, `aarch64` | — | `x64` | |
|
||||||
| `sapmachine` | `x64`, `aarch64`, `ppc64le` | `x64`, `aarch64` | `x64`, `aarch64` | |
|
| `sapmachine` | `x64`, `aarch64`, `ppc64le` | `x64`, `aarch64` | `x64`, `aarch64` | |
|
||||||
| `graalvm`, `graalvm-community` | `x64`, `aarch64` | `x64`, `aarch64` | `x64` | |
|
| `graalvm`, `graalvm-community` | `x64`, `aarch64` | `x64`, `aarch64` | `x64` | |
|
||||||
@@ -879,125 +863,6 @@ The two `settings.xml` files created from the above example look like the follow
|
|||||||
|
|
||||||
If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false`
|
If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false`
|
||||||
|
|
||||||
### Publishing to multiple Maven servers
|
|
||||||
|
|
||||||
Use `mvn-server-credentials` to add more than one credential entry to the generated `settings.xml`. Each line has the format `server-id:USERNAME_ENV:PASSWORD_ENV`. The username and password fields are environment variable names, not credential values.
|
|
||||||
|
|
||||||
When this input is set, it replaces the single server configured by `server-id`, `server-username-env-var`, and `server-password-env-var`.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v7
|
|
||||||
- name: Set up release and snapshot repositories
|
|
||||||
uses: actions/setup-java@v6
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '21'
|
|
||||||
mvn-server-credentials: |
|
|
||||||
releases:RELEASES_USERNAME:RELEASES_PASSWORD
|
|
||||||
snapshots:SNAPSHOTS_USERNAME:SNAPSHOTS_PASSWORD
|
|
||||||
- name: Publish with Maven
|
|
||||||
run: mvn deploy
|
|
||||||
env:
|
|
||||||
RELEASES_USERNAME: ${{ secrets.RELEASES_USERNAME }}
|
|
||||||
RELEASES_PASSWORD: ${{ secrets.RELEASES_PASSWORD }}
|
|
||||||
SNAPSHOTS_USERNAME: ${{ secrets.SNAPSHOTS_USERNAME }}
|
|
||||||
SNAPSHOTS_PASSWORD: ${{ secrets.SNAPSHOTS_PASSWORD }}
|
|
||||||
```
|
|
||||||
|
|
||||||
This configuration produces the following server entries:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<servers>
|
|
||||||
<server>
|
|
||||||
<id>releases</id>
|
|
||||||
<username>${env.RELEASES_USERNAME}</username>
|
|
||||||
<password>${env.RELEASES_PASSWORD}</password>
|
|
||||||
</server>
|
|
||||||
<server>
|
|
||||||
<id>snapshots</id>
|
|
||||||
<username>${env.SNAPSHOTS_USERNAME}</username>
|
|
||||||
<password>${env.SNAPSHOTS_PASSWORD}</password>
|
|
||||||
</server>
|
|
||||||
</servers>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Resolving Maven dependencies from custom repositories
|
|
||||||
|
|
||||||
Use `mvn-repositories` when Maven must download dependencies from repositories
|
|
||||||
outside Maven Central. Each line has the format
|
|
||||||
`repository-id:repository-url:snapshots-enabled`. The parser uses the first and
|
|
||||||
last colons as separators, so repository URLs can contain a scheme or port.
|
|
||||||
|
|
||||||
The repository ID can match a `mvn-server-credentials` server ID to authenticate
|
|
||||||
requests to a private repository:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v7
|
|
||||||
- name: Set up Java and private Maven repositories
|
|
||||||
uses: actions/setup-java@v6
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '21'
|
|
||||||
mvn-server-credentials: |
|
|
||||||
private:PRIVATE_REPOSITORY_USERNAME:PRIVATE_REPOSITORY_TOKEN
|
|
||||||
mvn-repositories: |
|
|
||||||
private:https://maven.example.com:8443/releases:false
|
|
||||||
snapshots:https://maven.example.com:8443/snapshots:true
|
|
||||||
mvn-repositories-include-central: true
|
|
||||||
mvn-repositories-prioritize-central: true
|
|
||||||
- run: mvn --batch-mode verify
|
|
||||||
env:
|
|
||||||
PRIVATE_REPOSITORY_USERNAME: ${{ secrets.PRIVATE_REPOSITORY_USERNAME }}
|
|
||||||
PRIVATE_REPOSITORY_TOKEN: ${{ secrets.PRIVATE_REPOSITORY_TOKEN }}
|
|
||||||
```
|
|
||||||
|
|
||||||
This configuration adds the following active profile to `settings.xml`:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>setup-java-repositories</id>
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>central</id>
|
|
||||||
<url>https://repo.maven.apache.org/maven2</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>private</id>
|
|
||||||
<url>https://maven.example.com:8443/releases</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>snapshots</id>
|
|
||||||
<url>https://maven.example.com:8443/snapshots</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
<activeProfiles>
|
|
||||||
<activeProfile>setup-java-repositories</activeProfile>
|
|
||||||
</activeProfiles>
|
|
||||||
```
|
|
||||||
|
|
||||||
Maven Central is included first by default. Set
|
|
||||||
`mvn-repositories-prioritize-central: false` to place custom repositories
|
|
||||||
first, or set `mvn-repositories-include-central: false` to disable Central. The
|
|
||||||
generated profile overrides the Central repository inherited from Maven's Super
|
|
||||||
POM with releases and snapshots disabled. When automatic Central inclusion is
|
|
||||||
off, the ID `central` may instead be declared explicitly in `mvn-repositories`
|
|
||||||
to replace it with a user-specified repository; otherwise that ID is reserved
|
|
||||||
to prevent duplicate entries.
|
|
||||||
|
|
||||||
### GPG
|
### GPG
|
||||||
|
|
||||||
The example above uses the [Maven GPG Plugin](https://maven.apache.org/plugins/maven-gpg-plugin/)'s Bouncy Castle signer (`-Dgpg.signer=bc`, available since `maven-gpg-plugin` 3.2.0). It is a pure-Java signer that reads the key directly from the `MAVEN_GPG_KEY` environment variable, so it does **not** require the `gpg` executable, importing the key into a GPG keychain, or the `--pinentry-mode loopback` workaround in your `pom.xml`. The key must be an ASCII-armored secret key (transferable secret key format).
|
The example above uses the [Maven GPG Plugin](https://maven.apache.org/plugins/maven-gpg-plugin/)'s Bouncy Castle signer (`-Dgpg.signer=bc`, available since `maven-gpg-plugin` 3.2.0). It is a pure-Java signer that reads the key directly from the `MAVEN_GPG_KEY` environment variable, so it does **not** require the `gpg` executable, importing the key into a GPG keychain, or the `--pinentry-mode loopback` workaround in your `pom.xml`. The key must be an ASCII-armored secret key (transferable secret key format).
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Contributing
|
# Contributors
|
||||||
|
|
||||||
Thank you for contributing!
|
Thank you for contributing!
|
||||||
|
|
||||||
Generated
+684
-1254
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -49,27 +49,27 @@
|
|||||||
"@actions/http-client": "^4.0.1",
|
"@actions/http-client": "^4.0.1",
|
||||||
"@actions/io": "^3.0.2",
|
"@actions/io": "^3.0.2",
|
||||||
"@actions/tool-cache": "^4.0.0",
|
"@actions/tool-cache": "^4.0.0",
|
||||||
"fast-xml-parser": "^5.11.1",
|
"fast-xml-parser": "^5.10.1",
|
||||||
"semver": "^7.8.5"
|
"semver": "^7.8.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^10.0.1",
|
"@eslint/js": "^10.0.1",
|
||||||
"@jest/globals": "^30.5.2",
|
"@jest/globals": "^30.4.1",
|
||||||
"@types/node": "^26.6.2",
|
"@types/node": "^26.1.1",
|
||||||
"@types/semver": "^7.8.0",
|
"@types/semver": "^7.7.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.70.1",
|
"@typescript-eslint/eslint-plugin": "^8.64.0",
|
||||||
"@typescript-eslint/parser": "^8.65.0",
|
"@typescript-eslint/parser": "^8.65.0",
|
||||||
"@vercel/ncc": "^0.45.0",
|
"@vercel/ncc": "^0.44.0",
|
||||||
"eslint": "^10.11.0",
|
"eslint": "^10.7.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-jest": "^29.16.6",
|
"eslint-plugin-jest": "^29.15.4",
|
||||||
"eslint-plugin-n": "^18.3.0",
|
"eslint-plugin-n": "^18.2.2",
|
||||||
"globals": "^17.12.0",
|
"globals": "^17.7.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"jest": "^30.5.2",
|
"jest": "^30.4.2",
|
||||||
"lint-staged": "^17.5.1",
|
"lint-staged": "^17.2.0",
|
||||||
"prettier": "^3.9.9",
|
"prettier": "^3.9.5",
|
||||||
"ts-jest": "^29.4.13",
|
"ts-jest": "^29.4.11",
|
||||||
"typescript": "^6.0.3"
|
"typescript": "^6.0.3"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
+37
-254
@@ -9,28 +9,18 @@ import * as gpg from './gpg.js';
|
|||||||
import {getBooleanInput} from './util.js';
|
import {getBooleanInput} from './util.js';
|
||||||
import {escapeXmlText} from './xml.js';
|
import {escapeXmlText} from './xml.js';
|
||||||
|
|
||||||
export interface MavenServerCredentials {
|
|
||||||
id: string;
|
|
||||||
usernameEnvVar: string;
|
|
||||||
passwordEnvVar: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MavenRepository {
|
|
||||||
id: string;
|
|
||||||
url: string;
|
|
||||||
snapshotsEnabled: boolean;
|
|
||||||
releasesEnabled?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MavenRepositorySettings {
|
|
||||||
repositories: MavenRepository[];
|
|
||||||
includeCentral: boolean;
|
|
||||||
prioritizeCentral: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function configureAuthentication() {
|
export async function configureAuthentication() {
|
||||||
const servers = getMavenServerSettings();
|
const id = core.getInput(constants.INPUT_SERVER_ID);
|
||||||
const repositorySettings = getMavenRepositorySettings();
|
const usernameEnvVar = getInputWithDeprecatedAlias(
|
||||||
|
constants.INPUT_SERVER_USERNAME_ENV_VAR,
|
||||||
|
constants.INPUT_SERVER_USERNAME_DEPRECATED,
|
||||||
|
constants.INPUT_DEFAULT_SERVER_USERNAME
|
||||||
|
);
|
||||||
|
const passwordEnvVar = getInputWithDeprecatedAlias(
|
||||||
|
constants.INPUT_SERVER_PASSWORD_ENV_VAR,
|
||||||
|
constants.INPUT_SERVER_PASSWORD_DEPRECATED,
|
||||||
|
constants.INPUT_DEFAULT_SERVER_PASSWORD
|
||||||
|
);
|
||||||
const settingsDirectory =
|
const settingsDirectory =
|
||||||
core.getInput(constants.INPUT_SETTINGS_PATH) ||
|
core.getInput(constants.INPUT_SETTINGS_PATH) ||
|
||||||
path.join(os.homedir(), constants.M2_DIR);
|
path.join(os.homedir(), constants.M2_DIR);
|
||||||
@@ -52,11 +42,12 @@ export async function configureAuthentication() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await createAuthenticationSettings(
|
await createAuthenticationSettings(
|
||||||
servers,
|
id,
|
||||||
|
usernameEnvVar,
|
||||||
|
passwordEnvVar,
|
||||||
settingsDirectory,
|
settingsDirectory,
|
||||||
overwriteSettings,
|
overwriteSettings,
|
||||||
gpgPassphraseEnvVar,
|
gpgPassphraseEnvVar
|
||||||
repositorySettings
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (gpgPrivateKey) {
|
if (gpgPrivateKey) {
|
||||||
@@ -89,179 +80,31 @@ export function getInputWithDeprecatedAlias(
|
|||||||
return value || deprecatedValue || defaultValue || '';
|
return value || deprecatedValue || defaultValue || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// only exported for testing purposes
|
|
||||||
export function getMavenServerSettings(): MavenServerCredentials[] {
|
|
||||||
const entries = core.getMultilineInput(
|
|
||||||
constants.INPUT_MVN_SERVER_CREDENTIALS
|
|
||||||
);
|
|
||||||
|
|
||||||
if (entries.some(entry => entry.trim())) {
|
|
||||||
return parseMavenServerCredentials(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
id: core.getInput(constants.INPUT_SERVER_ID),
|
|
||||||
usernameEnvVar: getInputWithDeprecatedAlias(
|
|
||||||
constants.INPUT_SERVER_USERNAME_ENV_VAR,
|
|
||||||
constants.INPUT_SERVER_USERNAME_DEPRECATED,
|
|
||||||
constants.INPUT_DEFAULT_SERVER_USERNAME
|
|
||||||
),
|
|
||||||
passwordEnvVar: getInputWithDeprecatedAlias(
|
|
||||||
constants.INPUT_SERVER_PASSWORD_ENV_VAR,
|
|
||||||
constants.INPUT_SERVER_PASSWORD_DEPRECATED,
|
|
||||||
constants.INPUT_DEFAULT_SERVER_PASSWORD
|
|
||||||
)
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// only exported for testing purposes
|
|
||||||
export function parseMavenServerCredentials(
|
|
||||||
entries: string[]
|
|
||||||
): MavenServerCredentials[] {
|
|
||||||
const servers: MavenServerCredentials[] = [];
|
|
||||||
const serverIds = new Set<string>();
|
|
||||||
|
|
||||||
entries.forEach((entry, index) => {
|
|
||||||
if (!entry.trim()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fields = entry.split(':');
|
|
||||||
if (fields.length !== 3) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid mvn-server-credentials entry at line ${index + 1}. Expected format: server-id:USERNAME_ENV:PASSWORD_ENV`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [id, usernameEnvVar, passwordEnvVar] = fields.map(field =>
|
|
||||||
field.trim()
|
|
||||||
);
|
|
||||||
if (!id || !usernameEnvVar || !passwordEnvVar) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid mvn-server-credentials entry at line ${index + 1}. server-id, username environment variable, and password environment variable are required`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (serverIds.has(id)) {
|
|
||||||
throw new Error(
|
|
||||||
`Duplicate server-id '${id}' in mvn-server-credentials input`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
serverIds.add(id);
|
|
||||||
servers.push({id, usernameEnvVar, passwordEnvVar});
|
|
||||||
});
|
|
||||||
|
|
||||||
return servers;
|
|
||||||
}
|
|
||||||
|
|
||||||
// only exported for testing purposes
|
|
||||||
export function getMavenRepositorySettings():
|
|
||||||
MavenRepositorySettings | undefined {
|
|
||||||
const entries = core.getMultilineInput(constants.INPUT_MVN_REPOSITORIES);
|
|
||||||
if (!entries.some(entry => entry.trim())) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const includeCentral = getBooleanInput(
|
|
||||||
constants.INPUT_MVN_REPOSITORIES_INCLUDE_CENTRAL,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
repositories: parseMavenRepositories(entries, includeCentral),
|
|
||||||
includeCentral,
|
|
||||||
prioritizeCentral: getBooleanInput(
|
|
||||||
constants.INPUT_MVN_REPOSITORIES_PRIORITIZE_CENTRAL,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// only exported for testing purposes
|
|
||||||
export function parseMavenRepositories(
|
|
||||||
entries: string[],
|
|
||||||
includeCentral: boolean
|
|
||||||
): MavenRepository[] {
|
|
||||||
const repositories: MavenRepository[] = [];
|
|
||||||
const repositoryIds = new Set<string>();
|
|
||||||
|
|
||||||
entries.forEach((entry, index) => {
|
|
||||||
if (!entry.trim()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const firstSeparator = entry.indexOf(':');
|
|
||||||
const lastSeparator = entry.lastIndexOf(':');
|
|
||||||
if (firstSeparator <= 0 || lastSeparator <= firstSeparator) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid mvn-repositories entry at line ${index + 1}. Expected format: repository-id:repository-url:snapshots-enabled`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const id = entry.slice(0, firstSeparator).trim();
|
|
||||||
const url = entry.slice(firstSeparator + 1, lastSeparator).trim();
|
|
||||||
const snapshotsValue = entry
|
|
||||||
.slice(lastSeparator + 1)
|
|
||||||
.trim()
|
|
||||||
.toLowerCase();
|
|
||||||
if (!id || !url || !snapshotsValue) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid mvn-repositories entry at line ${index + 1}. repository-id, repository URL, and snapshots-enabled are required`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (snapshotsValue !== 'true' && snapshotsValue !== 'false') {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid snapshots-enabled value '${snapshotsValue}' in mvn-repositories entry at line ${index + 1}. Expected true or false`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (repositoryIds.has(id)) {
|
|
||||||
throw new Error(
|
|
||||||
`Duplicate repository-id '${id}' in mvn-repositories input`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (includeCentral && id === constants.MAVEN_CENTRAL_REPOSITORY_ID) {
|
|
||||||
throw new Error(
|
|
||||||
`Repository-id '${constants.MAVEN_CENTRAL_REPOSITORY_ID}' is reserved when ${constants.INPUT_MVN_REPOSITORIES_INCLUDE_CENTRAL} is enabled`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
repositoryIds.add(id);
|
|
||||||
repositories.push({
|
|
||||||
id,
|
|
||||||
url,
|
|
||||||
snapshotsEnabled: snapshotsValue === 'true'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return repositories;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createAuthenticationSettings(
|
export async function createAuthenticationSettings(
|
||||||
servers: MavenServerCredentials[],
|
id: string,
|
||||||
|
usernameEnvVar: string,
|
||||||
|
passwordEnvVar: string,
|
||||||
settingsDirectory: string,
|
settingsDirectory: string,
|
||||||
overwriteSettings: boolean,
|
overwriteSettings: boolean,
|
||||||
gpgPassphraseEnvVar: string | undefined = undefined,
|
gpgPassphraseEnvVar: string | undefined = undefined
|
||||||
repositorySettings: MavenRepositorySettings | undefined = undefined
|
|
||||||
) {
|
) {
|
||||||
core.info(
|
core.info(`Creating ${constants.MVN_SETTINGS_FILE} with server-id: ${id}`);
|
||||||
`Creating ${constants.MVN_SETTINGS_FILE} with server-id: ${servers.map(server => server.id).join(', ')}`
|
|
||||||
);
|
|
||||||
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
||||||
// otherwise use the home/.m2/ path
|
// otherwise use the home/.m2/ path
|
||||||
await io.mkdirP(settingsDirectory);
|
await io.mkdirP(settingsDirectory);
|
||||||
await write(
|
await write(
|
||||||
settingsDirectory,
|
settingsDirectory,
|
||||||
generate(servers, gpgPassphraseEnvVar, repositorySettings),
|
generate(id, usernameEnvVar, passwordEnvVar, gpgPassphraseEnvVar),
|
||||||
overwriteSettings
|
overwriteSettings
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only exported for testing purposes
|
// only exported for testing purposes
|
||||||
export function generate(
|
export function generate(
|
||||||
servers: MavenServerCredentials[],
|
id: string,
|
||||||
gpgPassphraseEnvVar?: string | undefined,
|
usernameEnvVar: string,
|
||||||
repositorySettings?: MavenRepositorySettings | undefined
|
passwordEnvVar: string,
|
||||||
|
gpgPassphraseEnvVar?: string | undefined
|
||||||
) {
|
) {
|
||||||
// The maven-gpg-plugin reads the passphrase from the environment variable
|
// The maven-gpg-plugin reads the passphrase from the environment variable
|
||||||
// named by the `gpg.passphraseEnvName` property (default MAVEN_GPG_PASSPHRASE).
|
// named by the `gpg.passphraseEnvName` property (default MAVEN_GPG_PASSPHRASE).
|
||||||
@@ -278,90 +121,30 @@ export function generate(
|
|||||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
|
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
|
||||||
' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">',
|
' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">',
|
||||||
' <interactiveMode>false</interactiveMode>',
|
' <interactiveMode>false</interactiveMode>',
|
||||||
' <servers>'
|
' <servers>',
|
||||||
];
|
|
||||||
|
|
||||||
for (const server of servers) {
|
|
||||||
lines.push(
|
|
||||||
' <server>',
|
' <server>',
|
||||||
` <id>${escapeXmlText(server.id)}</id>`,
|
` <id>${escapeXmlText(id)}</id>`,
|
||||||
` <username>${escapeXmlText(`\${env.${server.usernameEnvVar}}`)}</username>`,
|
` <username>${escapeXmlText(`\${env.${usernameEnvVar}}`)}</username>`,
|
||||||
` <password>${escapeXmlText(`\${env.${server.passwordEnvVar}}`)}</password>`,
|
` <password>${escapeXmlText(`\${env.${passwordEnvVar}}`)}</password>`,
|
||||||
' </server>'
|
' </server>',
|
||||||
);
|
' </servers>'
|
||||||
}
|
|
||||||
lines.push(' </servers>');
|
|
||||||
|
|
||||||
if (repositorySettings || includeGpgPassphraseProfile) {
|
|
||||||
lines.push(' <profiles>');
|
|
||||||
if (repositorySettings) {
|
|
||||||
const centralRepository: MavenRepository = {
|
|
||||||
id: constants.MAVEN_CENTRAL_REPOSITORY_ID,
|
|
||||||
url: constants.MAVEN_CENTRAL_REPOSITORY_URL,
|
|
||||||
snapshotsEnabled: false
|
|
||||||
};
|
|
||||||
const customCentralConfigured = repositorySettings.repositories.some(
|
|
||||||
repository => repository.id === constants.MAVEN_CENTRAL_REPOSITORY_ID
|
|
||||||
);
|
|
||||||
const repositories = repositorySettings.includeCentral
|
|
||||||
? repositorySettings.prioritizeCentral
|
|
||||||
? [centralRepository, ...repositorySettings.repositories]
|
|
||||||
: [...repositorySettings.repositories, centralRepository]
|
|
||||||
: customCentralConfigured
|
|
||||||
? repositorySettings.repositories
|
|
||||||
: [
|
|
||||||
...repositorySettings.repositories,
|
|
||||||
{...centralRepository, releasesEnabled: false}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
lines.push(
|
|
||||||
' <profile>',
|
|
||||||
` <id>${constants.MAVEN_REPOSITORIES_PROFILE_ID}</id>`,
|
|
||||||
' <repositories>'
|
|
||||||
);
|
|
||||||
for (const repository of repositories) {
|
|
||||||
lines.push(
|
|
||||||
' <repository>',
|
|
||||||
` <id>${escapeXmlText(repository.id)}</id>`,
|
|
||||||
` <url>${escapeXmlText(repository.url)}</url>`,
|
|
||||||
...(repository.releasesEnabled === undefined
|
|
||||||
? []
|
|
||||||
: [
|
|
||||||
' <releases>',
|
|
||||||
` <enabled>${repository.releasesEnabled}</enabled>`,
|
|
||||||
' </releases>'
|
|
||||||
]),
|
|
||||||
' <snapshots>',
|
|
||||||
` <enabled>${repository.snapshotsEnabled}</enabled>`,
|
|
||||||
' </snapshots>',
|
|
||||||
' </repository>'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
lines.push(' </repositories>', ' </profile>');
|
|
||||||
}
|
|
||||||
if (includeGpgPassphraseProfile) {
|
if (includeGpgPassphraseProfile) {
|
||||||
lines.push(
|
lines.push(
|
||||||
|
' <profiles>',
|
||||||
' <profile>',
|
' <profile>',
|
||||||
` <id>${constants.GPG_PASSPHRASE_PROFILE_ID}</id>`,
|
` <id>${constants.GPG_PASSPHRASE_PROFILE_ID}</id>`,
|
||||||
' <properties>',
|
' <properties>',
|
||||||
` <gpg.passphraseEnvName>${escapeXmlText(gpgPassphraseEnvVar)}</gpg.passphraseEnvName>`,
|
` <gpg.passphraseEnvName>${escapeXmlText(gpgPassphraseEnvVar)}</gpg.passphraseEnvName>`,
|
||||||
' </properties>',
|
' </properties>',
|
||||||
' </profile>'
|
' </profile>',
|
||||||
|
' </profiles>',
|
||||||
|
' <activeProfiles>',
|
||||||
|
` <activeProfile>${constants.GPG_PASSPHRASE_PROFILE_ID}</activeProfile>`,
|
||||||
|
' </activeProfiles>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
lines.push(' </profiles>', ' <activeProfiles>');
|
|
||||||
if (repositorySettings) {
|
|
||||||
lines.push(
|
|
||||||
` <activeProfile>${constants.MAVEN_REPOSITORIES_PROFILE_ID}</activeProfile>`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (includeGpgPassphraseProfile) {
|
|
||||||
lines.push(
|
|
||||||
` <activeProfile>${constants.GPG_PASSPHRASE_PROFILE_ID}</activeProfile>`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
lines.push(' </activeProfiles>');
|
|
||||||
}
|
|
||||||
|
|
||||||
lines.push('</settings>');
|
lines.push('</settings>');
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@ import {
|
|||||||
isJdkCacheEnabled,
|
isJdkCacheEnabled,
|
||||||
isJobStatusSuccess
|
isJobStatusSuccess
|
||||||
} from './util.js';
|
} from './util.js';
|
||||||
import {isMainModule} from './is-main-module.js';
|
import {fileURLToPath} from 'url';
|
||||||
|
|
||||||
async function removeGpgHome() {
|
async function removeGpgHome() {
|
||||||
const gpgHome = core.getState(constants.STATE_GPG_HOME);
|
const gpgHome = core.getState(constants.STATE_GPG_HOME);
|
||||||
@@ -77,7 +77,7 @@ export async function run() {
|
|||||||
await ignoreError(saveCaches());
|
await ignoreError(saveCaches());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMainModule(import.meta.url)) {
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
run();
|
run();
|
||||||
} else {
|
} else {
|
||||||
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
||||||
|
|||||||
@@ -12,15 +12,6 @@ export const INPUT_SET_DEFAULT = 'set-default';
|
|||||||
export const INPUT_PROBLEM_MATCHER = 'problem-matcher';
|
export const INPUT_PROBLEM_MATCHER = 'problem-matcher';
|
||||||
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
export const INPUT_VERIFY_SIGNATURE = 'verify-signature';
|
||||||
export const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
export const INPUT_VERIFY_SIGNATURE_PUBLIC_KEY = 'verify-signature-public-key';
|
||||||
export const SIGNATURE_VERIFICATION_DOCUMENTATION_URL =
|
|
||||||
'https://github.com/actions/setup-java#download-integrity-and-signatures';
|
|
||||||
export const SIGNATURE_VERIFICATION_FAILURE_HELP = `If this is a legitimate vendor signing-key rotation, see ${SIGNATURE_VERIFICATION_DOCUMENTATION_URL} for instructions to configure the updated public key or temporarily disable signature verification.`;
|
|
||||||
export const INPUT_MVN_SERVER_CREDENTIALS = 'mvn-server-credentials';
|
|
||||||
export const INPUT_MVN_REPOSITORIES = 'mvn-repositories';
|
|
||||||
export const INPUT_MVN_REPOSITORIES_INCLUDE_CENTRAL =
|
|
||||||
'mvn-repositories-include-central';
|
|
||||||
export const INPUT_MVN_REPOSITORIES_PRIORITIZE_CENTRAL =
|
|
||||||
'mvn-repositories-prioritize-central';
|
|
||||||
export const INPUT_SERVER_ID = 'server-id';
|
export const INPUT_SERVER_ID = 'server-id';
|
||||||
export const INPUT_SERVER_USERNAME_ENV_VAR = 'server-username-env-var';
|
export const INPUT_SERVER_USERNAME_ENV_VAR = 'server-username-env-var';
|
||||||
export const INPUT_SERVER_PASSWORD_ENV_VAR = 'server-password-env-var';
|
export const INPUT_SERVER_PASSWORD_ENV_VAR = 'server-password-env-var';
|
||||||
@@ -44,10 +35,6 @@ export const MAVEN_GPG_PASSPHRASE_DEFAULT_ENV = 'MAVEN_GPG_PASSPHRASE';
|
|||||||
|
|
||||||
// Id of the settings.xml profile used to set `gpg.passphraseEnvName`.
|
// Id of the settings.xml profile used to set `gpg.passphraseEnvName`.
|
||||||
export const GPG_PASSPHRASE_PROFILE_ID = 'setup-java-gpg';
|
export const GPG_PASSPHRASE_PROFILE_ID = 'setup-java-gpg';
|
||||||
export const MAVEN_REPOSITORIES_PROFILE_ID = 'setup-java-repositories';
|
|
||||||
export const MAVEN_CENTRAL_REPOSITORY_ID = 'central';
|
|
||||||
export const MAVEN_CENTRAL_REPOSITORY_URL =
|
|
||||||
'https://repo.maven.apache.org/maven2';
|
|
||||||
|
|
||||||
export const INPUT_CACHE = 'cache';
|
export const INPUT_CACHE = 'cache';
|
||||||
export const INPUT_CACHE_JDK = 'cache-jdk';
|
export const INPUT_CACHE_JDK = 'cache-jdk';
|
||||||
|
|||||||
@@ -5,17 +5,16 @@ import semver from 'semver';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as httpm from '@actions/http-client';
|
import * as httpm from '@actions/http-client';
|
||||||
import {
|
import {
|
||||||
|
convertVersionToSemver,
|
||||||
getToolcachePath,
|
getToolcachePath,
|
||||||
isVersionSatisfies,
|
isVersionSatisfies
|
||||||
normalizeJavaVersionToSemver
|
|
||||||
} from '../util.js';
|
} from '../util.js';
|
||||||
import type {
|
import {
|
||||||
ChecksumAlgorithm,
|
ChecksumAlgorithm,
|
||||||
ChecksumMetadata,
|
ChecksumMetadata,
|
||||||
JavaDownloadRelease,
|
JavaDownloadRelease,
|
||||||
JavaInstallerOptions,
|
JavaInstallerOptions,
|
||||||
JavaInstallerResults,
|
JavaInstallerResults
|
||||||
SignatureVerificationKey
|
|
||||||
} from './base-models.js';
|
} from './base-models.js';
|
||||||
import {MACOS_JAVA_CONTENT_POSTFIX} from '../constants.js';
|
import {MACOS_JAVA_CONTENT_POSTFIX} from '../constants.js';
|
||||||
import {RetryingHttpClient} from '../retrying-http-client.js';
|
import {RetryingHttpClient} from '../retrying-http-client.js';
|
||||||
@@ -45,8 +44,7 @@ export abstract class JavaBase {
|
|||||||
private floatingVersionVerified = false;
|
private floatingVersionVerified = false;
|
||||||
protected setDefault: boolean;
|
protected setDefault: boolean;
|
||||||
protected verifySignature: boolean;
|
protected verifySignature: boolean;
|
||||||
protected verifySignatureExplicitlyRequested: boolean;
|
protected verifySignaturePublicKey: string | undefined;
|
||||||
protected verifySignaturePublicKey: SignatureVerificationKey | undefined;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected distribution: string,
|
protected distribution: string,
|
||||||
@@ -70,10 +68,7 @@ export abstract class JavaBase {
|
|||||||
installerOptions.setDefault !== undefined
|
installerOptions.setDefault !== undefined
|
||||||
? installerOptions.setDefault
|
? installerOptions.setDefault
|
||||||
: true;
|
: true;
|
||||||
this.verifySignature =
|
this.verifySignature = installerOptions.verifySignature ?? false;
|
||||||
installerOptions.verifySignature ?? this.supportsSignatureVerification();
|
|
||||||
this.verifySignatureExplicitlyRequested =
|
|
||||||
installerOptions.verifySignature === true;
|
|
||||||
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
this.verifySignaturePublicKey = installerOptions.verifySignaturePublicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +368,6 @@ export abstract class JavaBase {
|
|||||||
source: this.getJdkReleaseIdentity(javaRelease),
|
source: this.getJdkReleaseIdentity(javaRelease),
|
||||||
verification: getJdkVerificationIdentity(
|
verification: getJdkVerificationIdentity(
|
||||||
this.verifySignature,
|
this.verifySignature,
|
||||||
this.verifySignatureExplicitlyRequested,
|
|
||||||
this.verifySignaturePublicKey
|
this.verifySignaturePublicKey
|
||||||
),
|
),
|
||||||
path: this.getJdkCachePath(javaRelease.version)
|
path: this.getJdkCachePath(javaRelease.version)
|
||||||
@@ -675,9 +669,12 @@ export abstract class JavaBase {
|
|||||||
|
|
||||||
// Java uses a versioning scheme (JEP 322) that can contain more numeric
|
// Java uses a versioning scheme (JEP 322) that can contain more numeric
|
||||||
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
|
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
|
||||||
// exact versions to SemVer build notation ('18.0.1+1', or '26.0.2+1.1'
|
// exact versions to SemVer build notation ('18.0.1+1') so they are
|
||||||
// for '26.0.2.1+1') so they are accepted. Ranges are left untouched.
|
// accepted. Ranges and versions that already carry build metadata are
|
||||||
version = normalizeJavaVersionToSemver(version);
|
// left untouched.
|
||||||
|
if (/^\d+(\.\d+){3,}$/.test(version)) {
|
||||||
|
version = convertVersionToSemver(version);
|
||||||
|
}
|
||||||
|
|
||||||
if (!semver.validRange(version)) {
|
if (!semver.validRange(version)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
export type SignatureVerificationKey = string | readonly string[];
|
|
||||||
|
|
||||||
export interface JavaInstallerOptions {
|
export interface JavaInstallerOptions {
|
||||||
version: string;
|
version: string;
|
||||||
architecture: string;
|
architecture: string;
|
||||||
@@ -9,7 +7,7 @@ export interface JavaInstallerOptions {
|
|||||||
cacheJdk?: boolean;
|
cacheJdk?: boolean;
|
||||||
setDefault?: boolean;
|
setDefault?: boolean;
|
||||||
verifySignature?: boolean;
|
verifySignature?: boolean;
|
||||||
verifySignaturePublicKey?: SignatureVerificationKey;
|
verifySignaturePublicKey?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface JavaInstallerResults {
|
export interface JavaInstallerResults {
|
||||||
|
|||||||
@@ -98,10 +98,6 @@ export async function getJavaDistribution(
|
|||||||
const {OpenJdkDistribution} = await import('./openjdk/installer.js');
|
const {OpenJdkDistribution} = await import('./openjdk/installer.js');
|
||||||
return new OpenJdkDistribution(normalizedInstallerOptions);
|
return new OpenJdkDistribution(normalizedInstallerOptions);
|
||||||
}
|
}
|
||||||
case JavaDistribution.RedHat: {
|
|
||||||
const {RedHatDistribution} = await import('./redhat/installer.js');
|
|
||||||
return new RedHatDistribution(normalizedInstallerOptions);
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ export class LibericaDistributions extends JavaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private convertVersionToSemver(version: LibericaVersion): string {
|
private convertVersionToSemver(version: LibericaVersion): string {
|
||||||
const {featureVersion, interimVersion, updateVersion} = version;
|
const {buildVersion, featureVersion, interimVersion, updateVersion} =
|
||||||
const buildVersion = version.version.split('+')[1] || version.buildVersion;
|
version;
|
||||||
const mainVersion = [featureVersion, interimVersion, updateVersion].join(
|
const mainVersion = [featureVersion, interimVersion, updateVersion].join(
|
||||||
'.'
|
'.'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export class LocalDistribution extends JavaBase {
|
|||||||
architecture: this.architecture,
|
architecture: this.architecture,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
source,
|
source,
|
||||||
verification: getJdkVerificationIdentity(false, false),
|
verification: getJdkVerificationIdentity(false),
|
||||||
path: this.getJdkCachePath(this.version)
|
path: this.getJdkCachePath(this.version)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import {
|
|||||||
} from '../../util.js';
|
} from '../../util.js';
|
||||||
import * as gpg from '../../gpg.js';
|
import * as gpg from '../../gpg.js';
|
||||||
import {MICROSOFT_PUBLIC_KEY} from './microsoft-key.js';
|
import {MICROSOFT_PUBLIC_KEY} from './microsoft-key.js';
|
||||||
import {SIGNATURE_VERIFICATION_FAILURE_HELP} from '../../constants.js';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
@@ -35,7 +34,6 @@ export class MicrosoftDistributions extends JavaBase {
|
|||||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
||||||
|
|
||||||
if (this.verifySignature) {
|
if (this.verifySignature) {
|
||||||
try {
|
|
||||||
if (!javaRelease.signatureUrl) {
|
if (!javaRelease.signatureUrl) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`
|
`Input 'verify-signature' is enabled, but no signature URL was found for Microsoft Build of OpenJDK version ${javaRelease.version}.`
|
||||||
@@ -50,18 +48,10 @@ export class MicrosoftDistributions extends JavaBase {
|
|||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${(error as Error).message} ${SIGNATURE_VERIFICATION_FAILURE_HELP}`,
|
`Failed to verify signature for Microsoft Build of OpenJDK version ${javaRelease.version}. Signature URL: ${javaRelease.signatureUrl}. Error: ${(error as Error).message}`,
|
||||||
{cause: error}
|
{cause: error}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
if (this.verifySignatureExplicitlyRequested) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
core.warning(
|
|
||||||
error instanceof Error ? error.message : `Unknown error: ${error}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Extracting Java archive...`);
|
core.info(`Extracting Java archive...`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import {normalizeJavaVersionToSemver} from '../util.js';
|
import {convertVersionToSemver} from '../util.js';
|
||||||
|
|
||||||
export enum JavaDistribution {
|
export enum JavaDistribution {
|
||||||
Temurin = 'temurin',
|
Temurin = 'temurin',
|
||||||
@@ -17,8 +17,7 @@ export enum JavaDistribution {
|
|||||||
GraalVMCommunity = 'graalvm-community',
|
GraalVMCommunity = 'graalvm-community',
|
||||||
JetBrains = 'jetbrains',
|
JetBrains = 'jetbrains',
|
||||||
Kona = 'kona',
|
Kona = 'kona',
|
||||||
OracleOpenJdk = 'oracle-openjdk',
|
OracleOpenJdk = 'oracle-openjdk'
|
||||||
RedHat = 'redhat'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const JAVA_PACKAGE_CAPABILITIES = {
|
export const JAVA_PACKAGE_CAPABILITIES = {
|
||||||
@@ -51,8 +50,7 @@ export const JAVA_PACKAGE_CAPABILITIES = {
|
|||||||
'jre+ft'
|
'jre+ft'
|
||||||
],
|
],
|
||||||
[JavaDistribution.Kona]: ['jdk'],
|
[JavaDistribution.Kona]: ['jdk'],
|
||||||
[JavaDistribution.OracleOpenJdk]: ['jdk'],
|
[JavaDistribution.OracleOpenJdk]: ['jdk']
|
||||||
[JavaDistribution.RedHat]: ['jdk', 'jre']
|
|
||||||
} as const satisfies Record<JavaDistribution, readonly string[]>;
|
} as const satisfies Record<JavaDistribution, readonly string[]>;
|
||||||
|
|
||||||
export function validateJavaPackage(
|
export function validateJavaPackage(
|
||||||
@@ -98,9 +96,12 @@ function canResolveTemurinJmods(version: string): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedRange = normalizeJavaVersionToSemver(
|
let normalizedRange = normalizedVersion
|
||||||
normalizedVersion.replace(/-ea$/, '').replace('-ea.', '+')
|
.replace(/-ea$/, '')
|
||||||
);
|
.replace('-ea.', '+');
|
||||||
|
if (/^\d+(\.\d+){3,}$/.test(normalizedRange)) {
|
||||||
|
normalizedRange = convertVersionToSemver(normalizedRange);
|
||||||
|
}
|
||||||
if (!semver.validRange(normalizedRange)) {
|
if (!semver.validRange(normalizedRange)) {
|
||||||
// JavaBase owns general version validation and its targeted error messages.
|
// JavaBase owns general version validation and its targeted error messages.
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,14 +5,7 @@ import {JavaDistribution} from './package-types.js';
|
|||||||
export type JavaPlatform = 'linux' | 'macos' | 'windows' | 'solaris';
|
export type JavaPlatform = 'linux' | 'macos' | 'windows' | 'solaris';
|
||||||
|
|
||||||
export type JavaArchitecture =
|
export type JavaArchitecture =
|
||||||
| 'x86'
|
'x86' | 'x64' | 'armv7' | 'aarch64' | 'ppc64le' | 'ppc64' | 's390x';
|
||||||
| 'x64'
|
|
||||||
| 'armv7'
|
|
||||||
| 'aarch64'
|
|
||||||
| 'ppc64le'
|
|
||||||
| 'ppc64'
|
|
||||||
| 'riscv64'
|
|
||||||
| 's390x';
|
|
||||||
|
|
||||||
interface VersionedArchitecture {
|
interface VersionedArchitecture {
|
||||||
architecture: JavaArchitecture;
|
architecture: JavaArchitecture;
|
||||||
@@ -34,14 +27,7 @@ export type JavaPlatformCapability =
|
|||||||
RestrictedPlatformCapability | UnrestrictedPlatformCapability;
|
RestrictedPlatformCapability | UnrestrictedPlatformCapability;
|
||||||
|
|
||||||
const X64_ARM64 = ['x64', 'aarch64'] as const;
|
const X64_ARM64 = ['x64', 'aarch64'] as const;
|
||||||
const STANDARD_LINUX = [
|
const STANDARD_LINUX = ['x64', 'x86', 'aarch64', 'ppc64le', 's390x'] as const;
|
||||||
'x64',
|
|
||||||
'x86',
|
|
||||||
'aarch64',
|
|
||||||
'ppc64le',
|
|
||||||
'riscv64',
|
|
||||||
's390x'
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export const JAVA_PLATFORM_CAPABILITIES: Record<
|
export const JAVA_PLATFORM_CAPABILITIES: Record<
|
||||||
JavaDistribution,
|
JavaDistribution,
|
||||||
@@ -159,19 +145,6 @@ export const JAVA_PLATFORM_CAPABILITIES: Record<
|
|||||||
macos: X64_ARM64,
|
macos: X64_ARM64,
|
||||||
windows: ['x64']
|
windows: ['x64']
|
||||||
}
|
}
|
||||||
},
|
|
||||||
[JavaDistribution.RedHat]: {
|
|
||||||
platforms: {
|
|
||||||
linux: [
|
|
||||||
'x64',
|
|
||||||
{architecture: 'aarch64', versionRange: '<12'},
|
|
||||||
{architecture: 'ppc64le', versionRange: '<12'}
|
|
||||||
],
|
|
||||||
windows: [
|
|
||||||
{architecture: 'x64', versionRange: '<22'},
|
|
||||||
{architecture: 'x86', versionRange: '<11'}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -188,7 +161,6 @@ const CANONICAL_ARCHITECTURES: readonly JavaArchitecture[] = [
|
|||||||
'aarch64',
|
'aarch64',
|
||||||
'ppc64le',
|
'ppc64le',
|
||||||
'ppc64',
|
'ppc64',
|
||||||
'riscv64',
|
|
||||||
's390x'
|
's390x'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,180 +0,0 @@
|
|||||||
import * as core from '@actions/core';
|
|
||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
import semver from 'semver';
|
|
||||||
import {
|
|
||||||
cacheJdkDir,
|
|
||||||
extractJdkFile,
|
|
||||||
isVersionSatisfies,
|
|
||||||
renameWinArchive
|
|
||||||
} from '../../util.js';
|
|
||||||
import {JavaBase} from '../base-installer.js';
|
|
||||||
import {
|
|
||||||
JavaDownloadRelease,
|
|
||||||
JavaInstallerOptions,
|
|
||||||
JavaInstallerResults
|
|
||||||
} from '../base-models.js';
|
|
||||||
import {
|
|
||||||
IDiscoPackage,
|
|
||||||
IDiscoPackageDetailsResponse,
|
|
||||||
IDiscoPackageListResponse
|
|
||||||
} from './models.js';
|
|
||||||
import {isAlpineLinux} from '../platform-types.js';
|
|
||||||
|
|
||||||
const DISCO_API_URL = 'https://api.foojay.io/disco/v3.0';
|
|
||||||
|
|
||||||
export class RedHatDistribution extends JavaBase {
|
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
|
||||||
super('RedHat', installerOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async findPackageForDownload(
|
|
||||||
range: string
|
|
||||||
): Promise<JavaDownloadRelease> {
|
|
||||||
if (!this.stable) {
|
|
||||||
throw new Error('Early access versions are not supported');
|
|
||||||
}
|
|
||||||
|
|
||||||
const availablePackages = await this.getAvailablePackages();
|
|
||||||
const normalizedPackages = availablePackages
|
|
||||||
.map(item => ({
|
|
||||||
item,
|
|
||||||
version: this.normalizeDiscoVersion(item.java_version)
|
|
||||||
}))
|
|
||||||
.filter(
|
|
||||||
(item): item is {item: IDiscoPackage; version: string} =>
|
|
||||||
item.version !== null
|
|
||||||
)
|
|
||||||
.sort((left, right) => -semver.compareBuild(left.version, right.version));
|
|
||||||
|
|
||||||
const selectedPackage = normalizedPackages.find(item =>
|
|
||||||
isVersionSatisfies(range, item.version)
|
|
||||||
);
|
|
||||||
if (!selectedPackage) {
|
|
||||||
throw this.createVersionNotFoundError(
|
|
||||||
range,
|
|
||||||
normalizedPackages.map(item => item.version),
|
|
||||||
`Operating system: ${this.getOperatingSystem()}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const detailsUrl = `${DISCO_API_URL}/ids/${selectedPackage.item.id}`;
|
|
||||||
const response =
|
|
||||||
await this.http.getJson<IDiscoPackageDetailsResponse>(detailsUrl);
|
|
||||||
const details = response.result?.result?.[0];
|
|
||||||
if (!details?.direct_download_uri) {
|
|
||||||
throw new Error(
|
|
||||||
`Foojay Disco returned no direct Red Hat download URL for package '${selectedPackage.item.id}'.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const checksum = details.checksum?.trim();
|
|
||||||
if (details.checksum_type?.toLowerCase() !== 'sha256' || !checksum) {
|
|
||||||
throw new Error(
|
|
||||||
`Foojay Disco returned no SHA-256 checksum for Red Hat package '${selectedPackage.item.id}'.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
version: selectedPackage.version,
|
|
||||||
url: details.direct_download_uri,
|
|
||||||
checksum: {
|
|
||||||
algorithm: 'sha256',
|
|
||||||
value: checksum,
|
|
||||||
source: detailsUrl
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async downloadTool(
|
|
||||||
javaRelease: JavaDownloadRelease
|
|
||||||
): Promise<JavaInstallerResults> {
|
|
||||||
core.info(
|
|
||||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
|
||||||
);
|
|
||||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
|
||||||
|
|
||||||
core.info('Extracting Java archive...');
|
|
||||||
const archiveType = this.getArchiveType();
|
|
||||||
if (archiveType === 'zip') {
|
|
||||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
|
||||||
}
|
|
||||||
const extractedJavaPath = await extractJdkFile(
|
|
||||||
javaArchivePath,
|
|
||||||
archiveType
|
|
||||||
);
|
|
||||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
|
||||||
if (!archiveName) {
|
|
||||||
throw new Error(
|
|
||||||
`The Red Hat archive for Java ${javaRelease.version} was empty.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
|
||||||
const javaPath = await cacheJdkDir(
|
|
||||||
archivePath,
|
|
||||||
this.toolcacheFolderName,
|
|
||||||
this.getToolcacheVersionName(javaRelease.version),
|
|
||||||
this.architecture
|
|
||||||
);
|
|
||||||
|
|
||||||
return {version: javaRelease.version, path: javaPath};
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getAvailablePackages(): Promise<IDiscoPackage[]> {
|
|
||||||
const operatingSystem = this.getOperatingSystem();
|
|
||||||
const archiveType = this.getArchiveType();
|
|
||||||
const query = new URLSearchParams({
|
|
||||||
distro: 'redhat',
|
|
||||||
release_status: 'ga',
|
|
||||||
operating_system: operatingSystem,
|
|
||||||
architecture: this.distributionArchitecture(),
|
|
||||||
package_type: this.packageType,
|
|
||||||
archive_type: archiveType,
|
|
||||||
directly_downloadable: 'true'
|
|
||||||
});
|
|
||||||
const url = `${DISCO_API_URL}/packages?${query.toString()}`;
|
|
||||||
const response = await this.http.getJson<IDiscoPackageListResponse>(url);
|
|
||||||
const packages = response.result?.result;
|
|
||||||
if (!Array.isArray(packages)) {
|
|
||||||
throw new Error(
|
|
||||||
`Could not fetch Red Hat package metadata from Foojay Disco: ${url}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return packages.filter(
|
|
||||||
item =>
|
|
||||||
item.distribution === 'redhat' &&
|
|
||||||
item.release_status === 'ga' &&
|
|
||||||
item.operating_system === operatingSystem &&
|
|
||||||
item.architecture === this.distributionArchitecture() &&
|
|
||||||
item.package_type === this.packageType &&
|
|
||||||
item.archive_type === archiveType &&
|
|
||||||
item.directly_downloadable
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getOperatingSystem(alpine = isAlpineLinux()): string {
|
|
||||||
if (alpine) {
|
|
||||||
throw new Error(
|
|
||||||
"Distribution 'redhat' does not support Alpine Linux because Red Hat portable archives require glibc."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return process.platform === 'win32' ? 'windows' : 'linux';
|
|
||||||
}
|
|
||||||
|
|
||||||
private getArchiveType(): string {
|
|
||||||
return process.platform === 'win32' ? 'zip' : 'tar.xz';
|
|
||||||
}
|
|
||||||
|
|
||||||
private normalizeDiscoVersion(version: string): string | null {
|
|
||||||
let normalizedVersion = version.trim();
|
|
||||||
if (/^\d+\+\d+$/.test(normalizedVersion)) {
|
|
||||||
normalizedVersion = normalizedVersion.replace('+', '.0.0+');
|
|
||||||
} else if (/^\d+$/.test(normalizedVersion)) {
|
|
||||||
normalizedVersion = `${normalizedVersion}.0.0`;
|
|
||||||
} else if (/^\d+\.\d+$/.test(normalizedVersion)) {
|
|
||||||
normalizedVersion = `${normalizedVersion}.0`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return semver.valid(normalizedVersion) ? normalizedVersion : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
export interface IDiscoPackage {
|
|
||||||
id: string;
|
|
||||||
archive_type: string;
|
|
||||||
distribution: string;
|
|
||||||
java_version: string;
|
|
||||||
release_status: string;
|
|
||||||
operating_system: string;
|
|
||||||
architecture: string;
|
|
||||||
package_type: string;
|
|
||||||
directly_downloadable: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IDiscoPackageListResponse {
|
|
||||||
result: IDiscoPackage[];
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IDiscoPackageDetails {
|
|
||||||
filename: string;
|
|
||||||
direct_download_uri: string;
|
|
||||||
checksum: string;
|
|
||||||
checksum_type: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IDiscoPackageDetailsResponse {
|
|
||||||
result: IDiscoPackageDetails[];
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
@@ -8,10 +8,7 @@ import * as gpg from '../../gpg.js';
|
|||||||
import {ADOPTIUM_PUBLIC_KEY} from './adoptium-key.js';
|
import {ADOPTIUM_PUBLIC_KEY} from './adoptium-key.js';
|
||||||
import {JavaBase} from '../base-installer.js';
|
import {JavaBase} from '../base-installer.js';
|
||||||
import {ITemurinAvailableVersions} from './models.js';
|
import {ITemurinAvailableVersions} from './models.js';
|
||||||
import {
|
import {MACOS_JAVA_CONTENT_POSTFIX} from '../../constants.js';
|
||||||
MACOS_JAVA_CONTENT_POSTFIX,
|
|
||||||
SIGNATURE_VERIFICATION_FAILURE_HELP
|
|
||||||
} from '../../constants.js';
|
|
||||||
import {
|
import {
|
||||||
JavaDownloadRelease,
|
JavaDownloadRelease,
|
||||||
JavaInstallerOptions,
|
JavaInstallerOptions,
|
||||||
@@ -70,7 +67,7 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
const formattedVersion = this.stable
|
const formattedVersion = this.stable
|
||||||
? item.version_data.semver
|
? item.version_data.semver
|
||||||
: item.version_data.semver.replace('-beta+', '+');
|
: item.version_data.semver.replace('-beta+', '+');
|
||||||
const release: JavaDownloadRelease = {
|
return {
|
||||||
version: formattedVersion,
|
version: formattedVersion,
|
||||||
url: item.binaries[0].package.link,
|
url: item.binaries[0].package.link,
|
||||||
signatureUrl: item.binaries[0].package.signature_link,
|
signatureUrl: item.binaries[0].package.signature_link,
|
||||||
@@ -79,29 +76,11 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
value: item.binaries[0].package.checksum,
|
value: item.binaries[0].package.checksum,
|
||||||
source: item.binaries[0].package.checksum_link
|
source: item.binaries[0].package.checksum_link
|
||||||
}
|
}
|
||||||
};
|
} as JavaDownloadRelease;
|
||||||
return {
|
|
||||||
release,
|
|
||||||
openjdkVersion: getOpenJdkSemverVersion(item.version_data)
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// The Adoptium API `semver` folds the JEP 322 patch field into the build
|
|
||||||
// number ('26.0.2.1+1' -> '26.0.2+101') and appends extra metadata for LTS
|
|
||||||
// releases ('25.0.4+7' -> '25.0.4+7.0.LTS'). Exact versions requested by
|
|
||||||
// users follow the OpenJDK notation instead, so also match them against a
|
|
||||||
// key derived from the OpenJDK version fields ('26.0.2+1.1', '25.0.4+7').
|
|
||||||
const isExactBuildRequest = (semver.parse(version)?.build.length ?? 0) > 0;
|
|
||||||
|
|
||||||
const satisfiedVersions = availableVersionsWithBinaries
|
const satisfiedVersions = availableVersionsWithBinaries
|
||||||
.filter(
|
.filter(item => isVersionSatisfies(version, item.version))
|
||||||
({release, openjdkVersion}) =>
|
|
||||||
isVersionSatisfies(version, release.version) ||
|
|
||||||
(isExactBuildRequest &&
|
|
||||||
openjdkVersion !== null &&
|
|
||||||
semver.compareBuild(version, openjdkVersion) === 0)
|
|
||||||
)
|
|
||||||
.map(({release}) => release)
|
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return -semver.compareBuild(a.version, b.version);
|
return -semver.compareBuild(a.version, b.version);
|
||||||
});
|
});
|
||||||
@@ -110,7 +89,7 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
|
||||||
if (!resolvedFullVersion) {
|
if (!resolvedFullVersion) {
|
||||||
const availableVersionStrings = availableVersionsWithBinaries.map(
|
const availableVersionStrings = availableVersionsWithBinaries.map(
|
||||||
({release}) => release.version
|
item => item.version
|
||||||
);
|
);
|
||||||
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
throw this.createVersionNotFoundError(version, availableVersionStrings);
|
||||||
}
|
}
|
||||||
@@ -162,12 +141,6 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
const archivePath = await this.downloadAndVerify(release);
|
const archivePath = await this.downloadAndVerify(release);
|
||||||
|
|
||||||
if (this.verifySignature) {
|
if (this.verifySignature) {
|
||||||
try {
|
|
||||||
if (!(await gpg.isGpgAvailable())) {
|
|
||||||
throw new Error(
|
|
||||||
"Input 'verify-signature' is enabled, but gpg is not available."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!release.signatureUrl) {
|
if (!release.signatureUrl) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`
|
`Input 'verify-signature' is enabled, but no signature URL was found for Temurin version ${release.version}.`
|
||||||
@@ -181,23 +154,12 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY
|
this.verifySignaturePublicKey ?? ADOPTIUM_PUBLIC_KEY
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const verificationError = new Error(
|
throw new Error(
|
||||||
`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${(error as Error).message} ${SIGNATURE_VERIFICATION_FAILURE_HELP}`,
|
`Failed to verify signature for Temurin version ${release.version} from ${release.signatureUrl}: ${
|
||||||
|
(error as Error).message
|
||||||
|
}`,
|
||||||
{cause: error}
|
{cause: error}
|
||||||
);
|
);
|
||||||
if (this.verifySignatureExplicitlyRequested) {
|
|
||||||
throw verificationError;
|
|
||||||
} else {
|
|
||||||
core.warning(verificationError.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (this.verifySignatureExplicitlyRequested) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
core.warning(
|
|
||||||
error instanceof Error ? error.message : `Unknown error: ${error}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,20 +289,3 @@ export class TemurinDistribution extends JavaBase {
|
|||||||
return architecture === 'armv7' ? 'arm' : architecture;
|
return architecture === 'armv7' ? 'arm' : architecture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a SemVer version from the OpenJDK version fields reported by the
|
|
||||||
* Adoptium API, e.g. '26.0.2.1+1' -> '26.0.2+1.1' and '25.0.4+7-LTS' ->
|
|
||||||
* '25.0.4+7'. Returns null if the fields cannot form a valid SemVer version.
|
|
||||||
*/
|
|
||||||
function getOpenJdkSemverVersion(
|
|
||||||
versionData: ITemurinAvailableVersions['version_data']
|
|
||||||
): string | null {
|
|
||||||
const {major, minor, security, patch, build} = versionData;
|
|
||||||
if (build === undefined || build === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const buildMetadata = patch ? `${patch}.${build}` : `${build}`;
|
|
||||||
const version = `${major}.${minor}.${security}+${buildMetadata}`;
|
|
||||||
return semver.valid(version) ? version : null;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ export interface ITemurinAvailableVersions {
|
|||||||
minor: number;
|
minor: number;
|
||||||
openjdk_version: string;
|
openjdk_version: string;
|
||||||
security: string;
|
security: string;
|
||||||
patch?: number;
|
|
||||||
semver: string;
|
semver: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
|||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
import {JavaBase} from '../base-installer.js';
|
import {JavaBase} from '../base-installer.js';
|
||||||
import {IZuluPackageDetails, IZuluVersions} from './models.js';
|
import {IZuluPackageDetails, IZuluVersions} from './models.js';
|
||||||
@@ -29,17 +30,6 @@ interface ZuluResolvedRelease {
|
|||||||
packageUuid: string;
|
packageUuid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareNumberArrays(a: number[], b: number[]): number {
|
|
||||||
const length = Math.max(a.length, b.length);
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
const diff = (a[i] ?? 0) - (b[i] ?? 0);
|
|
||||||
if (diff !== 0) {
|
|
||||||
return diff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ZuluDistribution extends JavaBase {
|
export class ZuluDistribution extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
super('Zulu', installerOptions);
|
super('Zulu', installerOptions);
|
||||||
@@ -60,9 +50,7 @@ export class ZuluDistribution extends JavaBase {
|
|||||||
return {
|
return {
|
||||||
version: convertVersionToSemver(javaVersion),
|
version: convertVersionToSemver(javaVersion),
|
||||||
url: item.download_url,
|
url: item.download_url,
|
||||||
javaVersion: item.java_version,
|
zuluVersion: convertVersionToSemver(item.distro_version),
|
||||||
buildNumber: item.openjdk_build_number ?? 0,
|
|
||||||
distroVersion: item.distro_version,
|
|
||||||
packageUuid: item.package_uuid
|
packageUuid: item.package_uuid
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -70,14 +58,11 @@ export class ZuluDistribution extends JavaBase {
|
|||||||
const satisfiedVersions = availableVersions
|
const satisfiedVersions = availableVersions
|
||||||
.filter(item => isVersionSatisfies(version, item.version))
|
.filter(item => isVersionSatisfies(version, item.version))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
// Compare numerically rather than via semver build metadata: Azul
|
// Azul provides two versions: java_version and distro_version
|
||||||
// hotfix releases carry a 4th java_version segment (e.g. 25.0.4.1+1,
|
// we should sort by both fields by descending
|
||||||
// rendered as '25.0.4+1.1') that must rank above 25.0.4+7, whereas
|
|
||||||
// semver.compareBuild would order the build identifiers '7' > '1'.
|
|
||||||
return (
|
return (
|
||||||
-compareNumberArrays(a.javaVersion, b.javaVersion) ||
|
-semver.compareBuild(a.version, b.version) ||
|
||||||
b.buildNumber - a.buildNumber ||
|
-semver.compareBuild(a.zuluVersion, b.zuluVersion)
|
||||||
-compareNumberArrays(a.distroVersion, b.distroVersion)
|
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.map((item): ZuluResolvedRelease => ({
|
.map((item): ZuluResolvedRelease => ({
|
||||||
|
|||||||
+11
-31
@@ -5,16 +5,11 @@ import * as io from '@actions/io';
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as util from './util.js';
|
import * as util from './util.js';
|
||||||
import type {ExecOptions} from '@actions/exec';
|
import {ExecOptions} from '@actions/exec';
|
||||||
import type {SignatureVerificationKey} from './distributions/base-models.js';
|
|
||||||
|
|
||||||
export const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
export const GPG_HOME_PREFIX = 'setup-java-gpg-';
|
||||||
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
const VERIFY_GPG_HOME_PREFIX = 'verify-signature-gpg-home-';
|
||||||
|
|
||||||
export async function isGpgAvailable(): Promise<boolean> {
|
|
||||||
return Boolean(await io.which('gpg', false));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
// Convert a Windows path (D:\a\_temp\...) to a POSIX path (/d/a/_temp/...).
|
||||||
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
// The Git-bundled GPG on Windows (MSYS2-based) uses POSIX path conventions
|
||||||
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
// internally. Passing Windows paths with backslashes can cause fatal GPG errors
|
||||||
@@ -26,11 +21,8 @@ export function toGpgPath(p: string): string {
|
|||||||
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createGpgHome(
|
function createGpgHome(prefix: string): string {
|
||||||
prefix: string,
|
const gpgHome = fs.mkdtempSync(path.join(util.getTempDir(), prefix));
|
||||||
tempDir: string = util.getTempDir()
|
|
||||||
): string {
|
|
||||||
const gpgHome = fs.mkdtempSync(path.join(tempDir, prefix));
|
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
fs.chmodSync(gpgHome, 0o700);
|
fs.chmodSync(gpgHome, 0o700);
|
||||||
}
|
}
|
||||||
@@ -89,33 +81,28 @@ export async function removeGpgHome(gpgHome: string): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await stopGpgAgent(resolvedGpgHome);
|
|
||||||
await io.rmRF(resolvedGpgHome);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function stopGpgAgent(gpgHome: string): Promise<void> {
|
|
||||||
try {
|
try {
|
||||||
await exec.exec(
|
await exec.exec(
|
||||||
'gpgconf',
|
'gpgconf',
|
||||||
['--homedir', toGpgPath(gpgHome), '--kill', 'gpg-agent'],
|
['--homedir', toGpgPath(resolvedGpgHome), '--kill', 'gpg-agent'],
|
||||||
{silent: true, ignoreReturnCode: true}
|
{silent: true, ignoreReturnCode: true}
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
// gpgconf may be unavailable, but directory removal must still be attempted.
|
// gpgconf may be unavailable, but directory removal must still be attempted.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await io.rmRF(resolvedGpgHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function verifyPackageSignature(
|
export async function verifyPackageSignature(
|
||||||
archivePath: string,
|
archivePath: string,
|
||||||
signatureUrl: string,
|
signatureUrl: string,
|
||||||
publicKeyContent: SignatureVerificationKey
|
publicKeyContent: string
|
||||||
) {
|
) {
|
||||||
const signaturePath = await tc.downloadTool(signatureUrl);
|
const signaturePath = await tc.downloadTool(signatureUrl);
|
||||||
let gpgHome: string;
|
let gpgHome: string;
|
||||||
try {
|
try {
|
||||||
// Both RUNNER_TEMP and TMPDIR can exceed macOS's 104-byte agent socket limit.
|
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX);
|
||||||
const tempDir = process.platform === 'darwin' ? '/tmp' : util.getTempDir();
|
|
||||||
gpgHome = createGpgHome(VERIFY_GPG_HOME_PREFIX, tempDir);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
try {
|
try {
|
||||||
await io.rmRF(signaturePath);
|
await io.rmRF(signaturePath);
|
||||||
@@ -130,14 +117,8 @@ export async function verifyPackageSignature(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const publicKeys = Array.isArray(publicKeyContent)
|
const publicKeyFile = path.join(gpgHome, 'public-key.asc');
|
||||||
? publicKeyContent
|
fs.writeFileSync(publicKeyFile, publicKeyContent, {encoding: 'utf-8'});
|
||||||
: [publicKeyContent];
|
|
||||||
const publicKeyFiles = publicKeys.map((publicKey, index) => {
|
|
||||||
const publicKeyFile = path.join(gpgHome, `public-key-${index}.asc`);
|
|
||||||
fs.writeFileSync(publicKeyFile, publicKey, {encoding: 'utf-8'});
|
|
||||||
return toGpgPath(publicKeyFile);
|
|
||||||
});
|
|
||||||
const options: ExecOptions = {silent: true};
|
const options: ExecOptions = {silent: true};
|
||||||
await exec.exec(
|
await exec.exec(
|
||||||
'gpg',
|
'gpg',
|
||||||
@@ -146,7 +127,7 @@ export async function verifyPackageSignature(
|
|||||||
toGpgPath(gpgHome),
|
toGpgPath(gpgHome),
|
||||||
'--batch',
|
'--batch',
|
||||||
'--import',
|
'--import',
|
||||||
...publicKeyFiles
|
toGpgPath(publicKeyFile)
|
||||||
],
|
],
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
@@ -163,7 +144,6 @@ export async function verifyPackageSignature(
|
|||||||
options
|
options
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
await stopGpgAgent(gpgHome);
|
|
||||||
await io.rmRF(signaturePath);
|
await io.rmRF(signaturePath);
|
||||||
await io.rmRF(gpgHome);
|
await io.rmRF(gpgHome);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import fs from 'fs';
|
|
||||||
import {fileURLToPath} from 'url';
|
|
||||||
|
|
||||||
export function isMainModule(moduleUrl: string): boolean {
|
|
||||||
const entrypoint = process.argv[1];
|
|
||||||
if (!entrypoint || entrypoint === '-') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let entrypointPath: string;
|
|
||||||
try {
|
|
||||||
entrypointPath = fs.realpathSync(entrypoint);
|
|
||||||
} catch (error) {
|
|
||||||
if (
|
|
||||||
error instanceof Error &&
|
|
||||||
'code' in error &&
|
|
||||||
(error.code === 'ENOENT' || error.code === 'ENOTDIR')
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve both paths for runtimes using --preserve-symlinks-main.
|
|
||||||
return entrypointPath === fs.realpathSync(fileURLToPath(moduleUrl));
|
|
||||||
}
|
|
||||||
+6
-19
@@ -4,7 +4,6 @@ import path from 'path';
|
|||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {isCacheFeatureAvailable} from './cache-feature.js';
|
import {isCacheFeatureAvailable} from './cache-feature.js';
|
||||||
import type {SignatureVerificationKey} from './distributions/base-models.js';
|
|
||||||
|
|
||||||
const STATE_JDK_CACHES = 'jdk-caches';
|
const STATE_JDK_CACHES = 'jdk-caches';
|
||||||
const JDK_CACHE_KEY_VERSION = 1;
|
const JDK_CACHE_KEY_VERSION = 1;
|
||||||
@@ -118,30 +117,18 @@ function getInstallationIdentity(
|
|||||||
|
|
||||||
export function getJdkVerificationIdentity(
|
export function getJdkVerificationIdentity(
|
||||||
verifySignature: boolean,
|
verifySignature: boolean,
|
||||||
enforceSignatureVerification: boolean,
|
publicKey?: string
|
||||||
publicKey?: SignatureVerificationKey
|
|
||||||
): string {
|
): string {
|
||||||
if (!verifySignature) {
|
if (!verifySignature) {
|
||||||
return 'disabled';
|
return 'unverified';
|
||||||
}
|
}
|
||||||
const verificationPolicy = enforceSignatureVerification
|
|
||||||
? 'enforced'
|
|
||||||
: 'check-and-warn';
|
|
||||||
if (!publicKey) {
|
if (!publicKey) {
|
||||||
return `${verificationPolicy}:bundled`;
|
return 'verified:bundled';
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKeys = Array.isArray(publicKey) ? publicKey : [publicKey];
|
const normalizedKey = publicKey.replace(/\r\n?/g, '\n').trim();
|
||||||
const normalizedKeys = publicKeys.map(key =>
|
const fingerprint = createHash('sha256').update(normalizedKey).digest('hex');
|
||||||
key.replace(/\r\n?/g, '\n').trim()
|
return `verified:custom:sha256:${fingerprint}`;
|
||||||
);
|
|
||||||
const fingerprintSource = Array.isArray(publicKey)
|
|
||||||
? normalizedKeys.map(key => `${Buffer.byteLength(key)}:${key}`).join('')
|
|
||||||
: normalizedKeys[0];
|
|
||||||
const fingerprint = createHash('sha256')
|
|
||||||
.update(fingerprintSource)
|
|
||||||
.digest('hex');
|
|
||||||
return `${verificationPolicy}:custom:sha256:${fingerprint}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function saveJdkCaches(): Promise<void> {
|
export async function saveJdkCaches(): Promise<void> {
|
||||||
|
|||||||
+6
-13
@@ -12,7 +12,6 @@ import {getJavaDistribution} from './distributions/distribution-factory.js';
|
|||||||
import {JavaInstallerOptions} from './distributions/base-models.js';
|
import {JavaInstallerOptions} from './distributions/base-models.js';
|
||||||
import {configureProblemMatcher} from './problem-matcher.js';
|
import {configureProblemMatcher} from './problem-matcher.js';
|
||||||
import {validateToolchainIds} from './toolchain-ids.js';
|
import {validateToolchainIds} from './toolchain-ids.js';
|
||||||
import {isMainModule} from './is-main-module.js';
|
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION);
|
||||||
@@ -30,6 +29,10 @@ export async function run() {
|
|||||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||||
const forceDownload = getBooleanInput(constants.INPUT_FORCE_DOWNLOAD, false);
|
const forceDownload = getBooleanInput(constants.INPUT_FORCE_DOWNLOAD, false);
|
||||||
const setDefault = getBooleanInput(constants.INPUT_SET_DEFAULT, true);
|
const setDefault = getBooleanInput(constants.INPUT_SET_DEFAULT, true);
|
||||||
|
const verifySignature = getBooleanInput(
|
||||||
|
constants.INPUT_VERIFY_SIGNATURE,
|
||||||
|
false
|
||||||
|
);
|
||||||
const verifySignaturePublicKey =
|
const verifySignaturePublicKey =
|
||||||
core.getInput(constants.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY) || undefined;
|
core.getInput(constants.INPUT_VERIFY_SIGNATURE_PUBLIC_KEY) || undefined;
|
||||||
const toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
const toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||||
@@ -77,8 +80,6 @@ export async function run() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifySignature = getVerifySignatureInput();
|
|
||||||
|
|
||||||
const installerInputsOptions: installerInputsOptions = {
|
const installerInputsOptions: installerInputsOptions = {
|
||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
@@ -106,8 +107,6 @@ export async function run() {
|
|||||||
throw new Error('distribution input is required');
|
throw new Error('distribution input is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifySignature = getVerifySignatureInput();
|
|
||||||
|
|
||||||
const installerInputsOptions: installerInputsOptions = {
|
const installerInputsOptions: installerInputsOptions = {
|
||||||
architecture,
|
architecture,
|
||||||
packageType,
|
packageType,
|
||||||
@@ -173,7 +172,7 @@ function settle<T>(promise: Promise<T>): Promise<PromiseSettledResult<T>> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMainModule(import.meta.url)) {
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
run();
|
run();
|
||||||
} else {
|
} else {
|
||||||
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
||||||
@@ -193,12 +192,6 @@ function getJdkFileInput(): string {
|
|||||||
return jdkFile || deprecatedJdkFile;
|
return jdkFile || deprecatedJdkFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVerifySignatureInput(): boolean | undefined {
|
|
||||||
return core.getInput(constants.INPUT_VERIFY_SIGNATURE).trim()
|
|
||||||
? getBooleanInput(constants.INPUT_VERIFY_SIGNATURE)
|
|
||||||
: undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function installVersion(
|
async function installVersion(
|
||||||
version: string,
|
version: string,
|
||||||
options: installerInputsOptions,
|
options: installerInputsOptions,
|
||||||
@@ -270,7 +263,7 @@ interface installerInputsOptions {
|
|||||||
forceDownload: boolean;
|
forceDownload: boolean;
|
||||||
cacheJdk: boolean;
|
cacheJdk: boolean;
|
||||||
setDefault: boolean;
|
setDefault: boolean;
|
||||||
verifySignature: boolean | undefined;
|
verifySignature: boolean;
|
||||||
verifySignaturePublicKey: string | undefined;
|
verifySignaturePublicKey: string | undefined;
|
||||||
distributionName: string;
|
distributionName: string;
|
||||||
jdkFile: string;
|
jdkFile: string;
|
||||||
|
|||||||
-19
@@ -59,8 +59,6 @@ export async function extractJdkFile(toolPath: string, extension?: string) {
|
|||||||
if (!extension) {
|
if (!extension) {
|
||||||
extension = toolPath.endsWith('.tar.gz')
|
extension = toolPath.endsWith('.tar.gz')
|
||||||
? 'tar.gz'
|
? 'tar.gz'
|
||||||
: toolPath.endsWith('.tar.xz')
|
|
||||||
? 'tar.xz'
|
|
||||||
: path.extname(toolPath);
|
: path.extname(toolPath);
|
||||||
if (extension.startsWith('.')) {
|
if (extension.startsWith('.')) {
|
||||||
extension = extension.substring(1);
|
extension = extension.substring(1);
|
||||||
@@ -70,8 +68,6 @@ export async function extractJdkFile(toolPath: string, extension?: string) {
|
|||||||
switch (extension) {
|
switch (extension) {
|
||||||
case 'tar.gz':
|
case 'tar.gz':
|
||||||
return await extractTarGz(toolPath);
|
return await extractTarGz(toolPath);
|
||||||
case 'tar.xz':
|
|
||||||
return await tc.extractTar(toolPath, undefined, 'xJ');
|
|
||||||
case 'tar':
|
case 'tar':
|
||||||
return await tc.extractTar(toolPath);
|
return await tc.extractTar(toolPath);
|
||||||
case 'zip':
|
case 'zip':
|
||||||
@@ -510,21 +506,6 @@ export function convertVersionToSemver(version: number[] | string) {
|
|||||||
return mainVersion;
|
return mainVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Java versions (JEP 322) can contain more numeric fields than SemVer allows,
|
|
||||||
* e.g. '11.0.9.1' or Temurin respins such as '26.0.2.1+1'. Move the extra
|
|
||||||
* fields into SemVer build metadata ('11.0.9+1', '26.0.2+1.1'). Any other
|
|
||||||
* input (ranges, regular SemVer versions) is returned unchanged.
|
|
||||||
*/
|
|
||||||
export function normalizeJavaVersionToSemver(version: string): string {
|
|
||||||
const match = /^(\d+(?:\.\d+){3,})(?:\+([0-9A-Za-z.-]+))?$/.exec(version);
|
|
||||||
if (!match) {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
const converted = convertVersionToSemver(match[1]);
|
|
||||||
return match[2] ? `${converted}.${match[2]}` : converted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a validator for the bytes currently served by a URL from the response
|
* Builds a validator for the bytes currently served by a URL from the response
|
||||||
* headers of a HEAD request. A vendor's `/latest/` URL never changes, so this
|
* headers of a HEAD request. A vendor's `/latest/` URL never changes, so this
|
||||||
|
|||||||
Reference in New Issue
Block a user