From 805d5e69510650117dada17e4e3b4117d1ff49d1 Mon Sep 17 00:00:00 2001 From: Lucian Varlan Date: Mon, 23 Jun 2025 10:47:36 +0200 Subject: [PATCH 1/3] feat: add asset input Needed for certain repositories --- README.md | 4 ++++ action.yaml | 7 ++++++- setup.sh | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5aa5b3..9e65714 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ The `isometry/setup-generic-tool` action is designed to make the use of generic **Optional** Override tool name, if it doesn't match the repo name +### `asset` input + +**Optional** Override asset name, if it doesn't match the tool name + ### `version` input **Optional** Version of tool to install (default: `latest`; example: `v1.2.3`) diff --git a/action.yaml b/action.yaml index 883dc91..d90b864 100644 --- a/action.yaml +++ b/action.yaml @@ -10,6 +10,10 @@ inputs: description: Override tool name, if it doesn't match the repo name required: false default: "" + asset: + description: Override asset name, if it doesn't match the tool name + required: false + default: "" version: description: Version of tool to install required: false @@ -31,5 +35,6 @@ runs: NAME: ${{ inputs.name }} VERSION: ${{ inputs.version }} TOOL: ${{ inputs.tool }} + ASSET: ${{ inputs.asset }} run: | - "${GITHUB_ACTION_PATH}/setup.sh" "${NAME}" "${VERSION}" "${TOOL}" + "${GITHUB_ACTION_PATH}/setup.sh" "${NAME}" "${VERSION}" "${TOOL}" "${ASSET}" diff --git a/setup.sh b/setup.sh index d5f5fc1..333556e 100755 --- a/setup.sh +++ b/setup.sh @@ -31,6 +31,8 @@ IFS='/' read -r OWNER REPO <<< "${REPO_NAME}" # Set tool name if not provided as third argument TOOL_NAME="${3:-${REPO}}" +ASSET_NAME_INPUT="${4:-${TOOL_NAME}}" + # Validate tool name [[ ! "${TOOL_NAME}" =~ ^[-A-Za-z0-9]+$ ]] && error "Invalid tool name" @@ -87,7 +89,7 @@ if [[ -d "${TOOL_CACHE_DIR}" ]]; then info "Found ${TOOL_NAME} ${VERSION} in ${TOOL_CACHE_DIR}" else info "Searching for ${TOOL_NAME} ${VERSION} for ${PLATFORM}/${ARCH}" - ASSET_PATTERN="^${TOOL_NAME}.+${PLATFORM}.+${ARCH_PATTERN}([.](tar[.]gz|zip))?\$" + ASSET_PATTERN="^${ASSET_NAME_INPUT}.+${PLATFORM}.+${ARCH_PATTERN}([.](tar[.]gz|zip))?\$" mapfile -t ASSETS < <(jq -r --arg pattern "${ASSET_PATTERN}" '.assets[] | select(.name | test($pattern; "i")) | .name' <<< "${RELEASE_DATA}") : "${ASSETS:?No matching release asset found}" From 13f36b2a1f1b29b79efc11fd00ca7b37e339690c Mon Sep 17 00:00:00 2001 From: Lucian Varlan Date: Mon, 23 Jun 2025 10:48:22 +0200 Subject: [PATCH 2/3] feat: platform pattern for macOS --- setup.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 333556e..32e423c 100755 --- a/setup.sh +++ b/setup.sh @@ -40,6 +40,12 @@ ASSET_NAME_INPUT="${4:-${TOOL_NAME}}" PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) +if [[ ${PLATFORM} == "darwin" ]]; then + PLATFORM_PATTERN="(darwin|macos)" +else + PLATFORM_PATTERN="(${PLATFORM})" +fi + # Convert architecture to common formats case "${ARCH}" in "aarch64"|"arm64") @@ -89,7 +95,7 @@ if [[ -d "${TOOL_CACHE_DIR}" ]]; then info "Found ${TOOL_NAME} ${VERSION} in ${TOOL_CACHE_DIR}" else info "Searching for ${TOOL_NAME} ${VERSION} for ${PLATFORM}/${ARCH}" - ASSET_PATTERN="^${ASSET_NAME_INPUT}.+${PLATFORM}.+${ARCH_PATTERN}([.](tar[.]gz|zip))?\$" + ASSET_PATTERN="^${ASSET_NAME_INPUT}.+${PLATFORM_PATTERN}.+${ARCH_PATTERN}([.](tar[.]gz|zip))?\$" mapfile -t ASSETS < <(jq -r --arg pattern "${ASSET_PATTERN}" '.assets[] | select(.name | test($pattern; "i")) | .name' <<< "${RELEASE_DATA}") : "${ASSETS:?No matching release asset found}" From c466306e24fd02424b929d04b59fd37e98557c33 Mon Sep 17 00:00:00 2001 From: Lucian Varlan Date: Mon, 23 Jun 2025 10:56:28 +0200 Subject: [PATCH 3/3] test: add check on pull request --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f6aa5e5..6ed5a68 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,6 +2,7 @@ name: Test action on: push: + pull_request: jobs: test: