Skip to content

Commit

Permalink
add releases task
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Schwab committed Aug 25, 2013
1 parent d4fdeda commit 28ed533
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin
metrix
releases
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ install_dependencies:
clean:
rm -f bin/*

release:
GOOS=linux GOARCH=amd64 bash ./scripts/release.sh
GOOS=darwin GOARCH=amd64 bash ./scripts/release.sh

test:
go test -v

Expand Down
1 change: 1 addition & 0 deletions constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

const timeFormat = "2006-01-02 15:04:05Z"
const VERSION = "0.1.1"

var (
GITCOMMIT string
Expand Down
27 changes: 27 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -e

# to be called with
# GOOS=linux GOARCH=amd64 bash ./scripts/release.sh

BIN_NAME=metrix

# revision and version
PROJECT_ROOT=$(grealpath $(dirname $0)/../)
GIT_COMMIT=$(git rev-parse --short HEAD)
GIT_STATUS=$(test -n "`git status --porcelain`" && echo "+CHANGES" || echo "")
GIT_REV=$GIT_COMMIT$GIT_STATUS
VERSION=$(grep VERSION $PROJECT_ROOT/constants.go | cut -d '"' -f 2)

# dirs and paths
RELEASE_PATH=$PROJECT_ROOT/releases/$GIT_REV
NAME=$BIN_NAME-v$VERSION.$GOOS.$GOARCH
RELEASE_TMP_DIR=$RELEASE_PATH/$NAME
RELEASE_BIN=$RELEASE_TMP_DIR/$BIN_NAME

echo "building in $RELEASE_PATH"
mkdir -p $RELEASE_TMP_DIR
go build -a -ldflags "-X main.GITCOMMIT $GIT_REV" -o $RELEASE_BIN
chmod a+x $RELEASE_BIN
cd $(dirname $RELEASE_BIN) && tar cfz $RELEASE_PATH/$NAME.tar.gz $BIN_NAME
rm -Rf $RELEASE_TMP_DIR

0 comments on commit 28ed533

Please sign in to comment.