Created
December 8, 2021 09:58
-
-
Save FrankSansC/ead7103c51982f742d75ace39338f707 to your computer and use it in GitHub Desktop.
Get 1password CLI latest version URL - Source: https://1password.community/discussion/comment/560226/#Comment_560226
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -u | |
OP_RELEASE_NOTES_URL="https://app-updates.agilebits.com/product_history/CLI" | |
OP_PLATFORM="linux" | |
OP_ARCH="amd64" | |
op_release_notes=$(curl -sfL "${OP_RELEASE_NOTES_URL}") | |
if [ $? -eq 0 ]; then | |
op_url=$(echo "${op_release_notes}" | xmllint --html --xpath "string(//article[not(@class='beta')][1]/div[@class='cli-archs']/p[@class='system ${OP_PLATFORM}']/a[text()='${OP_ARCH}']/@href)" - 2>/dev/null) | |
if [ -z "${op_url}" ]; then | |
# If $op_url is empty (e.g. if the page layout has changed) | |
echo "1Password CLI tool release notes were not in an expected format at: ${OP_RELEASE_NOTES_URL}" | |
else | |
# $op_url should be the URL for the latest download | |
echo "${op_url}" | |
fi | |
else | |
# If the curl command failed (e.g. the page was not found) | |
echo "1Password CLI tool release notes were not found at: ${OP_RELEASE_NOTES_URL}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment