Skip to content

Commit

Permalink
Compresses the binaries with gzip
Browse files Browse the repository at this point in the history
Changes in Makefile, travis.yml, and get.sh makes sure
that the binary sizes are drastically reduced for downloads.

Fixes inlets#30

Signed-off-by: Utsav Anand <[email protected]>
  • Loading branch information
utsavanand2 committed Feb 20, 2020
1 parent 7a4b69f commit 621cfa9
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 49 deletions.
39 changes: 21 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
sudo: required
language: go

go:
- 1.13.x

script:
- make dist

before_deploy:
- "./ci/hashgen.sh"

deploy:
provider: releases
api_key:
secure: aYgBmrFjqAzOBWncNQ2EKKFZJwOD2+l+a7Lll8+DVJkNyvLdzliI8iD4ro5KLEIwJjlghwM/Xy78O5oMlTPGoBf6IwbFE4nxKr0wlwFonSym5XCW2W7diGwxNvJUvBqY3wHjV13UpFNJVOqKbcaAVC+oGP6Wt4vNttroUaikpokwTfDXneksg5YIIemKkNXAvvWyRHrdOUgn8U8qLnaJ5gdpdcQOACsVXoI43ogsX49nSqXVIaBqt1Ndz+53Dsu7nSUwuwg0CnTYT05sU83RUhzRckvoE/l3mmd/FQBmVyDTfTwjrVwQLaKv2ldqlDmasV1qQ32bsEAfnGswbEZcJ0Qpx6VasAtDk69OW0RPyHs/VMw9BHVgoQyDaO2KGTKBJBBsewaIcJPBnWcDoGsv8oV/s/6tagqT+20zobGLqJfu3JxPlG7m+mC17NW8Fe9UslexyP9R1PgJfghGqQisDIrid9KixqfMpfTAqLykVGR3ra5NctKJEvpM2lyjLsxKxgzRAeIcd/i6Rt/eQX7lQAFQuP+Gq/hwxffFFUvUJPaBg5xk69S5QF6OrVof/LJjReE39u5z+q3O4f1auyZXSlE3ZNTWJEZ2DCuD5fLQm1b2O8sTAuK2HXnPr2gLvjUTO5QaRlQiVwxeYNcaMol42VFZ+XpBU+PQOuhSUmpqhOk=
secure: VedDISGwlkOhc/i8Z6zyfea/0+OpSfIbqxJzH6PyCli9WgTxAL2Ci1Ye6tFz2zO810RhhkZ43UAvqZu0MAZS+0WBetIN/wqCj2zD6vps8Cfe+UV5Xs3L34F9K4iNShy3Nkbz5t0ulN5OShocA4vQlWOCqklOOW7dgfDnsQcdXLMzFKdnrOa1B3FVNEynXXv5c7z6tPHftnJbJ2DrC+VQgRC1Npsez7IJnqo1b9IWEQCvE4E7u1IQtK5PuZ0ApeKTAwLTh5JHPbstjom3o086YQ+06aQtApp1jqi9hvF0edNgCKut+okQrveTwtDTPIsXknx+IJtcl0x32WeKcX7QbMfDFTFAqOTRsCDQWA/zHEHHKx6W0CAe5HIHiL5uIVijsRo/1y3FU2s+yu8odJXEQIDfmHGUJWmUiYWY4McMCsUzJ4GlXpfGR1ddKbwN6VoBfQt1eBbd8vMj2DaF4bWDkbKi9AJ+HTEGZmL6mJVBJgQ/ZNlenQp7YXiAL14CKSlmHuTg86rYIfgaj9NUSWeCTqNgG9n7ZBpg3ocZdpGJf55WtYJIOhbas9tNJsVM3iCRmFH0TMYgL1iYE4C+Mpa9vXOWYxtC3Dhb4ROHUmYiVMtcZ2x5H/9sTEG2gvg39tFgvISd/SffFx3Xpi06H0HDw4I85xGPeRkVLVnSzJSBh54=
provider: releases
file:
- ./bin/inletsctl
- ./bin/inletsctl-darwin
- ./bin/inletsctl-armhf
- ./bin/inletsctl-arm64
- ./bin/inletsctl.exe
- ./bin/inletsctl.sha256
- ./bin/inletsctl-darwin.sha256
- ./bin/inletsctl-armhf.sha256
- ./bin/inletsctl-arm64.sha256
- ./bin/inletsctl.exe.sha256
- "./bin/inletsctl.tgz"
- "./bin/inletsctl.sha256"
- "./bin/inletsctl.tgz.sha256"
- "./bin/inletsctl-darwin.tgz"
- "./bin/inletsctl-darwin.sha256"
- "./bin/inletsctl-darwin.tgz.sha256"
- "./bin/inletsctl-armhf.tgz"
- "./bin/inletsctl-armhf.sha256"
- "./bin/inletsctl-armhf.tgz.sha256"
- "./bin/inletsctl-arm64.tgz"
- "./bin/inletsctl-arm64.sha256"
- "./bin/inletsctl-arm64.tgz.sha256"
- "./bin/inletsctl.exe.tgz"
- "./bin/inletsctl.exe.sha256"
- "./bin/inletsctl.exe.tgz.sha256"
skip_cleanup: true
overwrite: true
on:
tags: true

