Skip to content

Commit

Permalink
Update install cli script docs (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren authored Aug 11, 2022
1 parent e1a283b commit 2eab071
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 70 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser-pro
distribution: goreleaser
version: latest
workdir: ./cli/
args: release --rm-dist -f ../.goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_LICENSE }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}

helm_chart_version_bump:
Expand Down
21 changes: 19 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ builds:
- linux
- windows
- darwin
goarch:
- "386"
- amd64
- arm
- arm64
goarm:
- "7"
archives:
- replacements:
386: i386
Expand All @@ -33,14 +40,24 @@ nfpms:
- id: tracetest
vendor: Kubeshop
homepage: https://tracetest.kubeshop.io/
maintainer: Sebastian Choren <[email protected]>
license: MIT
formats:
- deb
- rpm
replacements:
386: i386
furies:
- account: tracetest
deb:
lintian_overrides:
- statically-linked-binary

publishers:
- name: fury.io
env:
- 'FURY_TOKEN={{ .Env.FURY_TOKEN }}'
# relative to cli/, where goreleaser runs from
cmd: ../scripts/fury-upload.sh {{ .ArtifactName }}

brews:
- tap:
owner: kubeshop
Expand Down
42 changes: 39 additions & 3 deletions docs/installing.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,55 @@ helm delete tracetest
```

## CLI Installation
Every time we release a new version of Tracetest, we generate binaries for Linux, MacOS, and Windows. Supporting both amd64, and ARM64 architectures. You can find the latest version [here](https://github.com/kubeshop/tracetest/releases/latest).
Every time we release a new version of Tracetest, we generate binaries for Linux, MacOS, and Windows. Supporting both amd64, and ARM64 architectures, in `tar.gz`, `deb`, `rpm` and `exe` formats
You can find the latest version [here](https://github.com/kubeshop/tracetest/releases/latest).

### Linux
### Linux/MacOS

Tracetest CLI can be installed automatically using the following script:
```sh
curl -L https://raw.githubusercontent.com/kubeshop/tracetest/main/install-cli.sh | bash
```

### MacOS
It works for systems with Hombrew, `apt-get`, `dpkg`, `yum`, `rpm` installed, and if no package manager is available, it will try to download the build and install it manually.

You can also manually install with one of the following methods

#### Homebrew

```sh
brew install kubeshop/tracetest/tracetest
```

#### apt

```sh
# requirements for our deb repo to work
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates

# add repo
echo "deb [trusted=yes] https://apt.fury.io/tracetest/ /" | sudo tee /etc/apt/sources.list.d/fury.list

# update and install
sudo apt-get update
sudo apt-get install tracetest
```

#### yum

```sh
# add repository
cat <<EOF | $SUDO tee /etc/yum.repos.d/tracetest.repo
[tracetest]
name=Tracetest
baseurl=https://yum.fury.io/tracetest/
enabled=1
gpgcheck=0
EOF

