diff --git a/src/atuin.sh/devcontainer-feature.json b/src/atuin.sh/devcontainer-feature.json index f94bc83..037dd12 100644 --- a/src/atuin.sh/devcontainer-feature.json +++ b/src/atuin.sh/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "atuin.sh", "id": "atuin.sh", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"atuin\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/atuin.sh", "options": { diff --git a/src/atuin.sh/install.sh b/src/atuin.sh/install.sh index d1916b6..145accc 100755 --- a/src/atuin.sh/install.sh +++ b/src/atuin.sh/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='atuinsh/atuin' readonly binaryName='atuin' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}-${architecture}-unknown-linux-gnu.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}-${architecture}-unknown-linux-gnu.tar.gz' readonly binaryPathInArchiveTemplate='${name}-${architecture}-unknown-linux-gnu/${binaryName}' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" @@ -113,6 +113,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -130,6 +142,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$(echo -n "$binaryPathInArchiveTemplate" | envsubst)" diff --git a/src/btop/devcontainer-feature.json b/src/btop/devcontainer-feature.json index 78228d0..6dfd3e3 100644 --- a/src/btop/devcontainer-feature.json +++ b/src/btop/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "btop", "id": "btop", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"btop\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/btop", "options": { diff --git a/src/btop/install.sh b/src/btop/install.sh index c93eafc..57930e7 100755 --- a/src/btop/install.sh +++ b/src/btop/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='aristocratos/btop' readonly binaryName='btop' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}-${architecture}-linux-musl.tbz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}-${architecture}-linux-musl.tbz' readonly binaryPathInArchiveTemplate='./btop/bin/${binaryName}' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" @@ -113,6 +113,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -131,6 +143,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$(echo -n "$binaryPathInArchiveTemplate" | envsubst)" diff --git a/src/charmbracelet-gum/devcontainer-feature.json b/src/charmbracelet-gum/devcontainer-feature.json index aea9d45..fc8852b 100644 --- a/src/charmbracelet-gum/devcontainer-feature.json +++ b/src/charmbracelet-gum/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "charmbracelet/gum", "id": "charmbracelet-gum", - "version": "1.0.2", + "version": "1.0.3", "description": "Install \"gum\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/charmbracelet-gum", "options": { diff --git a/src/charmbracelet-gum/install.sh b/src/charmbracelet-gum/install.sh index 6d221ea..c5c7689 100755 --- a/src/charmbracelet-gum/install.sh +++ b/src/charmbracelet-gum/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='charmbracelet/gum' readonly binaryName='gum' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}_${version}_Linux_${architecture}.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}_${version}_Linux_${architecture}.tar.gz' readonly binaryPathInArchiveTemplate='${name}_${version}_Linux_${architecture}/${binaryName}' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" @@ -111,6 +111,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -128,6 +140,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$(echo -n "$binaryPathInArchiveTemplate" | envsubst)" diff --git a/src/chezmoi.io/devcontainer-feature.json b/src/chezmoi.io/devcontainer-feature.json index 1358fbc..c725721 100644 --- a/src/chezmoi.io/devcontainer-feature.json +++ b/src/chezmoi.io/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "chezmoi.io", "id": "chezmoi.io", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"chezmoi\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/chezmoi.io", "options": { diff --git a/src/chezmoi.io/install.sh b/src/chezmoi.io/install.sh index da51ead..f04c3f1 100755 --- a/src/chezmoi.io/install.sh +++ b/src/chezmoi.io/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='twpayne/chezmoi' readonly binaryName='chezmoi' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}_${version}_linux_${architecture}.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}_${version}_linux_${architecture}.tar.gz' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" apt_get_update() { @@ -103,6 +103,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -120,6 +132,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$binaryName" diff --git a/src/jj-vcs.dev/devcontainer-feature.json b/src/jj-vcs.dev/devcontainer-feature.json index fe2f756..231c620 100644 --- a/src/jj-vcs.dev/devcontainer-feature.json +++ b/src/jj-vcs.dev/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "jj-vcs.dev", "id": "jj-vcs.dev", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"jj\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/jj-vcs.dev", "options": { diff --git a/src/jj-vcs.dev/install.sh b/src/jj-vcs.dev/install.sh index b39a046..daf4b11 100755 --- a/src/jj-vcs.dev/install.sh +++ b/src/jj-vcs.dev/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='jj-vcs/jj' readonly binaryName='jj' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}-v${version}-${architecture}-unknown-linux-musl.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}-${releaseTag}-${architecture}-unknown-linux-musl.tar.gz' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" apt_get_update() { @@ -112,6 +112,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -129,6 +141,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="./$binaryName" diff --git a/src/opencode.ai/devcontainer-feature.json b/src/opencode.ai/devcontainer-feature.json index 55fb5fd..60d7804 100644 --- a/src/opencode.ai/devcontainer-feature.json +++ b/src/opencode.ai/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "opencode.ai", "id": "opencode.ai", - "version": "1.0.1", + "version": "1.0.2", "description": "Install \"opencode\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/opencode.ai", "options": { diff --git a/src/opencode.ai/install.sh b/src/opencode.ai/install.sh index 1a63997..e5f3810 100755 --- a/src/opencode.ai/install.sh +++ b/src/opencode.ai/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='anomalyco/opencode' readonly binaryName='opencode' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}-linux-${architecture}.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}-linux-${architecture}.tar.gz' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" apt_get_update() { @@ -106,6 +106,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -123,6 +135,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryTargetPath="$(echo -n "$binaryTargetPathTemplate" | envsubst)" diff --git a/src/smallstep.com/devcontainer-feature.json b/src/smallstep.com/devcontainer-feature.json index 42a62f8..ff4905d 100644 --- a/src/smallstep.com/devcontainer-feature.json +++ b/src/smallstep.com/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "smallstep.com", "id": "smallstep.com", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"step\" cli binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/smallstep.com", "options": { diff --git a/src/smallstep.com/install.sh b/src/smallstep.com/install.sh index 9ab3b56..70819b6 100755 --- a/src/smallstep.com/install.sh +++ b/src/smallstep.com/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='smallstep/cli' readonly binaryName='step' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/step_linux_${version}_${architecture}.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/step_linux_${version}_${architecture}.tar.gz' readonly binaryPathInArchiveTemplate='step_${version}/bin/${binaryName}' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" @@ -108,6 +108,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -125,6 +137,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$(echo -n "$binaryPathInArchiveTemplate" | envsubst)" diff --git a/src/starship.rs/devcontainer-feature.json b/src/starship.rs/devcontainer-feature.json index f6182af..432bf68 100644 --- a/src/starship.rs/devcontainer-feature.json +++ b/src/starship.rs/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "starship.rs", "id": "starship.rs", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"starship\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/starship.rs", "options": { diff --git a/src/starship.rs/install.sh b/src/starship.rs/install.sh index 134987b..6effbc9 100755 --- a/src/starship.rs/install.sh +++ b/src/starship.rs/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='starship/starship' readonly binaryName='starship' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}-${architecture}-unknown-linux-musl.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}-${architecture}-unknown-linux-musl.tar.gz' readonly binaryPathInArchiveTemplate='${binaryName}' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" @@ -113,6 +113,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -130,6 +142,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$(echo -n "$binaryPathInArchiveTemplate" | envsubst)" diff --git a/src/zellij.dev/devcontainer-feature.json b/src/zellij.dev/devcontainer-feature.json index 62035a8..5ecfebf 100644 --- a/src/zellij.dev/devcontainer-feature.json +++ b/src/zellij.dev/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "zellij.dev", "id": "zellij.dev", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"zellij\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/zellij.dev", "options": { diff --git a/src/zellij.dev/install.sh b/src/zellij.dev/install.sh index 2d44771..6b8858d 100755 --- a/src/zellij.dev/install.sh +++ b/src/zellij.dev/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='zellij-org/zellij' readonly binaryName='zellij' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}-${architecture}-unknown-linux-musl.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}-${architecture}-unknown-linux-musl.tar.gz' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" apt_get_update() { @@ -112,6 +112,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -129,6 +141,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$binaryName" diff --git a/src/zyedidia-eget/devcontainer-feature.json b/src/zyedidia-eget/devcontainer-feature.json index 80fe0fe..1b366e6 100644 --- a/src/zyedidia-eget/devcontainer-feature.json +++ b/src/zyedidia-eget/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "zyedidia/eget", "id": "zyedidia-eget", - "version": "1.0.0", + "version": "1.0.1", "description": "Install \"eget\" binary", "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/zyedidia-eget", "options": { diff --git a/src/zyedidia-eget/install.sh b/src/zyedidia-eget/install.sh index 05d958e..66f722a 100755 --- a/src/zyedidia-eget/install.sh +++ b/src/zyedidia-eget/install.sh @@ -7,7 +7,7 @@ set -o allexport readonly githubRepository='zyedidia/eget' readonly binaryName='eget' readonly versionArgument='--version' -readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/v${version}/${name}-${version}-linux_${architecture}.tar.gz' +readonly downloadUrlTemplate='https://github.com/${githubRepository}/releases/download/${releaseTag}/${name}-${version}-linux_${architecture}.tar.gz' readonly binaryPathInArchiveTemplate='${name}-${version}-linux_${architecture}/${binaryName}' readonly binaryTargetFolder='/usr/local/bin' readonly name="${githubRepository##*/}" @@ -111,6 +111,18 @@ github_get_latest_release() { fi github_list_releases "$1" | head -n 1 } +github_get_tag_for_version() { + if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: github_get_tag_for_version " + return 1 + fi + local repo="$1" + local version="$2" + local url="https://api.github.com/repos/$repo/releases" + local escaped_version + escaped_version="$(printf '%s' "$version" | sed 's/\./\\./g')" + curl -s "$url" | grep -Po '"tag_name": "\K.*?(?=")' | grep -E "^v?${escaped_version}$" | head -n 1 +} utils_check_version() { local version=$1 if ! [[ "${version:-}" =~ ^(latest|[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then @@ -128,6 +140,11 @@ install() { VERSION=$(github_get_latest_release "$githubRepository") fi readonly version="${VERSION:?}" + readonly releaseTag="$(github_get_tag_for_version "$githubRepository" "$version")" + if [ -z "$releaseTag" ]; then + printf >&2 '=== [ERROR] Could not find release tag for version "%s" in "%s"!\n' "$version" "$githubRepository" + exit 1 + fi readonly downloadUrl="$(echo -n "$downloadUrlTemplate" | envsubst)" curl_check_url "$downloadUrl" readonly binaryPathInArchive="$(echo -n "$binaryPathInArchiveTemplate" | envsubst)"