29 Commits

Author SHA1 Message Date
Daniel Carbone
ca8101273e trying out posix sh (#14)
* trying out posix sh
2024-11-14 19:38:37 -06:00
Daniel Carbone
de7c0d1fb1 updating matrix versions (#12)
* updating matrix versions
2024-11-14 19:19:41 -06:00
Daniel Carbone
8867ddb478 remove windows gubbins from container tests 2023-11-07 14:50:52 -06:00
Michael Busby
945d84920f Support running action inside containers (#10)
* Add container tests

* Update github actions path to fix container compat
2023-11-07 14:47:46 -06:00
akhil
1090b8bd11 use curl instead of wget to fix failure on macOS runners (#8) 2023-09-29 12:04:15 -05:00
Daniel Carbone
ff922c75b7 Update example-windows.yaml 2023-09-27 19:11:45 -05:00
Daniel Carbone
7f4d6f4833 Update example-macos.yaml 2023-09-27 19:11:32 -05:00
Daniel Carbone
bfb9fa8e7d Update example-linux.yaml 2023-09-27 19:11:18 -05:00
Daniel Carbone
c1548c666d using macos as dl link os prefix in lieu of osx (#7)
* using macos as dl link os prefix in lieu of osx

* probably won't work
2023-09-27 18:12:19 -05:00
Daniel Carbone
f07422da1e fixing version 2023-09-14 17:16:46 -05:00
Daniel Carbone
183bc8df0e trying without stupid 2023-09-14 17:14:55 -05:00
Daniel Carbone
f6b58bacfe its late. 2023-09-14 17:12:59 -05:00
Daniel Carbone
8a48eeaec5 dumb 2023-09-14 17:12:01 -05:00
Daniel Carbone
4fd1c2fa17 love windows. 2023-09-14 17:11:06 -05:00
Daniel Carbone
d6095dd111 sigh 2023-09-14 17:07:18 -05:00
Daniel Carbone
f4380feee9 jeebus. 2023-09-14 17:06:27 -05:00
Daniel Carbone
013545576e ok finally that makes sense 2023-09-14 17:04:40 -05:00
Daniel Carbone
58f2b9e47b windows. 2023-09-14 17:03:31 -05:00
Daniel Carbone
ff3e63d085 super bizarre... 2023-09-14 16:57:19 -05:00
Daniel Carbone
d01a60fdb7 windows is mysterious. 2023-09-14 16:46:36 -05:00
Daniel Carbone
b628dd299f strange 2023-09-14 16:38:09 -05:00
Daniel Carbone
c8104cea13 wat 2023-09-14 16:30:31 -05:00
Daniel Carbone
aa4e9171a2 that's what you get for going quickly. 2023-09-14 16:26:35 -05:00
Daniel Carbone
be73239910 dangit. 2023-09-14 16:25:22 -05:00
Daniel Carbone
360494bdc8 quick & dirty 1.7 support (#4) 2023-09-14 15:39:55 -05:00
Daniel Carbone
6edf1e1259 update version in examples 2022-11-02 17:53:30 -05:00
Daniel Carbone
22c3fc1e13 Adding version check to tests 2022-11-02 17:50:09 -05:00
Daniel Carbone
91d8da7268 Merge pull request #1 from goruha/patch-1
Add `exec` permissions for installed jq
2022-11-02 16:57:23 -05:00
Igor Rodionov
2729c7570f Add exec permissions for installed jq 2022-11-03 01:55:53 +06:00
10 changed files with 438 additions and 36 deletions

View File

@@ -6,12 +6,12 @@ on:
version:
type: string
required: false
description: "Version of jq to install"
default: "1.6"
description: 'Version of jq to install'
default: '1.7'
force:
type: boolean
required: false
description: "Do not check for existing jq installation before continuing."
description: 'Do not check for existing jq installation before continuing.'
default: false
jobs:
@@ -19,12 +19,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v1.0.0
uses: dcarbone/install-jq-action@v2
with:
version: '${{ inputs.version }}'
force: '${{ inputs.force }}'
- name: 'Check jq'
# language=sh
run: |
which jq
jq --version

View File

@@ -6,12 +6,12 @@ on:
version:
type: string
required: false
description: "Version of jq to install"
default: "1.6"
description: 'Version of jq to install'
default: '1.7'
force:
type: boolean
required: false
description: "Do not check for existing jq installation before continuing."
description: 'Do not check for existing jq installation before continuing.'
default: false
jobs:
@@ -19,12 +19,13 @@ jobs:
runs-on: macos-latest
steps:
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v1.0.0
uses: dcarbone/install-jq-action@v2
with:
version: '${{ inputs.version }}'
force: '${{ inputs.force }}'
- name: 'Check jq'
# language=sh
run: |
which jq
jq --version

View File

@@ -6,12 +6,12 @@ on:
version:
type: string
required: false
description: "Version of jq to install"
default: "1.6"
description: 'Version of jq to install'
default: '1.7'
force:
type: boolean
required: false
description: "Do not check for existing jq installation before continuing."
description: 'Do not check for existing jq installation before continuing.'
default: false
jobs:
@@ -19,12 +19,13 @@ jobs:
runs-on: windows-latest
steps:
- name: 'Setup jq'
uses: dcarbone/install-jq-action@v1.0.0
uses: dcarbone/install-jq-action@v2
with:
version: '${{ inputs.version }}'
force: '${{ inputs.force }}'
- name: 'Check jq'
# language=powershell
run: |
Get-Command "jq.exe"
jq.exe --version

View File

@@ -10,7 +10,9 @@ on:
- 'action.yaml'
- '.github/workflows/tests.yaml'
- 'scripts/unixish.sh'
- 'scripts/unixish-17.sh'
- 'scripts/windowsish.ps1'
- 'scripts/windowsish-17.ps1'
pull_request:
branches:
@@ -24,35 +26,147 @@ jobs:
- "ubuntu-latest"
- "ubuntu-20.04"
- "ubuntu-22.04"
- "ubuntu-24.04"
- "macos-latest"
- "macos-11"
- "macos-12"
- "macos-13"
- "macos-14"
- "macos-15"
- "windows-latest"
- "windows-2022"
- "windows-2019"
- "windows-2022"
force:
- 'true'
- 'false'
name: "Test Action - (img: ${{ matrix.image }}; force: ${{ matrix.force }})"
version:
- '1.7'
include:
- image: "ubuntu-latest"
version: '1.6'
force: true
- image: "ubuntu-latest"
version: '1.6'
force: false
- image: "ubuntu-latest"
version: '1.5'
force: true
- image: "ubuntu-latest"
version: '1.5'
force: false
- image: "ubuntu-20.04"
version: '1.6'
force: true
- image: "ubuntu-20.04"
version: '1.6'
force: false
- image: "ubuntu-20.04"
version: '1.5'
force: true
- image: "ubuntu-20.04"
version: '1.5'
force: false
- image: "ubuntu-22.04"
version: '1.6'
force: true
- image: "ubuntu-22.04"
version: '1.6'
force: false
- image: "ubuntu-22.04"
version: '1.5'
force: true
- image: "ubuntu-22.04"
version: '1.5'
force: false
- image: "ubuntu-24.04"
version: '1.6'
force: true
- image: "ubuntu-24.04"
version: '1.6'
force: false
- image: "ubuntu-24.04"
version: '1.5'
force: true
- image: "ubuntu-24.04"
version: '1.5'
force: false
- image: "windows-latest"
version: '1.6'
force: true
- image: "windows-latest"
version: '1.6'
force: false
- image: "windows-latest"
version: '1.5'
force: true
- image: "windows-latest"
version: '1.5'
force: false
- image: "windows-2019"
version: '1.6'
force: true
- image: "windows-2019"
version: '1.6'
force: false
- image: "windows-2019"
version: '1.5'
force: true
- image: "windows-2019"
version: '1.5'
force: false
- image: "windows-2022"
version: '1.6'
force: true
- image: "windows-2022"
version: '1.6'
force: false
- image: "windows-2022"
version: '1.5'
force: true
- image: "windows-2022"
version: '1.5'
force: false
name: "Test Action - (img: ${{ matrix.image }}; version: ${{ matrix.version }}; force: ${{ matrix.force }})"
runs-on: ${{ matrix.image }}
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4
- name: Setup jq
id: install-jq
uses: dcarbone/install-jq-action@main
uses: ./
with:
version: '${{ matrix.version }}'
force: '${{ matrix.force }}'
- name: Check jq - Unix-ish
if: runner.os == 'Linux' || runner.os == 'macOS'
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.force == 'true'
# language=sh
run: |
which jq
jq --version
_err=
_which="$(which jq)"
_vers="$(jq --version)"
if [[ "${_which}" != "$RUNNER_TOOL_CACHE/jq/jq" ]]; then
echo "jq found at unexpected path."
echo " Expected: \"$RUNNER_TOOL_CACHE/jq/jq\""
echo " Actual: \"${_which}\""
_err=1
fi
if [[ "${_vers}" != 'jq-${{ matrix.version }}' ]]; then
echo "jq --version returned unexpected value"
echo ' Expected: "jq-${{ matrix.version }}"'
echo " Actual: \"${_vers}\""
_err=1
fi
if [ -n "${_err}" ]; then exit 1; fi;
- name: Check Outputs - Unix-ish
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash -e {0}
# language=sh
run: |
_installed='${{ steps.install-jq.outputs.installed }}'
_err=
@@ -87,14 +201,24 @@ jobs:
- name: Check jq - Windows-ish
if: runner.os == 'Windows'
if: runner.os == 'Windows' && matrix.force == 'true'
# language=powershell
run: |
Get-Command "jq.exe"
jq.exe --version
$_cmd={jq.exe --version }
$_vers=jq.exe --version 2>&1
if ( "${_vers}" -ne "jq-${{ matrix.version }}" -and "${_vers}" -ne "jq-${{ matrix.version }}-dirty" )
{
Write-Host "jq.exe --version returned unexpected value"
Write-Host " Expected: jq-${{ matrix.version }}"
Write-Host " Actual: ${_vers}"
exit 1
}
- name: Check Outputs - Windows-ish
if: runner.os == 'Windows'
shell: powershell
# language=powershell
run: |
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
@@ -139,3 +263,84 @@ jobs:
{
exit 1
}
test-container:
strategy:
matrix:
image:
- "ubuntu-24.04"
- "ubuntu-22.04"
- "ubuntu-20.04"
force:
- 'true'
- 'false'
version:
- '1.5'
- '1.6'
- '1.7'
name: "Test Action (Container) - (img: ${{ matrix.image }}; version: ${{ matrix.version }}; force: ${{ matrix.force }})"
runs-on: ${{ matrix.image }}
container:
image: node:20
steps:
- uses: actions/checkout@v4
- name: Setup jq
id: install-jq
uses: ./
with:
version: '${{ matrix.version }}'
force: '${{ matrix.force }}'
- name: Check jq
# language=sh
run: |
_err=
_which="$(which jq)"
_vers="$(jq --version)"
if [[ "${_which}" != "$RUNNER_TOOL_CACHE/jq/jq" ]]; then
echo "jq found at unexpected path."
echo " Expected: \"$RUNNER_TOOL_CACHE/jq/jq\""
echo " Actual: \"${_which}\""
_err=1
fi
if [[ "${_vers}" != 'jq-${{ matrix.version }}' ]]; then
echo "jq --version returned unexpected value"
echo ' Expected: "jq-${{ matrix.version }}"'
echo " Actual: \"${_vers}\""
_err=1
fi
if [ -n "${_err}" ]; then exit 1; fi;
- name: Check Outputs
# language=sh
run: |
_installed='${{ steps.install-jq.outputs.installed }}'
_err=
if [[ '${{ matrix.force }}' == 'true' ]]; then
# enabling "force" must result in an install
if [[ '${{ steps.install-jq.outputs.installed }}' != 'true' ]]; then
echo 'Unexpected value for "installed":'
echo 'Expected: "true"'
echo 'Actual: "${{ steps.install-jq.outputs.installed }}"'
_err=1
fi
else
if [[ '${{ steps.install-jq.outputs.found }}' == 'true' ]]; then
# if found, must not be installed without force
if [[ '${{ steps.install-jq.outputs.installed }}' != 'false' ]]; then
echo 'Unexpected value for "installed":'
echo 'Expected: "false"'
echo 'Actual: "${{ steps.install-jq.outputs.installed }}"'
_err=1
fi
else
# if not found, must be installed
if [[ '${{ steps.install-jq.outputs.installed }}' != 'true' ]]; then
echo 'Unexpected value for "installed":'
echo 'Expected: "true"'
echo 'Actual: "${{ steps.install-jq.outputs.installed }}"'
_err=1
fi
fi
fi
if [ -n "${_err}" ]; then exit 1; fi;

View File

@@ -3,7 +3,11 @@ Multiplatform [jq](https://github.com/stedolan/jq) installer action
[![Tests - Setup jq Action](https://github.com/dcarbone/install-jq-action/actions/workflows/tests.yaml/badge.svg)](https://github.com/dcarbone/install-jq-action/actions/workflows/tests.yaml)
This action cannot currently handle MacOS arm64 runners.
This action is tested against the following versions of JQ:
- [1.7](https://github.com/jqlang/jq/releases/tag/jq-1.7)
- [1.6](https://github.com/jqlang/jq/releases/tag/jq-1.6)
- [1.5](https://github.com/jqlang/jq/releases/tag/jq-1.5)
# Index
@@ -16,6 +20,7 @@ This action cannot currently handle MacOS arm64 runners.
* [linux](./.github/workflows/example-linux.yaml)
* [macos](./.github/workflows/example-macos.yaml)
* [windows](./.github/workflows/example-windows.yaml)
## Action Inputs
@@ -24,7 +29,7 @@ This action cannot currently handle MacOS arm64 runners.
version:
required: false
description: "Version of jq to install"
default: "1.6"
default: "1.7"
```
This must be a version with a [corresponding release](https://github.com/stedolan/jq/releases).

View File

@@ -10,7 +10,7 @@ inputs:
version:
required: false
description: "Version of jq to install"
default: "1.6"
default: "1.7"
force:
required: false
description: "If 'true', does not check for existing jq installation before continuing."
@@ -31,6 +31,7 @@ runs:
id: jq-check-unix
if: (runner.os == 'Linux' || runner.os == 'macOS')
shell: bash +e {0}
# language=sh
run: |
_jq_bin="$(which jq)"
if [ -f "${_jq_bin}" ]; then
@@ -39,17 +40,27 @@ runs:
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: 'Install jq - Unix-ish'
if: (runner.os == 'Linux' || runner.os == 'macOS') && (steps.jq-check-unix.outputs.found == 'false' || inputs.force == 'true')
- name: 'Install jq - Unix-ish non-1.7'
if: (runner.os == 'Linux' || runner.os == 'macOS') && (inputs.version == '1.5' || inputs.version == '1.6') && (steps.jq-check-unix.outputs.found == 'false' || inputs.force == 'true')
shell: bash
env:
JQ_VERSION: '${{ inputs.version }}'
run: $GITHUB_ACTION_PATH/scripts/unixish.sh
# language=sh
run: ${GITHUB_ACTION_PATH}/scripts/unixish.sh
- name: 'Install jq - Unix-ish 1.7'
if: (runner.os == 'Linux' || runner.os == 'macOS') && inputs.version == '1.7' && (steps.jq-check-unix.outputs.found == 'false' || inputs.force == 'true')
shell: bash
env:
JQ_VERSION: '${{ inputs.version }}'
# language=sh
run: ${GITHUB_ACTION_PATH}/scripts/unixish-17.sh
- name: 'Check for jq - Windows-ish'
id: jq-check-windows
if: runner.os == 'Windows'
shell: powershell
# language=powershell
run: |
if (Get-Command "jq.exe" -ErrorAction SilentlyContinue)
{
@@ -60,9 +71,16 @@ runs:
Add-Content $Env:GITHUB_OUTPUT "found=false"
}
- name: 'Install jq - Windows-ish'
if: runner.os == 'Windows' && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true')
- name: 'Install jq - Windows-ish non-1.7'
if: runner.os == 'Windows' && (inputs.version == '1.5' || inputs.version == '1.6') && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true')
shell: powershell
env:
JQ_VERSION: '${{ inputs.version }}'
run: '& $Env:GITHUB_ACTION_PATH\scripts\windowsish.ps1'
run: ${{ github.action_path }}\scripts\windowsish.ps1
- name: 'Install jq - Windows-ish 1.7'
if: runner.os == 'Windows' && inputs.version == '1.7' && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true')
shell: powershell
env:
JQ_VERSION: '${{ inputs.version }}'
run: ${{ github.action_path }}\scripts\windowsish-17.ps1

95
scripts/unixish-17.sh Executable file
View File

@@ -0,0 +1,95 @@
#!/bin/sh
set -e
echo '::group::Prep'
# validate input and prepare some vars
_base_url='https://github.com/jqlang/jq/releases/download'
_arch_env="$(echo "$RUNNER_ARCH" | tr '[:upper:]' '[:lower:]')"
_os=
_arch=
_bin_name=
_dl_name=
_dl_path=
_dl_url=
case $RUNNER_OS in
Linux)
_os='linux'
;;
macOS)
_os='macos'
;;
*)
echo "Cannot handle OS of type $RUNNER_OS"
echo "Expected one of: [ Linux macOS ]"
exit 1
;;
esac
case "${_arch_env}" in
'x86'|'386')
_arch='i386'
;;
'x64'|'amd64'|'x86_64')
_arch='amd64'
;;
'arm'|'armhf')
_arch='armhf'
;;
'armel')
_arch='armel'
;;
'arm64'|'aarch64')
_arch='arm64'
;;
*)
echo "Cannot handle arch of type $RUNNER_ARCH"
echo "Expected one of: [ x86 386 x64 amd64 x86_64 arm armhf armel arm64 aarch64 ]"
exit 1
;;
esac
# build bin name
_bin_name="jq-${_os}-${_arch}"
# build download vars
_dl_name="${_bin_name}"
_dl_path="$RUNNER_TEMP/${_dl_name}"
_dl_url="${_base_url}/jq-$JQ_VERSION/${_dl_name}"
echo '::endgroup::'
echo '::group::Downloading jq'
echo "Src: ${_dl_url}"
echo "Dst: ${_dl_path}"
curl -L "${_dl_url}" -o "${_dl_path}"
echo '::endgroup::'
echo '::group::Copying to tool cache'
echo "Creating tool cache directory $RUNNER_TOOL_CACHE/jq"
mkdir -p "$RUNNER_TOOL_CACHE/jq"
echo "Installing into tool cache:"
echo "Src: $RUNNER_TEMP/${_bin_name}"
echo "Dst: $RUNNER_TOOL_CACHE/jq/jq"
mv "$RUNNER_TEMP/${_bin_name}" "$RUNNER_TOOL_CACHE/jq/jq"
chmod +x "$RUNNER_TOOL_CACHE/jq/jq"
echo "Adding $RUNNER_TOOL_CACHE/jq to path..."
echo "$RUNNER_TOOL_CACHE/jq" >> $GITHUB_PATH
echo '::endgroup::'

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
set -e
@@ -54,7 +54,7 @@ esac
# determine binary name
if [[ "${_os}" == "linux" ]]; then
if [ "${_os}" = "linux" ]; then
case "${_arch}" in
'386')
_bin_name="jq-linux32"
@@ -93,7 +93,7 @@ echo '::group::Downloading jq'
echo "Src: ${_dl_url}"
echo "Dst: ${_dl_path}"
wget -O- "${_dl_url}" > "${_dl_path}"
curl -L "${_dl_url}" -o "${_dl_path}"
echo '::endgroup::'
@@ -107,6 +107,8 @@ echo "Src: $RUNNER_TEMP/${_bin_name}"
echo "Dst: $RUNNER_TOOL_CACHE/jq/jq"
mv "$RUNNER_TEMP/${_bin_name}" "$RUNNER_TOOL_CACHE/jq/jq"
chmod +x "$RUNNER_TOOL_CACHE/jq/jq"
echo "Adding $RUNNER_TOOL_CACHE/jq to path..."
echo "$RUNNER_TOOL_CACHE/jq" >> $GITHUB_PATH

74
scripts/windowsish-17.ps1 Executable file
View File

@@ -0,0 +1,74 @@
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
Write-Host "::group::Prep"
$_base_url = "https://github.com/jqlang/jq/releases/download"
$_arch_env = ($Env:RUNNER_ARCH).ToLower()
# validate input and prepare some vars
switch ($_arch_env)
{
"x86" {
$_arch = "i386"
}
"386" {
$_arch = "i386"
}
"x64" {
$_arch = "amd64"
}
"x86_64" {
$_arch = "amd64"
}
"amd64" {
$_arch = "amd64"
}
default {
Write-Host "Cannot handle arch of type $Env:RUNNER_ARCH"
Write-Host "Expected one of: [ x86 386 x64 x86_64 amd64 ]"
exit 1
}
}
# build bin name
$_bin_name = "jq-windows-${_arch}.exe"
# build download vars
$_dl_name = "${_bin_name}"
$_dl_path = "$Env:RUNNER_TEMP\${_dl_name}"
$_dl_url = "${_base_url}/jq-$Env:JQ_VERSION/${_dl_name}"
Write-Host "::endgroup::"
# download artifact
Write-Host "::group::Downloading jq"
Write-Host "Src: ${_dl_url}"
Write-Host "Dst: ${_dl_path}"
Invoke-WebRequest -Uri "${_dl_url}" -OutFile "${_dl_path}"
Write-Host "::endgroup::"
# install into tool cache
Write-Host "::group::Copying to tool cache"
Write-Host "Creating tool cache directory $Env:RUNNER_TOOL_CACHE\jq\"
New-Item "$Env:RUNNER_TOOL_CACHE\jq\" -ItemType Directory -Force
Write-Host "Installing into tool cache:"
Write-Host "Src: $Env:RUNNER_TEMP\${_bin_name}"
Write-Host "Dst: $Env:RUNNER_TOOL_CACHE\jq\jq.exe"
Move-Item -Force -LiteralPath "$Env:RUNNER_TEMP\${_bin_name}" -Destination "$Env:RUNNER_TOOL_CACHE\jq\jq.exe"
Write-Host "Adding $Env:RUNNER_TOOL_CACHE\jq\ to path..."
Add-Content "$Env:GITHUB_PATH" "$Env:RUNNER_TOOL_CACHE\jq\"
Write-Host "::endgroup::"

0
scripts/windowsish.ps1 Normal file → Executable file
View File