mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 09:56:46 +00:00
add overwrite-settings parameter
This commit is contained in:
parent
7c88894700
commit
b86b190044
9 changed files with 165 additions and 36 deletions
82
.github/workflows/e2e-publishing.yml
vendored
82
.github/workflows/e2e-publishing.yml
vendored
|
@ -11,6 +11,10 @@ on:
|
|||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: pwsh
|
||||
|
||||
jobs:
|
||||
setup-java-publishing:
|
||||
name: Validate settings.xml
|
||||
|
@ -34,12 +38,7 @@ jobs:
|
|||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
||||
- name: Validate settings.xml
|
||||
run: |
|
||||
$homePath = $env:USERPROFILE
|
||||
if (-not $homePath) {
|
||||
$homePath = $env:HOME
|
||||
}
|
||||
$xmlPath = Join-Path $homePath ".m2" "settings.xml"
|
||||
|
||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||
Get-Content $xmlPath | ForEach-Object { Write-Host $_ }
|
||||
|
||||
[xml]$xml = Get-Content $xmlPath
|
||||
|
@ -51,7 +50,73 @@ jobs:
|
|||
if (($servers[1].id -ne 'gpg.passphrase') -or ($servers[1].passphrase -ne '${env.MAVEN_GPG_PASSPHRASE}')) {
|
||||
throw "Generated XML file is incorrect"
|
||||
}
|
||||
shell: pwsh
|
||||
|
||||
test-publishing-overwrite:
|
||||
name: Validate settings.xml is not overwritten if flag is false
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Create fake settings.xml
|
||||
run: |
|
||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||
Set-Content -Path $xmlPath -Value "Fake_XML"
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
server-id: maven
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_CENTRAL_TOKEN
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
||||
- name: Validate settings.xml is overwritten
|
||||
run: |
|
||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||
Get-Content $xmlPath | ForEach-Object { Write-Host $_ }
|
||||
|
||||
$xml = Get-Content $xmlPath -Raw
|
||||
if ($raw -notlike 'maven') {
|
||||
throw "settings.xml file is not overwritten"
|
||||
}
|
||||
|
||||
test-publishing-skip-overwrite:
|
||||
name: Validate settings.xml is not overwritten if flag is false
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Create fake settings.xml
|
||||
run: |
|
||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||
Set-Content -Path $xmlPath -Value "Fake_XML"
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
server-id: maven
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_CENTRAL_TOKEN
|
||||
overwrite-settings: false
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE
|
||||
- name: Validate that settings.xml is not overwritten
|
||||
run: |
|
||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||
$content = Get-Content -Path $xmlPath -Raw
|
||||
if ($content -ne "Fake_XML") {
|
||||
throw "settings.xml file was overwritten but it should not be"
|
||||
}
|
||||
|
||||
test-publishing-custom-location:
|
||||
name: Validate settings.xml in custom location
|
||||
|
@ -79,5 +144,4 @@ jobs:
|
|||
$path = Join-Path $env:RUNNER_TEMP "settings.xml"
|
||||
if (-not (Test-Path $path)) {
|
||||
throw "settings.xml file is not found in expected location"
|
||||
}
|
||||
shell: pwsh
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue