From e7d52beeabfe68533c9c252a9f846bff72bef5e2 Mon Sep 17 00:00:00 2001 From: Glenn Sommer Date: Wed, 25 Oct 2023 00:14:00 +0200 Subject: [PATCH] Support pinning version during binary install (#1237) For installations using the binary release method (using the official installer script), it would be nice to be able to define a specific version to install. A user/developer can choose to define the NETBIRD_RELEASE variable during installation, to pin a specific version during installation. If NETBIRD_RELEASE is not defined, we default to the current behavior of latest --- release_files/install.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/release_files/install.sh b/release_files/install.sh index e529c229e..ef5012f0d 100755 --- a/release_files/install.sh +++ b/release_files/install.sh @@ -23,19 +23,28 @@ if command -v sudo > /dev/null && [ "$(id -u)" -ne 0 ]; then SUDO="sudo" fi -get_latest_release() { +if [ -z ${NETBIRD_RELEASE+x} ]; then + NETBIRD_RELEASE=latest +fi + +get_release() { + local RELEASE=$1 + if [ "$RELEASE" = "latest" ]; then + local TAG="latest" + else + local TAG="tags/${RELEASE}" + fi if [ -n "$GITHUB_TOKEN" ]; then - curl -H "Authorization: token ${GITHUB_TOKEN}" -s "https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" \ + curl -H "Authorization: token ${GITHUB_TOKEN}" -s "https://api.github.com/repos/${OWNER}/${REPO}/releases/${TAG}" \ | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' else - curl -s "https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" \ + curl -s "https://api.github.com/repos/${OWNER}/${REPO}/releases/${TAG}" \ | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' fi - } download_release_binary() { - VERSION=$(get_latest_release) + VERSION=$(get_release "$NETBIRD_RELEASE") BASE_URL="https://github.com/${OWNER}/${REPO}/releases/download" BINARY_BASE_NAME="${VERSION#v}_${OS_TYPE}_${ARCH}.tar.gz" @@ -299,7 +308,7 @@ stop_running_netbird_ui() { update_netbird() { if is_bin_package_manager "$CONFIG_FILE"; then - latest_release=$(get_latest_release) + latest_release=$(get_release "latest") latest_version=${latest_release#v} installed_version=$(netbird version)