Skip to content

Commit

Permalink
Support pinning version during binary install (#1237)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
glemsom authored Oct 24, 2023
1 parent 7a5c6b2 commit e7d52be
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions release_files/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e7d52be

Please sign in to comment.