-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
release.sh
executable file
·49 lines (46 loc) · 1.34 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
#!/bin/bash
set -e
# get verison from main.go VERSION string
if [ $# -eq 0 ]; then
VERSION=$(cat main.go|grep "VERSION string"| awk -v FS="(\")" '{print $2}')
else
VERSION=$1
fi
echo Releasing $VERSION
WINF=whatscli-$VERSION-windows.zip
LINUXF=whatscli-$VERSION-linux.zip
MACF=whatscli-$VERSION-macos.zip
RASPIF=whatscli-$VERSION-raspberrypi.zip
# build zip files with binaries
GOOS=darwin go build -o whatscli
zip $MACF whatscli
rm whatscli
GOOS=windows go build -o whatscli.exe
zip $WINF whatscli.exe
rm whatscli.exe
GOOS=linux go build -o whatscli
zip $LINUXF whatscli
rm whatscli
GOOS=linux GOARCH=arm GOARM=5 go build -o whatscli
zip $RASPIF whatscli
rm whatscli
# publish to github
git pull
LASTTAG=$(git describe --tags --abbrev=0)
git log $LASTTAG..HEAD --no-decorate --pretty=format:"- %s" --abbrev-commit > changes.txt
vim changes.txt
gh release create $VERSION $LINUXF $MACF $WINF $RASPIF -F changes.txt -t $VERSION
rm changes.txt
rm *.zip
# update homebrew tap
URL="https://github.com/normen/whatscli/archive/$VERSION.tar.gz"
wget $URL
SHASUM=$(shasum -a 256 $VERSION.tar.gz|awk '{print$1}')
rm $VERSION.tar.gz
cd ../../BrewCode/homebrew-tap
sed -i bak "s/sha256 \".*/sha256 \"$SHASUM\"/" Formula/whatscli.rb
sed -i bak "s!url \".*!url \"$URL\"!" Formula/whatscli.rb
rm Formula/whatscli.rbbak
git add -A
git commit -m "update whatscli to $VERSION"
git push