-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·64 lines (46 loc) · 1.39 KB
/
build.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
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -eou pipefail
version="$(git tag | sort --version-sort -r | head -1)"
last_tag_ref=$(git log --decorate | grep $version | cut -d' ' -f 2 | head -c 7)
last_commit_ref="$(git log -1 --oneline | cut -d' ' -f 1)"
echo $version $last_tag_ref $last_commit_ref
if [ ! $last_tag_ref == $last_commit_ref ]; then
echo "last commit is not last tag"
echo "last tag: $version"
fi
[ -d dist/ ] && mv dist/ dist.prev/
# force using go modules when inside GOPATH
export GO111MODULE=on
xgo \
--targets="darwin/amd64,linux/amd64" \
--dest=dist \
--ldflags "-X main.version=$version" \
-v -x \
github.com/endorama/2ami
sudo chown $USER: -R dist
gpg_sign_key="edoardo.tenani@protonmail.com"
checksum_file="dist/2ami-${version}_checksums.txt"
orig_darwin_file="dist/2ami-darwin-10.6-amd64"
orig_linux_file="dist/2ami-linux-amd64"
darwin_file="dist/2ami-${version}-darwin-10.6-amd64"
linux_file="dist/2ami-${version}-linux-amd64"
mv -f "$orig_darwin_file" "$darwin_file"
mv -f "$orig_linux_file" "$linux_file"
gpg2 \
-u ${gpg_sign_key} \
--output ${darwin_file}.sig \
--detach-sign ${darwin_file}
gpg2 \
-u ${gpg_sign_key} \
--output ${linux_file}.sig \
--detach-sign ${linux_file}
sha1sum \
"$darwin_file" \
"$linux_file" \
${checksum_file} \
> $checksum_file
gpg2 \
-u ${gpg_sign_key} \
--output ${checksum_file}.sig \
--detach-sign ${checksum_file}
rm -r dist.prev/