forked from rqlite/rqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·55 lines (46 loc) · 1.39 KB
/
package.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
#!/bin/bash
#
# Simple script for creating releases.
#
# To determine the GitHub release ID, execute this command:
#
# curl https://api.github.com/repos/rqlite/rqlite/releases
#
if [ $# -lt 1 ]; then
echo "$0 <version> [release_id api_token]"
exit 1
fi
REPO_URL="https://github.com/rqlite/rqlite"
VERSION=$1
RELEASE_ID=$2
API_TOKEN=$3
tmp_build=`mktemp -d`
tmp_pkg=`mktemp -d`
kernel=`uname -s`
machine=`uname -m`
if [ "$machine" == "x86_64" ]; then
machine="amd64"
fi
branch=`git rev-parse --abbrev-ref HEAD`
commit=`git rev-parse HEAD`
kernel=`uname -s`
buildtime=`date +%Y-%m-%dT%T%z`
mkdir -p $tmp_build/src/github.com/rqlite
export GOPATH=$tmp_build
cd $tmp_build/src/github.com/rqlite
git clone $REPO_URL
cd rqlite
go get -d ./...
go install -ldflags="-X main.version=$VERSION -X main.branch=$branch -X main.commit=$commit -X main.buildtime=$buildtime" ./...
release=`echo rqlite-$VERSION-$kernel-$machine | tr '[:upper:]' '[:lower:]'`
release_pkg=${release}.tar.gz
mkdir $tmp_pkg/$release
cp $GOPATH/bin/rqlited $tmp_pkg/$release
cp $GOPATH/bin/rqlite $tmp_pkg/$release
cd $tmp_pkg
tar cvfz $release_pkg $release
if [ -z "$API_TOKEN" ]; then
exit 0
fi
upload_url="https://uploads.github.com/repos/rqlite/rqlite/releases/$RELEASE_ID/assets"
curl -v -H "Content-type: application/octet-stream" -H "Authorization: token $API_TOKEN" -XPOST $upload_url?name=$release_pkg --data-binary @$release_pkg