deploy.sh 1.05 KB
Newer Older
1 2
#!/bin/bash

Christopher Schinnerl's avatar
Christopher Schinnerl committed
3 4 5 6
PRIVKEY=$1

# Create fresh artifacts folder.
rm -rf artifacts
7
mkdir artifacts
Christopher Schinnerl's avatar
Christopher Schinnerl committed
8

9 10 11
# Return first error encountered by any command.
set -e

Christopher Schinnerl's avatar
Christopher Schinnerl committed
12 13 14 15
# Generate public key from private key.
echo "$PRIVKEY" | openssl rsa -in - -outform PEM -pubout -out artifacts/pubkey.pem

# Build binaries and sign them.
16 17 18
for arch in amd64 arm; do
	for os in darwin linux windows; do
	        for pkg in siac siad; do
19
			# Ignore unsupported arch/os combinations.
20 21 22 23 24 25
			if [ "$arch" == "arm" ]; then
				if [ "$os" == "windows" ] || [ "$os" == "darwin" ]; then
					continue
				fi
			fi

26
			# Binaries are called 'siac' and i'siad'.
27
	                bin=$pkg
28 29

			# Different naming convention for windows.
30 31 32
	                if [ "$os" == "windows" ]; then
	                        bin=${pkg}.exe
	                fi
33

34
			# Build binary.
35
	                GOOS=${os} GOARCH=${arch} go build -tags='netgo' -o artifacts/$arch/$os/$bin ./cmd/$pkg
Christopher Schinnerl's avatar
Christopher Schinnerl committed
36

37
			# Sign binary.
Christopher Schinnerl's avatar
Christopher Schinnerl committed
38
			echo "$PRIVKEY" | openssl dgst -sha256 -sign - -out artifacts/$arch/$os/$bin.sha256 artifacts/$arch/$os/$bin
39 40 41
	        done
	done
done