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