Skip to content

Commit 9280b7b

Browse files
authored
feat: support other types of release metadata (#18)
* feat: add asset input Needed for certain repositories * feat: platform pattern for macOS * test: add check on pull request
1 parent 1a64151 commit 9280b7b

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Test action
22

33
on:
44
push:
5+
pull_request:
56

67
jobs:
78
test:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ The `isometry/setup-generic-tool` action is designed to make the use of generic
1717

1818
**Optional** Override tool name, if it doesn't match the repo name
1919

20+
### `asset` input
21+
22+
**Optional** Override asset name, if it doesn't match the tool name
23+
2024
### `version` input
2125

2226
**Optional** Version of tool to install (default: `latest`; example: `v1.2.3`)

action.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
description: Override tool name, if it doesn't match the repo name
1111
required: false
1212
default: ""
13+
asset:
14+
description: Override asset name, if it doesn't match the tool name
15+
required: false
16+
default: ""
1317
version:
1418
description: Version of tool to install
1519
required: false
@@ -31,5 +35,6 @@ runs:
3135
NAME: ${{ inputs.name }}
3236
VERSION: ${{ inputs.version }}
3337
TOOL: ${{ inputs.tool }}
38+
ASSET: ${{ inputs.asset }}
3439
run: |
35-
"${GITHUB_ACTION_PATH}/setup.sh" "${NAME}" "${VERSION}" "${TOOL}"
40+
"${GITHUB_ACTION_PATH}/setup.sh" "${NAME}" "${VERSION}" "${TOOL}" "${ASSET}"

setup.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,21 @@ IFS='/' read -r OWNER REPO <<< "${REPO_NAME}"
3131
# Set tool name if not provided as third argument
3232
TOOL_NAME="${3:-${REPO}}"
3333

34+
ASSET_NAME_INPUT="${4:-${TOOL_NAME}}"
35+
3436
# Validate tool name
3537
[[ ! "${TOOL_NAME}" =~ ^[-A-Za-z0-9]+$ ]] && error "Invalid tool name"
3638

3739
# Determine platform and architecture
3840
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')
3941
ARCH=$(uname -m)
4042

43+
if [[ ${PLATFORM} == "darwin" ]]; then
44+
PLATFORM_PATTERN="(darwin|macos)"
45+
else
46+
PLATFORM_PATTERN="(${PLATFORM})"
47+
fi
48+
4149
# Convert architecture to common formats
4250
case "${ARCH}" in
4351
"aarch64"|"arm64")
@@ -87,7 +95,7 @@ if [[ -d "${TOOL_CACHE_DIR}" ]]; then
8795
info "Found ${TOOL_NAME} ${VERSION} in ${TOOL_CACHE_DIR}"
8896
else
8997
info "Searching for ${TOOL_NAME} ${VERSION} for ${PLATFORM}/${ARCH}"
90-
ASSET_PATTERN="^${TOOL_NAME}.+${PLATFORM}.+${ARCH_PATTERN}([.](tar[.]gz|zip))?\$"
98+
ASSET_PATTERN="^${ASSET_NAME_INPUT}.+${PLATFORM_PATTERN}.+${ARCH_PATTERN}([.](tar[.]gz|zip))?\$"
9199
mapfile -t ASSETS < <(jq -r --arg pattern "${ASSET_PATTERN}" '.assets[] | select(.name | test($pattern; "i")) | .name' <<< "${RELEASE_DATA}")
92100

93101
: "${ASSETS:?No matching release asset found}"

0 commit comments

Comments
 (0)