Skip to content

Commit

Permalink
fix: upload clis (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostbean authored Jul 9, 2024
1 parent 05b54eb commit dfff91b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 28 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ jobs:

- name: Build cli
run: |
path=$(nix build ./#cross-compiled-cli.x86_64-linux.${{ matrix.os }}.${{ matrix.arch }} --no-link --print-out-paths)
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}"
ln -s $path/bin/${{ matrix.os }}_${{ matrix.arch }}/kardinal.cli $binout
result=$(nix build ./#cross-compiled-cli.x86_64-linux.${{ matrix.os }}.${{ matrix.arch }} --no-link --print-out-paths)
path=$(find $result -name 'kardinal.cli*' -type f | head -n 1)
if [[ "${{ matrix.os }}" == "windows" ]]; then
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}.exe"
else
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}"
fi
ls -lah $path
ln -s $path $binout
ls -lah $binout
[ -s $binout ]
15 changes: 11 additions & 4 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
path=$(nix build ./#cross-compiled-cli.x86_64-linux.${{ matrix.os }}.${{ matrix.arch }} --no-link --print-out-paths)
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}"
ln -s $path/bin/${{ matrix.os }}_${{ matrix.arch }}/kardinal.cli $binout
gh release upload ${{ needs.release-please.outputs.tag_name }} $binout
result=$(nix build ./#cross-compiled-cli.x86_64-linux.${{ matrix.os }}.${{ matrix.arch }} --no-link --print-out-paths)
path=$(find $result -name 'kardinal.cli*' -type f | head -n 1)
if [[ "${{ matrix.os }}" == "windows" ]]; then
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}.exe"
else
binout="/tmp/kardinal-${{ matrix.os }}-${{ matrix.arch }}"
fi
ls -lah $path
ln -s $path $binout
ls -lah $binout
gh release upload ${{ needs.release-please.outputs.tag_name }} $binout --clobber
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

Kardinal is a traffic control and data isolation layer that enables engineers to safely do development and QA work directly in production. Say goodbye to maintaining multiple environments and hello to faster, more efficient development workflows.

## Quick install

```bash
curl https://raw.githubusercontent.com/kurtosis-tech/kardinal/main/scripts/install_cli.sh -s | sh
```

## What is Kardinal?

Kardinal injects production data and service dependencies into your dev and test workflows safely and securely. Instead of spinning up ephemeral environments with mocked services, fake traffic, and fake data, developers using Kardinal can put their service directly into the production environment to see how it works... without risking the stability of that environment.
Expand Down Expand Up @@ -279,4 +285,3 @@ gomod2nix generate
<!--------------- ONLY LINKS BELOW THIS POINT ---------------------->
[run-build-cli]: #running-kardinal-cli
53 changes: 33 additions & 20 deletions scripts/install_cli.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
#!/bin/sh

set -e

REPO="kurtosis-tech/kardinal"
BINARY_NAME="kardinal"
Expand All @@ -14,37 +16,48 @@ elif [[ "$ARCH" == "aarch64" ]]; then
ARCH="arm64"
fi

BIN_FOLDER="$HOME/.local/bin"
mkdir -p $BIN_FOLDER

LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

echo "Downloading $BINARY_NAME $LATEST_RELEASE for $OS $ARCH..."
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_RELEASE/${BINARY_NAME}-${OS}-${ARCH}"
curl -L $DOWNLOAD_URL -o /tmp/${BINARY_NAME}
curl -L $DOWNLOAD_URL -o /$BIN_FOLDER/$BINARY_NAME
chmod +x $BIN_FOLDER/$BINARY_NAME

BIN_FOLDER="$HOME/.local/bin"
mkdir -p $BIN_FOLDER
USER_SHELL=$(basename $SHELL)
echo "Detected shell: $USER_SHELL"

handle_error() {
local exit_code=$?
echo "Ops! Failed to setup integration with your $USER_SHELL shell. Please add the following lines to
your shell configuration manually (changes may not be persistent)
export PATH=\$PATH:$BIN_FOLDER
source <($BIN_FOLDER/$BINARY_NAME completion $USER_SHELL)"
exit $exit_code
}

mv /tmp/$BINARY_NAME $BIN_FOLDER/$BINARY_NAME
trap 'handle_error' ERR

if [ -f $BIN_FOLDER/$BINARY_NAME ]; then
if [ -d /usr/share/bash-completion/completions ]; then
source $($BIN_FOLDER/$BINARY_NAME completion bash)
if [ $USER_SHELL == 'bash' ]; then
echo "export PATH=\$PATH:$BIN_FOLDER" >>~/.bashrc
echo "source <($BIN_FOLDER/$BINARY_NAME completion bash)" >>~/.bashrc
source ~/.bashrc
fi

if [ -d ~/.zsh/completions ]; then
source $($BIN_FOLDER/$BINARY_NAME completion zsh)
if [ $USER_SHELL == 'zsh' ]; then
echo "export PATH=\$PATH:$BIN_FOLDER" >>~/.zshrc
echo "source <($BIN_FOLDER/$BINARY_NAME completion zsh)" >>~/.bashrc
source ~/.zshrc
fi

if [ -d ~/.config/fish/completions ]; then
source $($BIN_FOLDER/$BINARY_NAME completion fish)
if [ $USER_SHELL == 'fish' ]; then
echo "set -gx PATH \$PATH $BIN_FOLDER" >>~/.config/fish/config.fish
echo "source <($BIN_FOLDER/$BINARY_NAME completion fish)" >>~/.bashrc
source ~/.config/fish/config.fish
fi
fi

echo "$BINARY_NAME has been installed successfully!"

if ! command -v $BINARY_NAME &>/dev/null; then
echo "export PATH=\$PATH:$BIN_FOLDER" >>~/.bashrc
source ~/.bashrc
echo "export PATH=\$PATH:$BIN_FOLDER" >>~/.zshrc
source ~/.zshrc
echo "set -gx PATH \$PATH $BIN_FOLDER" >>~/.config/fish/config.fish
source ~/.config/fish/config.fish
fi

0 comments on commit dfff91b

Please sign in to comment.