github.com/ZuluSpl0it/Sia@v1.3.7/release.sh (about) 1 #!/bin/bash 2 set -e 3 4 # version and keys are supplied as arguments 5 version="$1" 6 keyfile="$2" 7 pubkeyfile="$3" # optional 8 if [[ -z $version || -z $keyfile ]]; then 9 echo "Usage: $0 VERSION KEYFILE" 10 exit 1 11 fi 12 if [[ -z $pubkeyfile ]]; then 13 echo "Warning: no public keyfile supplied. Binaries will not be verified." 14 fi 15 16 # check for keyfile before proceeding 17 if [ ! -f $keyfile ]; then 18 echo "Key file not found: $keyfile" 19 exit 1 20 fi 21 keysum=$(shasum -a 256 $keyfile | cut -c -64) 22 if [ $keysum != "735320b4698010500d230c487e970e12776e88f33ad777ab380a493691dadb1b" ]; then 23 echo "Wrong key file: checksum does not match developer key file." 24 exit 1 25 fi 26 27 # setup build-time vars 28 ldflags="-s -w -X 'github.com/NebulousLabs/Sia/build.GitRevision=`git rev-parse --short HEAD`' -X 'github.com/NebulousLabs/Sia/build.BuildTime=`date`'" 29 30 for os in darwin linux windows; do 31 echo Packaging ${os}... 32 # create workspace 33 folder=release/Sia-$version-$os-amd64 34 rm -rf $folder 35 mkdir -p $folder 36 # compile and sign binaries 37 for pkg in siac siad; do 38 bin=$pkg 39 if [ "$os" == "windows" ]; then 40 bin=${pkg}.exe 41 fi 42 GOOS=${os} go build -a -tags 'netgo' -ldflags="$ldflags" -o $folder/$bin ./cmd/$pkg 43 openssl dgst -sha256 -sign $keyfile -out $folder/${bin}.sig $folder/$bin 44 # verify signature 45 if [[ -n $pubkeyfile ]]; then 46 openssl dgst -sha256 -verify $pubkeyfile -signature $folder/${bin}.sig $folder/$bin 47 fi 48 49 done 50 # add other artifacts 51 cp -r doc LICENSE README.md $folder 52 # zip 53 ( 54 cd release 55 zip -rq Sia-$version-$os-amd64.zip Sia-$version-$os-amd64 56 ) 57 done