# install
sudo yum install tracetest --refresh
```

### Windows
Download one of the files from the latest tag, extract to your machine, and then [add the tracetest binary to your PATH variable](https://stackoverflow.com/a/41895179)
155 changes: 92 additions & 63 deletions install-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,112 +5,141 @@ cmd_exists() {
}

ensure_dependency_exist() {
if ! cmd_exists $1; then
echo "missing dependency: $1 is required to run this script"
exit 2
fi
}

ensure_required_dependencies_are_present() {
ensure_dependency_exist "curl"
ensure_dependency_exist "uname"
if ! cmd_exists $1; then
echo "missing dependency: $1 is required to run this script"
exit 2
fi
}

get_latest_version() {
ensure_dependency_exist "curl"

curl --silent "https://api.github.com/repos/kubeshop/tracetest/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}


get_os() {
os_name=`uname | tr '[:upper:]' '[:lower:]'`
echo $os_name
os_name=`uname | tr '[:upper:]' '[:lower:]'`
echo $os_name
}

get_arch() {
arch=`uname -p`
if [ "x86_64" == "$arch" ]; then
echo "amd64"
elif [ "arm" == "$arch" ]; then
echo "arm64"
else
echo "$arch"
fi
arch=$(uname -p)
case "$arch" in
"x86_64")
echo "amd64"
;;

"arm"|"aarch64")
echo "arm64"
;;

*)
echo ""
;;
esac
}

get_download_link() {
os=$1
arch=$2
version=$3
pkg=$4
raw_version=`echo $version | sed 's/v//'`
os=$(get_os)
version=$(get_latest_version)
arch=$(get_arch)
raw_version=`echo $version | sed 's/v//'`
pkg=$1

echo "https://github.com/kubeshop/tracetest/releases/download/${version}/tracetest_${raw_version}_${os}_${arch}.${pkg}"
echo "https://github.com/kubeshop/tracetest/releases/download/${version}/tracetest_${raw_version}_${os}_${arch}.${pkg}"
}

download_file() {
file=$1
path=$2
file=$1
path=$2

echo "Downloading $file and saving to $path"
echo "Downloading $file and saving to $path"

curl -L "$file" --output "$path"
echo "File downloaded and saved to $path"
curl -L "$file" --output "$path"
echo "File downloaded and saved to $path"
}

install_tar() {
download_link=$1
ensure_dependency_exist "curl"
ensure_dependency_exist "tar"

download_link=$(get_download_link "tar.gz")
file_path="/tmp/cli.tar.gz"
download_file "$download_link" "$file_path"

tar -xvf $compressed_file_path -C /tmp
sudo mv /tmp/tracetest /usr/local/bin/tracetest
tar -xvf $file_path -C /tmp
$SUDO mv /tmp/tracetest /usr/local/bin/tracetest
rm -f $file_path
}

install_dpkg() {
download_link=$1
download_link=$(get_download_link "deb")
file_path="/tmp/cli.deb"
download_file "$download_link" "$file_path"

sudo dpkg -i $file_path
$SUDO dpkg -i $file_path
rm -f $file_path
}

install_rpm() {
download_link=$1
download_link=$(get_download_link "rpm")
file_path="/tmp/cli.rpm"
download_file "$download_link" "$file_path"

sudo rpm -i $file_path
$SUDO rpm -i $file_path
rm -f $file_path
}

run() {
ensure_required_dependencies_are_present
install_apt() {
$SUDO apt-get update
$SUDO apt-get install -y apt-transport-https ca-certificates
echo "deb [trusted=yes] https://apt.fury.io/tracetest/ /" | $SUDO tee /etc/apt/sources.list.d/fury.list
$SUDO apt-get update
$SUDO apt-get install -y tracetest
}

os=$(get_os)
if [ "$os" != "linux" ]; then
echo $os 'OS not supported by this script. See https://kubeshop.github.io/tracetest/installing/#cli-installation'
exit 1
fi
install_yum() {
cat <<EOF | $SUDO tee /etc/yum.repos.d/tracetest.repo
[tracetest]
name=Tracetest
baseurl=https://yum.fury.io/tracetest/
enabled=1
gpgcheck=0
EOF
$SUDO yum install -y tracetest --refresh
}

latest_version=`get_latest_version`
arch=`get_arch`

if cmd_exists dpkg; then
download_link=`get_download_link $os $arch $latest_version deb`
echo
echo
echo $download_link
echo
echo
install_dpkg $download_link
elif cmd_exists rpm; then
download_link=`get_download_link $os $arch $latest_version rpm`
install_rpm $download_link
else
download_link=`get_download_link $os $arch $latest_version tar.gz`
install_tar $download_link
run() {
os=$(get_os)

ensure_dependency_exist "uname"
if cmd_exists apt-get; then
install_apt
elif cmd_exists yum; then
install_yum
elif cmd_exists dpkg; then
install_dpkg
elif cmd_exists rpm; then
install_rpm
elif [ "$os" = "linux" ]; then
if [ "$(get_arch)" == "unknown" ]; then
echo "unknown system architecture. Try manual install. See https://kubeshop.github.io/tracetest/installing/#cli-installation"
exit 1;
fi
install_tar
else
echo 'OS not supported by this script. See https://kubeshop.github.io/tracetest/installing/#cli-installation'
exit 1
fi
}

SUDO=""
if [ `id -un` != "root" ]; then
ensure_dependency_exist "sudo"
SUDO="sudo"
fi

run
12 changes: 12 additions & 0 deletions scripts/fury-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e
if [ "${1: -4}" == ".deb" ] || [ "${1: -4}" == ".rpm" ]; then
cd dist
echo "uploading $1"
status="$(curl -s -q -o /dev/null -w "%{http_code}" -F package="@$1" "https://$FURY_TOKEN@push.fury.io/tracetest/")"
echo "got: $status"
if [ "$status" == "200" ] || [ "$status" == "409" ]; then
exit 0
fi
exit 1
fi

0 comments on commit 2eab071

Please sign in to comment.