From ab7ab23a8859bd2d39dcafe345f0243420109709 Mon Sep 17 00:00:00 2001 From: Kyle Downey <8682922+kdowney-lot49@users.noreply.github.com> Date: Sat, 7 Feb 2026 21:49:21 +0000 Subject: [PATCH] fix: remove dependency on deprecated nanolayer package Signed-off-by: Kyle Downey <8682922+kdowney-lot49@users.noreply.github.com> --- .pre-commit-config.yaml | 6 ++-- src/buf/devcontainer-feature.json | 2 +- src/buf/install.sh | 57 +++++++++++++++++++------------ 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 595abad..4ab2a25 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: hooks: - id: license-eye - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: pretty-format-json args: @@ -34,7 +34,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/compilerla/conventional-pre-commit - rev: v4.2.0 + rev: v4.3.0 hooks: - id: conventional-pre-commit stages: @@ -45,7 +45,7 @@ repos: - id: markdown-toc exclude: ^src - repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.18.1 + rev: v0.20.0 hooks: - id: markdownlint-cli2 exclude: ^src diff --git a/src/buf/devcontainer-feature.json b/src/buf/devcontainer-feature.json index c32eb24..dfcfd88 100644 --- a/src/buf/devcontainer-feature.json +++ b/src/buf/devcontainer-feature.json @@ -25,6 +25,6 @@ } }, "installsAfter": [ - "ghcr.io/devcontainers-extra/features/gh-release" + "ghcr.io/devcontainers-extra/features/curl-apt-get:1" ] } diff --git a/src/buf/install.sh b/src/buf/install.sh index 12f3664..50e7eaf 100755 --- a/src/buf/install.sh +++ b/src/buf/install.sh @@ -27,27 +27,40 @@ if [[ "$INSTALL_PROTOC_GEN_BUF_LINT" == "true" ]]; then binary_names="$binary_names,protoc-gen-buf-lint" fi -source ./library_scripts.sh - -# nanolayer is a cli utility which keeps container layers as small as possible -# source code: https://github.com/devcontainers-contrib/nanolayer -# `ensure_nanolayer` is a bash function that will find any existing nanolayer installations, -# and if missing - will download a temporary copy that automatically get deleted at the end -# of the script -ensure_nanolayer nanolayer_location "v0.4.45" - -$nanolayer_location \ - install \ - devcontainer-feature \ - "ghcr.io/devcontainers-extra/features/gh-release:1.0.26" \ - --option repo='bufbuild/buf' \ - --option binaryNames="$binary_names" \ - --option version="$VERSION" \ - --option assetRegex='.*\.tar\.gz' \ - --option libName='buf' - -rm /usr/local/bin/buf - -ln -s /usr/local/lib/buf/buf/bin/buf /usr/local/bin/buf +BIN="/usr/local/bin" +REPO_OWNER="bufbuild" +REPO_NAME="buf" +VERSION="${VERSION:-"latest"}" # Default to latest if not set + +# Resolve "latest" to a real tag +if [ "${VERSION}" = "latest" ]; then + echo "Fetching latest version from GitHub..." + API_URL="https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest" + + # Extract tag_name from JSON response + VERSION=$(curl -sL "${API_URL}" | grep '"tag_name":' | cut -d : -f 2,3 | tr -d \", | tr -d '[:space:]') + + if [ -z "${VERSION}" ]; then + echo "Error: Failed to fetch the latest version tag from GitHub." + exit 1 + fi +fi + +VERSION="${VERSION#v}" +IFS=',' read -ra BINARIES <<< "$binary_names" + +for binary in "${BINARIES[@]}"; do + echo "Downloading ${binary}..." + DOWNLOAD_URL="https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/v${VERSION}/${binary}-$(uname -s)-$(uname -m)" + + if ! curl -fsSL "$DOWNLOAD_URL" -o "${BIN}/${binary}"; then + echo "Error: Failed to download ${binary} version v${VERSION}." + echo "URL: ${DOWNLOAD_URL}" + rm -f "${BIN}/${binary}" + exit 1 + fi + + chmod +x "${BIN}/${binary}" +done echo 'Done!'