From 78a889490954931745d26bbebfb8f2684a1c33a7 Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Wed, 24 Jan 2018 23:53:54 +0000 Subject: [PATCH] Re-organizing the build script --- dist/build.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/dist/build.sh b/dist/build.sh index 7baa49a..67e4900 100755 --- a/dist/build.sh +++ b/dist/build.sh @@ -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) \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) \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"