-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version flag and installation script (#14)
- Loading branch information
1 parent
e97273a
commit fd499a4
Showing
4 changed files
with
63 additions
and
6 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 |
---|---|---|
|
@@ -43,7 +43,8 @@ jobs: | |
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV | ||
- name: Build | ||
run: | | ||
go build -o snd-${{ matrix.os }}-${{ matrix.arch }} ./cmd/snd-cli | ||
version=$(git describe --tags --abbrev=7) | ||
go build -o snd-${{ matrix.os }}-${{ matrix.arch }} ./cmd/snd-cli -ldflags="-X 'github.com/SneaksAndData/snd-cli-go/blob/main/cmd/snd-cli/main.version=$version'" | ||
- name: Import Secrets | ||
uses: hashicorp/[email protected] | ||
with: | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
# Installation script for SnD CLI | ||
echo "Determining target OS and architecture..." | ||
ARCH=$(uname -m) | ||
if [[ "$OSTYPE" =~ ^darwin && "$ARCH" =~ arm64 ]]; then | ||
bin_name=snd-darwin-arm64 | ||
elif [[ "$OSTYPE" =~ ^linux ]]; then | ||
if [[ "$ARCH" =~ arm64 ]]; then | ||
bin_name=snd-linux-arm64 | ||
elif [[ "$ARCH" =~ amd64 ]]; then | ||
bin_name=snd-linux-amd64 | ||
elif [[ "$OSTYPE" =~ ^linux && "$ARCH" =~ amd64 ]]; then | ||
bin_name=snd-windows-amd64 | ||
fi | ||
else | ||
echo "Error: Unsupported OS type or architecture: $OSTYPE $ARCH " | ||
exit 1 | ||
fi | ||
echo "Target OS: $OSTYPE" | ||
echo "Target ARCH: $ARCH" | ||
|
||
BUNDLE_URL="https://esddatalakeproduction.blob.core.windows.net/dist/snd-cli-go/$bin_name" | ||
|
||
# Define base path for the application | ||
base_path="$HOME/.local/snd-cli" | ||
mkdir -p "$base_path" | ||
|
||
# Check if az cli is installed | ||
echo "Check if Azure CLI is installed..." | ||
if ! command -v az &> /dev/null | ||
then | ||
echo "az cli is not installed. Please install it from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli" | ||
exit | ||
fi | ||
|
||
# Login into azure | ||
echo "Please log in to Azure..." | ||
az login | ||
|
||
echo "Downloading the binary from $BUNDLE_URL" | ||
# Get file | ||
az storage blob download --blob-url $BUNDLE_URL --auth-mode login --file "$base_path/$bin_name" | ||
|
||
chmod +x "$base_path/$bin_name" | ||
|
||
if [ -e "$HOME/.local/bin/snd" ]; then | ||
echo "Removing symlink..." | ||
rm $HOME/.local/bin/snd | ||
fi | ||
|
||
# Create a symbolic link to the application | ||
echo "Creating the symlink..." | ||
ln -s "$base_path/$bin_name" "$HOME/.local/bin/snd" | ||
|
||
echo "Please restart your terminal for the changes to take effect." | ||
echo "After restarting, you can try running 'snd --help'. :)" |
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