1#!/bin/bash 2 3if [ $# -ne 1 ]; then 4 cat <<EOF 5Usage: $0 <VERSION_NUMBER> 6 7Example: 8 $ $0 3.0.0 9 10This script will download pre-built protoc binaries from maven repository and 11create the Google.Protobuf.Tools package. Well-known type .proto files will also 12be included. 13EOF 14 exit 1 15fi 16 17VERSION_NUMBER=$1 18# <directory name> <binary file name> pairs. 19declare -a FILE_NAMES=( \ 20 windows_x86 windows-x86_32.exe \ 21 windows_x64 windows-x86_64.exe \ 22 macosx_x64 osx-x86_64.exe \ 23 linux_x86 linux-x86_32.exe \ 24 linux_x64 linux-x86_64.exe \ 25) 26 27set -e 28 29mkdir -p protoc 30# Create a zip file for each binary. 31for((i=0;i<${#FILE_NAMES[@]};i+=2));do 32 DIR_NAME=${FILE_NAMES[$i]} 33 mkdir -p protoc/$DIR_NAME 34 35 if [ ${DIR_NAME:0:3} = "win" ]; then 36 TARGET_BINARY="protoc.exe" 37 else 38 TARGET_BINARY="protoc" 39 fi 40 41 BINARY_NAME=${FILE_NAMES[$(($i+1))]} 42 BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME} 43 44 if ! wget ${BINARY_URL} -O protoc/$DIR_NAME/$TARGET_BINARY &> /dev/null; then 45 echo "[ERROR] Failed to download ${BINARY_URL}" >&2 46 echo "[ERROR] Skipped $protoc-${VERSION_NAME}-${DIR_NAME}" >&2 47 continue 48 fi 49done 50 51nuget pack Google.Protobuf.Tools.nuspec 52