Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tag retrieval in the location header instead of a static file #2476

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,3 @@ oci-arm-push: build-linux-arm64
@echo "With the following pull command you get a containerlab binary at your working directory. To use this downloaded binary - do `chmod +x ./containerlab` and then `./containerlab deploy`. Make sure not forget to add ./ prefix in order to use the downloaded binary and not the globally installed containerlab!"
@echo 'If https proxy is configured in your environment, pass the proxies via --env HTTPS_PROXY="<proxy-address>" flag of the docker run command.'
@echo "download with: sudo docker run --rm -v \$$(pwd):/workspace ghcr.io/oras-project/oras:v1.1.0 pull ghcr.io/srl-labs/clab-oci:$(COMMIT_HASH)"

tag-release: # tag the release and save the version in ./internal/versions/latest
@VERSION_CLEAN=$$(echo "$(VERSION)" | sed 's/^v//') && \
echo "$$VERSION_CLEAN" > ./internal/versions/latest && \
git add . && git commit -m "release $$VERSION_CLEAN" && \
git tag v$$VERSION_CLEAN
16 changes: 9 additions & 7 deletions get.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# The install script is based off of the Apache 2.0 script from Helm,
# https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3

Expand All @@ -10,7 +12,7 @@
: ${REPO_NAME:="srl-labs/containerlab"}
: ${REPO_URL:="https://github.com/$REPO_NAME"}
: ${PROJECT_URL:="https://containerlab.dev"}
: ${VERSIONS_FILE_URL:="https://raw.githubusercontent.com/srl-labs/containerlab/refs/heads/main/internal/versions/latest"}
: ${LATEST_VERSION_URL:="${REPO_URL}/releases/latest"}

# detectArch discovers the architecture for this system.
detectArch() {
Expand Down Expand Up @@ -106,8 +108,8 @@ handleVersionError() {
processVersion() {
local version=$1
[ -z "$version" ] && handleVersionError
TAG_WO_VER="$version"
TAG="v${version}"
TAG_WO_VER=$(echo "${version}" | cut -c 2-)
TAG="${version}"
}

# setDesiredVersion sets the desired version either to an explicit version provided by a user
Expand All @@ -117,10 +119,10 @@ setDesiredVersion() {
# when desired version is not provided
# get latest tag from the <repo>/internal/versions.yml
if type "curl" &>/dev/null; then
local latest_version=$(curl -s ${VERSIONS_FILE_URL})
local latest_version=$(curl -s -I ${LATEST_VERSION_URL} | grep -i "location:" | awk -F'/' '{print $NF}' | tr -cd '[:alnum:].-')
processVersion "$latest_version"
elif type "wget" &>/dev/null; then
local latest_version=$(wget -q -O- ${VERSIONS_FILE_URL})
local latest_version=$(wget -qO- -S --spider ${LATEST_VERSION_URL} 2>&1 | grep -i "location:" | awk -F'/' '{print $NF}' | tr -cd '[:alnum:].-')
processVersion "$latest_version"
fi
else
Expand Down Expand Up @@ -220,7 +222,7 @@ downloadFile() {
CHECKSUM_URL="${REPO_URL}/releases/download/${TAG}/checksums.txt"
TMP_FILE="$TMP_ROOT/$ARCHIVE"
SUM_FILE="$TMP_ROOT/checksums.txt"
echo "Downloading $DOWNLOAD_URL"
echo "Downloading ${DOWNLOAD_URL}"
if type "curl" &>/dev/null; then
curl -SsL "$CHECKSUM_URL" -o "$SUM_FILE"
curl -SsL "$DOWNLOAD_URL" -o "$TMP_FILE"
Expand Down Expand Up @@ -328,7 +330,7 @@ help() {
echo -e "\t[--verify-checksum] ->> verify checksum of the downloaded file"
}

# removes temporary directory used to download artefacts
# removes temporary directory used to download artifacts
cleanup() {
if [[ -d "${TMP_ROOT:-}" ]]; then
rm -rf "$TMP_ROOT"
Expand Down
17 changes: 0 additions & 17 deletions internal/versions/README.md

This file was deleted.

1 change: 0 additions & 1 deletion internal/versions/latest

This file was deleted.

Loading