Skip to content

Commit 985afbe

Browse files
authoredAug 20, 2024··
Merge pull request #1 from jesmarla/main
feat: Implement asdf oasdiff plugin
2 parents 02a6921 + 4a609a1 commit 985afbe

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed
 

‎.github/workflows/build.yml

+5
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ jobs:
2020
uses: asdf-vm/actions/plugin-test@v2
2121
with:
2222
command: oasdiff --help
23+
- name: asdf_plugin_test_1_10_23
24+
uses: asdf-vm/actions/plugin-test@v2
25+
with:
26+
command: oasdiff --version
27+
version: 1.10.23

‎bin/download

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -euo pipefail
55
current_script_path=${BASH_SOURCE[0]}
66
plugin_dir=$(dirname "$(dirname "$current_script_path")")
77

8-
# shellcheck source=../lib/utils.bash
8+
# shellcheck source=lib/utils.bash
99
source "${plugin_dir}/lib/utils.bash"
1010

1111
mkdir -p "$ASDF_DOWNLOAD_PATH"
@@ -17,7 +17,7 @@ release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz"
1717
download_release "$ASDF_INSTALL_VERSION" "$release_file"
1818

1919
# Extract contents of tar.gz file into the download directory
20-
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file"
20+
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" || fail "Could not extract $release_file"
2121

2222
# Remove the tar.gz file since we don't need to keep it
2323
rm "$release_file"

‎bin/install

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -euo pipefail
55
current_script_path=${BASH_SOURCE[0]}
66
plugin_dir=$(dirname "$(dirname "$current_script_path")")
77

8-
# shellcheck source=../lib/utils.bash
8+
# shellcheck source=lib/utils.bash
99
source "${plugin_dir}/lib/utils.bash"
1010

1111
install_version "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"

‎bin/latest-stable

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -euo pipefail
55
current_script_path=${BASH_SOURCE[0]}
66
plugin_dir=$(dirname "$(dirname "$current_script_path")")
77

8-
# shellcheck source=../lib/utils.bash
8+
# shellcheck source=lib/utils.bash
99
. "${plugin_dir}/lib/utils.bash"
1010

1111
curl_opts=(-sI)

‎bin/list-all

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -euo pipefail
55
current_script_path=${BASH_SOURCE[0]}
66
plugin_dir=$(dirname "$(dirname "$current_script_path")")
77

8-
# shellcheck source=../lib/utils.bash
8+
# shellcheck source=lib/utils.bash
99
source "${plugin_dir}/lib/utils.bash"
1010

1111
list_all_versions | sort_versions | xargs echo

‎lib/utils.bash

+23-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -euo pipefail
44

5-
]GH_REPO="https://github.com/tufin/oasdiff"
5+
GH_REPO="https://github.com/Tufin/oasdiff"
66
TOOL_NAME="oasdiff"
77
TOOL_TEST="oasdiff --help"
88

@@ -36,17 +36,37 @@ list_all_versions() {
3636
}
3737

3838
download_release() {
39-
local version filename url
39+
local version filename url platform
4040
version="$1"
4141
filename="$2"
42+
platform=$(get_platform "$version")
4243

4344
# TODO: Adapt the release URL convention for oasdiff
44-
url="$GH_REPO/archive/v${version}.tar.gz"
45+
url="$GH_REPO/releases/download/v${version}/${TOOL_NAME}_${version}_$platform.tar.gz"
4546

4647
echo "* Downloading $TOOL_NAME release $version..."
4748
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
4849
}
4950

51+
get_platform() {
52+
local version=$1
53+
54+
case $(uname) in
55+
#Linux OS
56+
Linux)
57+
if [ "$(uname -m)" = "aarch64" ]; then
58+
echo "linux_arm64"
59+
else
60+
echo "linux_amd64"
61+
fi
62+
;;
63+
#Mac OS
64+
Darwin)
65+
echo "darwin_all"
66+
;;
67+
esac
68+
}
69+
5070
install_version() {
5171
local install_type="$1"
5272
local version="$2"

0 commit comments

Comments
 (0)
Please sign in to comment.