Skip to content

Commit

Permalink
Merge pull request #6 from dcarbone/dcarbone/version-check
Browse files Browse the repository at this point in the history
Adding test for empty version value
  • Loading branch information
dcarbone authored Nov 19, 2024
2 parents a2e3287 + 65e4d13 commit 4075b4d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
1 change: 0 additions & 1 deletion .github/workflows/example-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
type: string
required: false
description: "Version of YQ to install"
default: "v4.35.1"
download-compressed:
type: boolean
required: false
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/example-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
type: string
required: false
description: "Version of YQ to install"
default: "v4.35.1"
download-compressed:
type: boolean
required: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/example-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
type: string
required: false
description: "Version of YQ to install"
default: "v4.35.1"
download-compressed:
type: boolean
required: false
Expand All @@ -31,6 +30,7 @@ jobs:
force: '${{ inputs.force }}'

- name: 'Check yq'
# language=powershell
run: |
Get-Command "yq.exe"
yq.exe --version
7 changes: 6 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ jobs:
force:
- 'true'
- 'false'
name: "Test Action - (img: ${{ matrix.image }}; dlcmp: ${{ matrix.download-compressed }}; force: ${{ matrix.force }})"
version:
- ''
- 'v4.44.3'

name: "Test Action - (img: ${{ matrix.image }}; dlcmp: ${{ matrix.download-compressed }}; force: ${{ matrix.force }}; v: ${{ matrix.version }})"
runs-on: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
Expand All @@ -49,6 +53,7 @@ jobs:
with:
force: '${{ matrix.force }}'
download-compressed: '${{ matrix.download-compressed }}'
version: '${{ matrix.version }}'

- name: Check yq - Unix-ish
if: runner.os == 'Linux' || runner.os == 'macOS'
Expand Down
4 changes: 3 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branding:

inputs:
version:
required: false
required: true
description: "Version of YQ to install"
default: "v4.44.3"
download-compressed:
Expand All @@ -35,6 +35,7 @@ runs:
id: yq-check-unix
if: (runner.os == 'Linux' || runner.os == 'macOS')
shell: bash +e {0}
# language=bash
run: |
_yq_bin="$(which yq)"
if [ -f "${_yq_bin}" ]; then
Expand All @@ -55,6 +56,7 @@ runs:
id: yq-check-windows
if: runner.os == 'Windows'
shell: powershell
# language=powershell
run: |
if (Get-Command "yq.exe" -ErrorAction SilentlyContinue)
{
Expand Down
11 changes: 9 additions & 2 deletions scripts/unixish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ else
_dl_path="$RUNNER_TEMP/${_root_name}/${_dl_name}"
fi

_dl_url="${_base_url}/$YQ_VERSION/${_dl_name}"
# default to _something_...
_version="${YQ_VERSION}"

if [ -z "${YQ_VERSION}" ]; then
_version='v4.44.3'
fi

_dl_url="${_base_url}/${_version}/${_dl_name}"

echo '::endgroup::'

echo '::group::Downloading yq'
echo "::group::Downloading yq ${_version}"

echo "Src: ${_dl_url}"
echo "Dst: ${_dl_path}"
Expand Down
12 changes: 10 additions & 2 deletions scripts/windowsish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ else
New-Item "$Env:RUNNER_TEMP\${_root_name}\" -ItemType Directory -Force
}

$_dl_url = "${_base_url}/$Env:YQ_VERSION/${_dl_name}"
$_version = "$Env:YQ_VERSION"

# default to _something_...
if ($_version -eq "")
{
$_version = "v4.44.3"
}

$_dl_url = "${_base_url}/${_version}/${_dl_name}"

Write-Host "::endgroup::"

# download artifact

Write-Host "::group::Downloading yq"
Write-Host "::group::Downloading yq ${_version}"

Write-Host "Src: ${_dl_url}"
Write-Host "Dst: ${_dl_path}"
Expand Down

0 comments on commit 4075b4d

Please sign in to comment.