-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
7 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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Import GPG key | ||
gpg --import "$TRAVIS_BUILD_DIR/dist/gpg_key.priv" | ||
echo -e '%_gpg_name Jiri Tyr (PKG) <[email protected]>\n%dist .el7' > ~/.rpmmacros | ||
|
||
# Create RPM infrastructure | ||
mkdir -p ~/rpmbuild/SOURCES | ||
echo -e '#!/usr/bin/expect -f\nspawn rpmsign --key-id CA67951CD2BBE8AAE4210B72FB90C91F64BED28C --addsign {*}$argv\nexpect -exact "Enter pass phrase: "\nsend -- "\\r"\nexpect eof' > ~/rpm-sign.exp | ||
chmod +x ~/rpm-sign.exp | ||
|
||
# Archs to build for | ||
declare -a PLATFORMS=( | ||
'darwin/amd64' | ||
'linux/amd64' | ||
|
@@ -11,11 +21,10 @@ declare -a PLATFORMS=( | |
NAME='gbt' | ||
VER="${TRAVIS_TAG:1}" | ||
TMP="/tmp/$NAME" | ||
rm -fr "$TMP" | ||
|
||
gpg --import "$TRAVIS_BUILD_DIR/dist/gpg_key.priv" | ||
echo -e '%_gpg_name Jiri Tyr (PKG) <[email protected]>\n%dist .el7' > ~/.rpmmacros | ||
rm -fr "$TMP" | ||
|
||
# Process build for each arch | ||
for P in "${PLATFORMS[@]}"; do | ||
echo "### Building $P" | ||
|
||
|
@@ -27,6 +36,7 @@ for P in "${PLATFORMS[@]}"; do | |
|
||
mkdir -p "$PTMP" | ||
|
||
# Compile GBT | ||
if [ "$ARCH" == "$ARM" ]; then | ||
GOOS="$OS" GOARCH="$ARCH" CGO_ENABLED=0 go build -ldflags='-s -w' -o "$PTMP/$NAME" github.com/jtyr/gbt/cmd/gbt | ||
else | ||
|
@@ -36,12 +46,14 @@ for P in "${PLATFORMS[@]}"; do | |
GOOS="$OS" GOARCH="$ARCH" GOARM="$ARM" CGO_ENABLED=0 go build -ldflags='-s -w' -o "$PTMP/$NAME" github.com/jtyr/gbt/cmd/gbt | ||
fi | ||
|
||
# Create .tar.gz package | ||
( | ||
cp -r "$TRAVIS_BUILD_DIR"/{README.md,LICENSE,themes,sources} "$PTMP" | ||
tar -C "$PTMP/.." -czf "$TMP/$PKG" ./ | ||
cd "$TMP" | ||
) | ||
|
||
# Create Linux distro packages | ||
if [ "$OS" = 'linux' ]; then | ||
# DEB | ||
( | ||
|
@@ -54,7 +66,8 @@ for P in "${PLATFORMS[@]}"; do | |
fi | ||
|
||
cd "$TRAVIS_BUILD_DIR/contrib" | ||
ln -sf "$PTMP" "$TRAVIS_BUILD_DIR/contrib/$NAME" | ||
rm -f "$TRAVIS_BUILD_DIR/contrib/$NAME" | ||
ln -s "$PTMP" "$TRAVIS_BUILD_DIR/contrib/$NAME" | ||
m4 -DVER="$VER" -DDATE="$(date '+%a, %d %b %Y %H:%M:%S %z')" debian/changelog.m4 > debian/changelog | ||
dpkg-buildpackage -a$DEBARCH -tc -b -kCA67951CD2BBE8AAE4210B72FB90C91F64BED28C | ||
) | ||
|
@@ -63,20 +76,18 @@ for P in "${PLATFORMS[@]}"; do | |
|
||
# RPM | ||
if [ "$ARCH" = 'amd64' ]; then | ||
mkdir -p ~/rpmbuild/SOURCES | ||
ln -sf "$TMP/$PKG" ~/rpmbuild/SOURCES/ | ||
( | ||
cd "$TRAVIS_BUILD_DIR/contrib/redhat" | ||
m4 -DVER="$VER" -DDATE="$(date '+%a %b %d %Y')" gbt.spec.m4 > gbt.spec | ||
rpmbuild -bb gbt.spec | ||
) | ||
echo -e '#!/usr/bin/expect -f\nspawn rpmsign --key-id CA67951CD2BBE8AAE4210B72FB90C91F64BED28C --addsign {*}$argv\nexpect -exact "Enter pass phrase: "\nsend -- "\\r"\nexpect eof' > ~/rpm-sign.exp | ||
chmod +x ~/rpm-sign.exp | ||
~/rpm-sign.exp ~/rpmbuild/RPMS/x86_64/*.rpm | ||
mv ~/rpmbuild/RPMS/x86_64/*.rpm "$TMP" | ||
fi | ||
fi | ||
done | ||
|
||
# Create checksums | ||
cd "$TMP" | ||
sha256sum *.tar.gz *.deb *.rpm | sort -k2 > "$NAME-$VER-checksums-sha256.txt" |