-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·47 lines (42 loc) · 1.4 KB
/
release
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
#!/bin/bash
# Embrace the sweet release of code!
# Run this in the repository's root directory when you're ready to release.
log () {
echo "sweet release: $1"
}
builds="builds"
mkdir $builds
cd $builds || exit
# see: `go tool dist list`
platforms=("darwin/amd64" "darwin/arm64" "linux/amd64" "linux/arm64" "windows/amd64" "windows/arm64")
version=$(git tag --sort=-creatordate | head -n 1)
assets=()
log "building release of sweet$version"
for p in "${platforms[@]}";
do
os=$(echo "$p" | cut -d/ -f 1)
arch=$(echo "$p" | cut -d/ -f 2)
name="sweet-$os-$arch"
if [ "$os" = "windows" ]; then
name="$name.exe"
fi
path="$name"
log "building $path..."
GOOS=$os GOARCH=$arch go build -C .. -ldflags "-w -X github.com/NicksPatties/sweet/cmd/about.version=v0.1.0 -X github.com/NicksPatties/sweet/cmd/version.version=$version -X github.com/NicksPatties/sweet/cmd/about.version=$version" -o "$builds/$path"
log "$path built"
assets+=("$path")
log "generating checksum for $path..."
sum="$path.sha256"
sha256sum "$path" >> "$sum"
assets+=("$sum")
log "checksum for $path generated"
done
log "done building assets!"
log "creating draft of release for sweet$version"
gh release create "$version" --generate-notes -d "${assets[@]}"
log "removing $builds directory"
cd ..
rm -rf $builds
log "releasing to pkg.go.dev"
GOPROXY=proxy.golang.org go list -m "github.com/NicksPatties/sweet@$version"
log "all done!"