Skip to content

Commit

Permalink
Add a release script, keep a simple build.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
matm committed Sep 14, 2015
1 parent 65d9f3f commit 3a4d52d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 27 deletions.
28 changes: 1 addition & 27 deletions bin/coquelicot/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

COMMIT=$(git log --format="%h" -n 1)
TAG=$(git describe --all --exact-match $COMMIT)
BIN=coquelicot

cat > version.go << EOF
package main
Expand All @@ -15,29 +14,4 @@ const (
)
EOF

ARCH=amd64
OSLIST=$(uname -s|tr '[:upper:]' '[:lower:]')

if [ "$1" = "-a" ]; then
OSLIST="linux windows freebsd darwin"
fi

rm -f /tmp/$BIN*.zip

RTAG=$(git tag|tail -1)
if [ -z "$RTAG" ]; then
RTAG=$COMMIT
fi

for OS in $OSLIST; do
echo "Building for $OS ..."
TMP=/tmp/c$OS$ARCH
rm -rf $TMP
GOOS=$OS GOARCH=$ARCH go build -o $TMP/$BIN
if [ "$OS" = "windows" ]; then
mv $TMP/$BIN $TMP/$BIN.exe
fi
zip -j /tmp/$BIN-$RTAG-$OS-$ARCH.zip $TMP/$BIN* && rm -rf $TMP
done

rm -f version.go
go build && rm -f version.go
45 changes: 45 additions & 0 deletions bin/coquelicot/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

# Writes a version file with the latest git commit id
# and any tag associated with it.

COMMIT=$(git log --format="%h" -n 1)
TAG=$(git describe --all --exact-match $COMMIT)
BIN=coquelicot

cat > version.go << EOF
package main
const (
appVersion = "$COMMIT $TAG"
)
EOF

echo "(use -a to build for all platforms (go >= 1.5)"

ARCH=amd64
OSLIST=$(uname -s|tr '[:upper:]' '[:lower:]')

if [ "$1" = "-a" ]; then
OSLIST="linux windows freebsd darwin"
fi

rm -f /tmp/$BIN*.zip

RTAG=$(git tag|tail -1)
if [ -z "$RTAG" ]; then
RTAG=$COMMIT
fi

for OS in $OSLIST; do
echo "Building for $OS ..."
TMP=/tmp/c$OS$ARCH
rm -rf $TMP
GOOS=$OS GOARCH=$ARCH go build -o $TMP/$BIN
if [ "$OS" = "windows" ]; then
mv $TMP/$BIN $TMP/$BIN.exe
fi
zip -j /tmp/$BIN-$RTAG-$OS-$ARCH.zip $TMP/$BIN* && rm -rf $TMP
done

rm -f version.go

0 comments on commit 3a4d52d

Please sign in to comment.