-
Notifications
You must be signed in to change notification settings - Fork 14
/
release.sh
executable file
·68 lines (54 loc) · 1.69 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
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -eu -o pipefail
shopt -s failglob
[ $# -ne 2 ] && { echo "Usage: $0 VERSION NAME"; exit 1; }
RELEASE_VERSION=$1
RELEASE_NAME=$2
RELEASE_DIR=$(pwd)/dist
echo "git reset and clean"
git reset --hard && git clean -xfd
echo "checking docs install version"
if ! grep "$RELEASE_VERSION" ./docs/install.md;
then
echo "Docs install version does not match release version, aborting";
exit 1;
fi
release_tag=v${RELEASE_VERSION}
echo "git tag ${release_tag} ${RELEASE_NAME}"
git tag -s -a "$release_tag" -m "$release_tag $RELEASE_NAME"
build() {
goos=$1
goarch=$2
dir=${RELEASE_DIR}/aretext_${RELEASE_VERSION}_${goos}_${goarch}
echo "$dir"
mkdir -p "$dir"
GOOS=$1 GOARCH=$2 go build \
-trimpath \
-ldflags="-X 'main.version=${RELEASE_VERSION}'" \
-o "$dir/aretext" \
github.com/aretext/aretext
cp LICENSE "$dir/"
cp -r docs "$dir/"
archive_cwd=$(dirname "$dir")
archive_src=$(basename "$dir")
archive_dst=$RELEASE_DIR/${archive_src}.tar.gz
echo "$archive_dst"
tar -czf "$archive_dst" -C "$archive_cwd" "$archive_src"
}
build linux amd64
build linux arm64
build linux 386
build darwin amd64
build darwin arm64
build freebsd amd64
build freebsd arm64
checksums=aretext_${RELEASE_VERSION}_checksums.txt
echo "$RELEASE_DIR/$checksums"
(cd "$RELEASE_DIR" && shasum -a 256 ./*.tar.gz > "$checksums")
signatures=$checksums.sig
echo "$RELEASE_DIR/$signatures"
(cd "$RELEASE_DIR" && gpg --output "$signatures" --detach-sig "$checksums")
echo "verifying signature and checksums"
(cd "$RELEASE_DIR" && gpg --verify "$signatures" "$checksums" && shasum -c "$checksums")
echo "publishing git tag"
git push origin "$release_tag"