This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from kshlm/release-scripts
Add scripts to build and release GD2
- Loading branch information
Showing
4 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ vendor/ | |
_builds/ | ||
_steps/ | ||
_projects/ | ||
# Ignore build and release directories | ||
build/ | ||
releases/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
## This scripts builds a GD2 binary and places it in the given path | ||
## Should be called from the root of the GD2 repo as | ||
## ./scripts/build.sh [<path-to-output-directory>] | ||
## If no path is given, defaults to build | ||
|
||
OUTDIR=build | ||
if [ "x$1" != "x" ]; then | ||
OUTDIR=$1 | ||
fi | ||
|
||
VERSION=$($(dirname $0)/pkg-version --full) | ||
LDFLAGS="-X github.com/gluster/glusterd2/gdctx.GlusterdVersion=$VERSION" | ||
BIN=$(basename $(go list -f '{{.ImportPath}}')) | ||
|
||
echo "Building $BIN $VERSION" | ||
go build -ldflags "${LDFLAGS}" -o $OUTDIR/$BIN || exit 1 | ||
echo "Built $BIN $VERSION at $OUTDIR/$BIN" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
|
||
## This script builds a GlusterD-2.0 binary and creates an archive, and then signs it. | ||
## Should be called from the root of the GD2 repo | ||
|
||
VERSION=$($(dirname $0)/pkg-version --full) | ||
OS=$(go env GOOS) | ||
ARCH=$(go env GOARCH) | ||
BIN=$(basename $(go list -f '{{.ImportPath}}')) | ||
|
||
RELEASEDIR=releases/$VERSION | ||
TAR=$RELEASEDIR/$BIN-$VERSION-$OS-$ARCH.tar | ||
ARCHIVE=$TAR.xz | ||
|
||
if [ -e $ARCHIVE ]; then | ||
echo "Release archive $ARCHIVE exists." | ||
echo "Do you want to clean and start again?(y/N)" | ||
read answer | ||
case "$answer" in | ||
y|Y) | ||
echo "Cleaning previously built release" | ||
rm -rf $RELEASEDIR | ||
echo | ||
;; | ||
*) | ||
exit 0 | ||
;; | ||
esac | ||
fi | ||
|
||
mkdir -p $RELEASEDIR | ||
|
||
echo "Making GlusterD-2.0 release $VERSION" | ||
echo | ||
|
||
# Build GD2 into the release directory | ||
$(dirname $0)/build.sh $RELEASEDIR || exit 1 | ||
echo | ||
|
||
# Create release archive | ||
echo "Creating release archive" | ||
tar -cf $TAR -C $RELEASEDIR $BIN || exit 1 | ||
xz $TAR || exit 1 | ||
echo "Created release archive $RELEASEDIR/$ARCHIVE" | ||
echo | ||
|
||
# Sign the tarball | ||
# Requires that a default gpg key be set up | ||
echo "Signing archive" | ||
SIGNFILE=$ARCHIVE.asc | ||
gpg --armor --output $SIGNFILE --detach-sign $ARCHIVE || exit 1 | ||
echo "Signed archive, signature in $SIGNFILE" |