env: GO111MODULE=on
env:
matrix:
- GO111MODULE=on
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ dist:
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/inletsctl-armhf
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/inletsctl-arm64
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags $(LDFLAGS) -a -installsuffix cgo -o bin/inletsctl.exe

echo "Compressing the compiled artifacts"
find bin -name "inletsctl*" -exec tar -cvzf {}.tgz {} \;
100 changes: 69 additions & 31 deletions get.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# This script was adapted from https://github.com/openfaas/cli.openfaas.com/blob/master/get.sh

export OWNER=inlets
export OWNER=utsavanand2
export REPO=inletsctl
export SUCCESS_CMD="$REPO version"
export BINLOCATION="/usr/local/bin"
Expand Down Expand Up @@ -34,19 +34,24 @@ getPackage() {
suffix=""
case $uname in
"Darwin")
suffix="-darwin"
suffix="-darwin.tgz"
;;
"Linux")
arch=$(uname -m)
echo $arch
case $arch in
"x86_64")
suffix=".tgz"
;;
esac
case $arch in
"aarch64")
suffix="-arm64"
suffix="-arm64.tgz"
;;
esac
case $arch in
"armv6l" | "armv7l")
suffix="-armhf"
suffix="-armhf.tgz"
;;
esac
;;
Expand All @@ -67,40 +72,73 @@ getPackage() {

curl -sSLf $url --output $targetFile

if [ "$?" = "0" ]; then

chmod +x $targetFile

echo "Download complete."
if [ $? -ne 0 ]; then
echo "Download Failed!"
exit 1
else
echo "Download Complete, Decompressing"
extractFolder=$(echo $targetFile | sed "s/${REPO}${suffix}//g")
tar -xvzf $targetFile -C $extractFolder
fi

if [ ! -w "$BINLOCATION" ]; then
if [ $? -ne 0 ]; then
echo "Failed to expand archve: $targetFile"
exit 1
else
echo "Binary Decompressed!"
rm $targetFile

echo
echo "============================================================"
echo " The script was run as a user who is unable to write"
echo " to $BINLOCATION. To complete the installation the"
echo " following commands may need to be run manually."
echo "============================================================"
echo
echo " sudo cp $REPO$suffix $BINLOCATION/$REPO"
echo
./$REPO$suffix version
else
# Get the parent dir of the 'bin' folder holding the binary
targetFile=$(echo $targetFile | sed "s+/${REPO}${suffix}++g")
suffix=$(echo $suffix | sed 's/.tgz//g')

echo
echo "Running with sufficient permissions to attempt to move $REPO to $BINLOCATION"
targetFile="${targetFile}/bin/${REPO}${suffix}"

mv $targetFile $BINLOCATION/$REPO
chmod +x $targetFile

if [ "$?" = "0" ]; then
echo "New version of $REPO installed to $BINLOCATION"
fi
# Calculate SHA
shaurl=$(echo $url | sed 's/.tgz/.sha256/g')
SHA256=$(curl -sLS $shaurl | awk '{print $1}')
echo "SHA256 fetched from release: $SHA256"
# NOTE to other maintainers
# There needs to be two spaces between the SHA and the file in the echo statement
# for shasum to compare the checksums
echo "$SHA256 $targetFile" | shasum -a 256 -c -s

if [ -e $targetFile ]; then
rm $targetFile
if [ $? -ne 0 ]; then
echo "SHA mismatch! This means there must be a problem with the download"
exit 1
else
echo "SHA match!"

if [ ! -w "$BINLOCATION" ]; then
echo
echo "============================================================"
echo " The script was run as a user who is unable to write"
echo " to $BINLOCATION. To complete the installation the"
echo " following commands may need to be run manually."
echo "============================================================"
echo
echo " sudo cp $REPO$suffix $BINLOCATION/$REPO"
echo
./$REPO$suffix version
else

echo
echo "Running with sufficient permissions to attempt to move $REPO to $BINLOCATION"

mv $targetFile $BINLOCATION/$REPO

if [ "$?" = "0" ]; then
echo "New version of $REPO installed to $BINLOCATION"
fi

if [ -e $targetFile ]; then
rm $targetFile
fi

${SUCCESS_CMD}
fi

${SUCCESS_CMD}
fi
fi
}
Expand Down

0 comments on commit 621cfa9

Please sign in to comment.