Skip to content

Commit

Permalink
build: zip binaries on release
Browse files Browse the repository at this point in the history
  • Loading branch information
henryhale committed Jan 6, 2025
1 parent 76faefb commit 2399df3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
generate_release_notes: true
files: |
depgraph-*
depgraph-*.zip
checksum.sha.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ cibuild () {
GOARCH="$2"
EXT=""

BINARY_NAME="depgraph-$GOOS-$GOARCH$EXT"

if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi

go build -ldflags "-X main.version=$VERSION" -o "depgraph-$GOOS-$GOARCH$EXT" depgraph.go
go build -ldflags "-X main.version=$VERSION" -o "$BINARY_NAME" depgraph.go

zip -m $BINARY_NAME{.zip,}
}

if [ "$CI" = "ci" ]; then
Expand Down
24 changes: 18 additions & 6 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ echo "depgraph: installing executable..."
# detect os and architecture
echo "depgraph: detecting system architecture..."

OS=$(uname | tr '[:upper:]' '[:lower:]')
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

if [ "$OS" != "linux" -1 "$OS" != "darwin"]; then
echo "depgraph: error: unsupported operating system"
exit 1
fi

if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "aarch64" ]; then
Expand All @@ -20,7 +25,7 @@ else
fi

# download binary
BIN_URL="https://github.com/henryhale/depgraph/releases/latest/download/depgraph-${OS}-${ARCH}"
BIN_URL="https://github.com/henryhale/depgraph/releases/latest/download/depgraph-${OS}-${ARCH}.zip"

DEST_DIR="/usr/local/bin"

Expand All @@ -29,11 +34,18 @@ if [ "$OS" == "linux" ] && [ -n "$PREFIX" ]; then
DEST_DIR="$PREFIX/bin"
fi

# fetch
BINARY_PATH="$DEST_DIR/depgraph"

# fetch binary
echo "depgraph: downloading binary..."
curl -L "$BIN_URL" -o "$BINARY_PATH.zip"
unzip -o "$BINARY_PATH.zip"

echo "depgraph: making binary executable..."
chmod +x "$BINARY_PATH"

curl -L "$BIN_URL" -o "$DEST_DIR/depgraph"
chmod +x "$DEST_DIR/depgraph"
# clean up
rm -f "$BINARY_PATH.zip"

echo "depgraph: successfully installed at $DEST_DIR/depgraph"
echo "depgraph: successfully installed at $BINARY_PATH"
echo -e "\ntry it now:\n\t$ depgraph -h"

0 comments on commit 2399df3

Please sign in to comment.