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
This commit is contained in:
Glenn Sommer 2023-10-25 00:14:00 +02:00 committed by GitHub
parent 7a5c6b24ae
commit e7d52beeab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)