blob: 182c5c5c82eab8c0b70c4b975d6c245afb542776 [file] [log] [blame]
Austin Schuh40c16522018-10-28 20:27:54 -07001#!/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_x86 osx-x86_32.exe \
23 macosx_x64 osx-x86_64.exe \
24 linux_x86 linux-x86_32.exe \
25 linux_x64 linux-x86_64.exe \
26)
27
28set -e
29
30mkdir -p protoc
31# Create a zip file for each binary.
32for((i=0;i<${#FILE_NAMES[@]};i+=2));do
33 DIR_NAME=${FILE_NAMES[$i]}
34 mkdir -p protoc/$DIR_NAME
35
36 if [ ${DIR_NAME:0:3} = "win" ]; then
37 TARGET_BINARY="protoc.exe"
38 else
39 TARGET_BINARY="protoc"
40 fi
41
42 BINARY_NAME=${FILE_NAMES[$(($i+1))]}
43 BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME}
44
45 if ! wget ${BINARY_URL} -O protoc/$DIR_NAME/$TARGET_BINARY &> /dev/null; then
46 echo "[ERROR] Failed to download ${BINARY_URL}" >&2
47 echo "[ERROR] Skipped $protoc-${VERSION_NAME}-${DIR_NAME}" >&2
48 continue
49 fi
50done
51
52nuget pack Google.Protobuf.Tools.nuspec