Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macOS downloads of 2.20 and later #8

Merged
merged 8 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: asdf_plugin_test
uses: asdf-vm/actions/plugin-test@v1.1.0
uses: asdf-vm/actions/plugin-test@v2
with:
command: op --version
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: 1password-cli
- name: Move 1password-cli plugin to plugins dir
Expand All @@ -33,13 +33,23 @@ jobs:
run: |
echo "Trying to list all versions of 1password-cli"
asdf list all 1password-cli
echo "Will try to install 1password-cli 1.11.0 (Last version with amd64 for MacOS)"
echo "Will try to install 1password-cli 1.11.0 (Last version with amd64 for macOS)"
asdf install 1password-cli 1.11.0
echo "Will try to install 1password-cli 1.11.1 (First version with universal for MacOS)"
echo "Will try to install 1password-cli 1.11.1 (First version with universal for macOS)"
asdf install 1password-cli 1.11.1
echo "Will try to install 1password-cli 2.0.0 (First 2.0 version)"
asdf install 1password-cli 2.0.0
echo "Will try to install 1password-cli 2.2.0 (First version with zip and pkg versions for macOS)"
asdf install 1password-cli 2.2.0
echo "Setting 1password-cli version 1.11.0 as the default value in ~/.tool-versions"
echo '1password-cli 1.11.0' > ~/.tool-versions
op --version 2>&1 | grep '1.11.0'
echo "Setting 1password-cli version 1.11.1 as the default value in ~/.tool-versions"
echo '1password-cli 1.11.1' > ~/.tool-versions
op --version 2>&1 | grep '1.11.1'
echo "Setting 1password-cli version 2.0.0 as the default value in ~/.tool-versions"
echo '1password-cli 2.0.0' > ~/.tool-versions
op --version 2>&1 | grep '2.0.0'
echo "Setting 1password-cli version 2.2.0 as the default value in ~/.tool-versions"
echo '1password-cli 2.2.0' > ~/.tool-versions
op --version 2>&1 | grep '2.2.0'
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run ShellCheck
run: shellcheck -x bin/*

format:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install shfmt
run: brew install shfmt
- name: Run shfmt
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
shellcheck 0.7.2
shellcheck 0.9.0
shfmt 3.2.4
42 changes: 39 additions & 3 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,46 @@ download_release() {
esac

if [[ "$version" =~ ^1\..*$ ]]; then
url=$(curl -s https://app-updates.agilebits.com/product_history/CLI | grep "${version}" | grep "${filter_platform}" | grep "${arch}" | sed -e 's/<a /\n<a /g' | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d' | sed '/^[[:space:]]*$/d' | grep -o "https.*$")
url=$(curl -s https://app-updates.agilebits.com/product_history/CLI)
elif [[ "$version" =~ ^2\..*$ ]]; then
url=$(curl -s https://app-updates.agilebits.com/product_history/CLI2 | grep "${version}\/" | grep "${filter_platform}" | grep "${arch}" | sed -e 's/<a /\n<a /g' | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d' | sed '/^[[:space:]]*$/d' | grep -o "https.*$")
url=$(curl -s https://app-updates.agilebits.com/product_history/CLI2)
fi

# Limit to version ${version}/
url=$(echo "${url}" | grep "${version}\/")

# Limit to ${filter_platform}
url=$(echo "${url}" | grep "${filter_platform}")

# Limit to architecture ${arch}
url=$(echo "${url}" | grep "${arch}")

# Limit to trailing extension \.${ext} (not /${ext}/ in path)
url=$(echo "${url}" | grep "\.${ext}")

# Ensure each link is on its own line
# shellcheck disable=SC2001 # (bash 3.2.x parameter expansion can't handle newlines)
url=$(echo "${url}" | sed -e "s/<a /\n<a /g")

# Strip off HTML
url=$(echo "${url}" | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d')

# Lose extraneous spaces
url=$(echo "${url}" | sed '/^[[:space:]]*$/d')

# Require HTTPS
url=$(echo "${url}" | grep -o "https.*$")

# Expect only one line
if [[ $(echo "$url" | wc -l | tr -d ' ') -gt 1 ]]; then
echo "Unable to winnow down to a single URL:"
echo "$url"
exit 1
elif [[ ${url} == "" ]]; then
echo "Failed to extract a URL for version ${version}"
exit 1
fi

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename.${ext}" -C - "$url" || fail "Could not download $url"
}
Expand Down Expand Up @@ -77,7 +113,7 @@ install_version() {
*)
cp -R "$ASDF_DOWNLOAD_PATH/." "$install_path/bin"
is_exists=$(program_exists)
echo $is_exists
echo "$is_exists"
if [ "$is_exists" != 0 ]; then
gpg --keyserver hkps://keyserver.ubuntu.com:443 --receive-keys "$TOOL_GPG_KEY"
gpg --verify "$install_path/bin/op.sig" "$install_path/bin/op" || fail "asdf-$TOOL_NAME download file verify fail with GPG."
Expand Down