Skip to content

Commit

Permalink
Merge pull request #8 from raimon49/support-remove-alpha-binary-names
Browse files Browse the repository at this point in the history
Support remove 'alpha' in binary names
  • Loading branch information
raimon49 authored Sep 26, 2023
2 parents 42bb8e9 + 0076b4e commit c83befe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/asdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
os:
- macos-latest
- ubuntu-latest
goss-version:
- 0.3.16
- 0.4.0

runs-on: ${{ matrix.os }}

Expand All @@ -20,7 +23,7 @@ jobs:
uses: asdf-vm/actions/plugin-test@v2
with:
command: goss --version
version: 0.3.16
version: ${{ matrix.goss-version }}
lint:
runs-on: ubuntu-latest

Expand Down
26 changes: 19 additions & 7 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ install_tool() {
chmod +x "${binary_path}"
}

numeric_version() {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}

get_platform() {
uname | tr '[:upper:]' '[:lower:]'
}
Expand All @@ -55,12 +59,20 @@ get_filename() {
local binary_name="$1"
local platform="$2"
local arch_name="$3"

case $platform in
# XXX: The keyword "alpha" is tentative
# See also) https://github.com/raimon49/asdf-goss/pull/1
darwin | windows) binary_name="${binary_name}-alpha";;
esac
local version="$4"

local install_numeric_version
install_numeric_version=$(numeric_version "${version}")

if [ "${install_numeric_version}" -lt "$(numeric_version 0.4.0)" ]; then
# XXX: The keyword "alpha" is removed in v0.4.0 or later
# See also) https://github.com/goss-org/goss/releases/tag/v0.4.0
case $platform in
# XXX: The keyword "alpha" is tentative
# See also) https://github.com/raimon49/asdf-goss/pull/1
darwin | windows) binary_name="${binary_name}-alpha";;
esac
fi

echo "${binary_name}-${platform}-${arch_name}"
}
Expand All @@ -71,7 +83,7 @@ get_download_url() {
local binary_name="$3"
local arch_name="$4"
local filename
filename="$(get_filename "${binary_name}" "${platform}" "${arch_name}")"
filename="$(get_filename "${binary_name}" "${platform}" "${arch_name}" "${version}")"

local github_repo="aelsabbahy/goss"

Expand Down

0 comments on commit c83befe

Please sign in to comment.