From 82c03e30515ed8467e152e546e64bde9b296680f Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Fri, 11 Jul 2025 14:43:29 +0200 Subject: [PATCH] improve protoc download script --- docs/package.json | 3 ++- docs/plugin-download.sh | 58 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/docs/package.json b/docs/package.json index ed8a6bf68d..76914603a1 100644 --- a/docs/package.json +++ b/docs/package.json @@ -14,8 +14,9 @@ "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "ensure-plugins": "if [ ! -f \"protoc-gen-connect-openapi/protoc-gen-connect-openapi\" ]; then sh ./plugin-download.sh; fi", + "debug-plugins": "echo \"PWD: $(pwd)\" && echo \"Plugin file exists: $(test -f protoc-gen-connect-openapi/protoc-gen-connect-openapi && echo 'yes' || echo 'no')\" && echo \"Plugin executable: $(test -x protoc-gen-connect-openapi/protoc-gen-connect-openapi && echo 'yes' || echo 'no')\" && ls -la protoc-gen-connect-openapi/ || echo 'Plugin directory not found'", "generate": "pnpm run generate:grpc && pnpm run generate:apidocs && pnpm run generate:configdocs", - "generate:grpc": "buf generate ../proto", + "generate:grpc": "pnpm run ensure-plugins && buf generate ../proto", "generate:apidocs": "docusaurus gen-api-docs all", "generate:configdocs": "cp -r ../cmd/defaults.yaml ./docs/self-hosting/manage/configure/ && cp -r ../cmd/setup/steps.yaml ./docs/self-hosting/manage/configure/", "generate:re-gen": "yarn generate:clean-all && pnpm generate", diff --git a/docs/plugin-download.sh b/docs/plugin-download.sh index 499326a1e7..64d4bfb320 100644 --- a/docs/plugin-download.sh +++ b/docs/plugin-download.sh @@ -1,8 +1,28 @@ -echo $(uname -m) -mkdir protoc-gen-connect-openapi +#!/bin/bash +set -e + +echo "Downloading protoc-gen-connect-openapi plugin..." +echo "Architecture: $(uname -m)" +echo "OS: $(uname)" + +# Create directory if it doesn't exist +mkdir -p protoc-gen-connect-openapi cd ./protoc-gen-connect-openapi/ + +# Skip download if plugin already exists and is executable +if [ -f "protoc-gen-connect-openapi" ] && [ -x "protoc-gen-connect-openapi" ]; then + echo "Plugin already exists and is executable" + ./protoc-gen-connect-openapi --version || echo "Plugin version check failed, but file exists" + exit 0 +fi + +# Clean up any partial downloads +rm -f protoc-gen-connect-openapi.tar.gz protoc-gen-connect-openapi + +# Determine download URL based on OS and architecture if [ "$(uname)" = "Darwin" ]; then - curl -L -o protoc-gen-connect-openapi.tar.gz https://github.com/sudorandom/protoc-gen-connect-openapi/releases/download/v0.18.0/protoc-gen-connect-openapi_0.18.0_darwin_all.tar.gz + echo "Downloading for Darwin..." + URL="https://github.com/sudorandom/protoc-gen-connect-openapi/releases/download/v0.18.0/protoc-gen-connect-openapi_0.18.0_darwin_all.tar.gz" else ARCH=$(uname -m) case $ARCH in @@ -17,6 +37,34 @@ else exit 1 ;; esac - curl -L -o protoc-gen-connect-openapi.tar.gz https://github.com/sudorandom/protoc-gen-connect-openapi/releases/download/v0.18.0/protoc-gen-connect-openapi_0.18.0_linux_${ARCH}.tar.gz + echo "Downloading for Linux ${ARCH}..." + URL="https://github.com/sudorandom/protoc-gen-connect-openapi/releases/download/v0.18.0/protoc-gen-connect-openapi_0.18.0_linux_${ARCH}.tar.gz" fi -tar -xvf protoc-gen-connect-openapi.tar.gz \ No newline at end of file + +# Download with retries +echo "Downloading from: $URL" +curl -L -o protoc-gen-connect-openapi.tar.gz "$URL" || { + echo "Download failed, trying with different curl options..." + curl -L --fail --retry 3 --retry-delay 1 -o protoc-gen-connect-openapi.tar.gz "$URL" +} + +echo "Extracting plugin..." +tar -xzf protoc-gen-connect-openapi.tar.gz + +# Verify extraction +if [ ! -f "protoc-gen-connect-openapi" ]; then + echo "ERROR: Plugin binary not found after extraction" + ls -la + exit 1 +fi + +# Make sure the plugin is executable +chmod +x protoc-gen-connect-openapi + +# Verify plugin works +echo "Plugin installed successfully" +ls -la protoc-gen-connect-openapi +./protoc-gen-connect-openapi --version || echo "Plugin version check failed, but installation completed" + +# Clean up +rm -f protoc-gen-connect-openapi.tar.gz \ No newline at end of file