Skip to content

Commit

Permalink
feat: archive binaries in builds for faster downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Oct 20, 2020
1 parent e77b7b2 commit 42e92f6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"github": {
"release": true,
"releaseName": "Release v${version}",
"assets": ["./bin/vim-doge-*"]
"assets": ["./bin/vim-doge-*.tar.gz"]
},
"plugins": {
"@release-it/conventional-changelog": {
Expand Down
15 changes: 14 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@
set -e
set -u

ROOT_DIR="$(cd "$(dirname "$0")"; pwd -P)/.."
ROOT_DIR=$(realpath "$(cd "$(dirname "$0")"; pwd -P)/..")

# Build the pkg lib prerequisites if needed.
if [[ ! -d $ROOT_DIR/pkg/lib-es5 ]]; then
cd $ROOT_DIR/pkg
npm install --no-save && npm run prepare
fi

cd $ROOT_DIR

# Build the binaries.
BUILD_TARGETS="node14-linux-x64,node14-macos-x64,node14-win-x64"
node $ROOT_DIR/pkg/lib-es5/bin.js . -t "$BUILD_TARGETS" --out-path $ROOT_DIR/bin
chmod +x $ROOT_DIR/bin/vim-doge*

# Archive the binaries.
cd $ROOT_DIR/bin
rm -f $ROOT_DIR/bin/vim-doge-{linux,macos,win.exe}.tar.gz
for file in ./vim-doge-{linux,macos,win.exe}; do
filename=$(basename "$file")
echo "==> Archiving $filename -> $filename.tar.gz"
tar -czf $filename.tar.gz "$filename" > /dev/null 2>&1
done

echo "🎉 Done building vim-doge binaries"
20 changes: 12 additions & 8 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [[ -e ./bin/vim-doge ]]; then
fi


ROOT_DIR="$(cd "$(dirname "$0")"; pwd -P)/.."
ROOT_DIR=$(realpath "$(cd "$(dirname "$0")"; pwd -P)/.."
cd $ROOT_DIR
mkdir ./bin
Expand All @@ -21,17 +21,21 @@ PKG_VERSION=$(cat "$ROOT_DIR/.version")
RELEASE_URL="https://github.com/kkoomen/vim-doge/releases/download/$PKG_VERSION"
if [[ $OS == 'Darwin' ]]; then
VIM_DOGE_EXECUTABLE_URL="$RELEASE_URL/vim-doge-macos"
TARGET="vim-doge-macos"
elif [[ $OS == 'Linux' ]]; then
VIM_DOGE_EXECUTABLE_URL="$RELEASE_URL/vim-doge-linux"
TARGET="vim-doge-linux"
else
VIM_DOGE_EXECUTABLE_URL="$RELEASE_URL/vim-doge-win.exe"
TARGET="vim-doge-win.exe"
OUTFILE="$OUTFILE.exe"
fi
echo "Downloading $VIM_DOGE_EXECUTABLE_URL"
TEMP_FILE="vim-doge.tar.gz"
DOWNLOAD_URL="$RELEASE_URL/$TARGET.tar.gz"
echo "Downloading $DOWNLOAD_URL"
curl -L --progress-bar \
--fail \
--output "$OUTFILE" \
$VIM_DOGE_EXECUTABLE_URL
chmod +x $OUTFILE
--output "$TEMP_FILE" \
"$DOWNLOAD_URL"
tar xzf "$TEMP_FILE" && mv "$TARGET" "$OUTFILE"
rm -f "$TEMP_FILE"
chmod +x "$OUTFILE"

0 comments on commit 42e92f6

Please sign in to comment.