-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (87 loc) · 2.59 KB
/
install.sh
File metadata and controls
executable file
·103 lines (87 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
# Artifact Keeper CLI installer
# Usage: curl -fsSL https://raw.githubusercontent.com/artifact-keeper/artifact-keeper-cli/main/install.sh | sh
set -e
REPO="artifact-keeper/artifact-keeper-cli"
BINARY_NAME="ak"
# Detect OS
OS="$(uname -s)"
case "$OS" in
Linux*) OS_NAME="linux";;
Darwin*) OS_NAME="darwin";;
MINGW*|MSYS*|CYGWIN*) OS_NAME="windows";;
*)
echo "Error: Unsupported operating system: $OS" >&2
exit 1
;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64|amd64) ARCH_NAME="amd64";;
aarch64|arm64) ARCH_NAME="arm64";;
*)
echo "Error: Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
# Determine artifact name
if [ "$OS_NAME" = "windows" ]; then
ARTIFACT="ak-${OS_NAME}-${ARCH_NAME}.exe"
else
ARTIFACT="ak-${OS_NAME}-${ARCH_NAME}"
fi
# Get latest release tag
echo "Detecting latest release..."
LATEST_TAG=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
if [ -z "$LATEST_TAG" ]; then
echo "Error: Could not determine latest release" >&2
exit 1
fi
echo "Latest release: ${LATEST_TAG}"
# Download binary and checksum
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST_TAG}/${ARTIFACT}"
CHECKSUM_URL="${DOWNLOAD_URL}.sha256"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
echo "Downloading ${ARTIFACT}..."
curl -fsSL "$DOWNLOAD_URL" -o "${TMPDIR}/${ARTIFACT}"
curl -fsSL "$CHECKSUM_URL" -o "${TMPDIR}/${ARTIFACT}.sha256"
# Verify checksum
echo "Verifying checksum..."
cd "$TMPDIR"
if command -v sha256sum > /dev/null 2>&1; then
sha256sum -c "${ARTIFACT}.sha256"
elif command -v shasum > /dev/null 2>&1; then
shasum -a 256 -c "${ARTIFACT}.sha256"
else
echo "Error: No checksum tool found (sha256sum or shasum required)" >&2
exit 1
fi
cd - > /dev/null
# Determine install directory
INSTALL_DIR="/usr/local/bin"
if [ ! -w "$INSTALL_DIR" ] 2>/dev/null; then
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "$INSTALL_DIR"
fi
# Install
echo "Installing to ${INSTALL_DIR}/${BINARY_NAME}..."
cp "${TMPDIR}/${ARTIFACT}" "${INSTALL_DIR}/${BINARY_NAME}"
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
echo ""
echo "Artifact Keeper CLI (${LATEST_TAG}) installed to ${INSTALL_DIR}/${BINARY_NAME}"
# Check if install dir is in PATH
case ":$PATH:" in
*":${INSTALL_DIR}:"*) ;;
*)
echo ""
echo "Note: ${INSTALL_DIR} is not in your PATH."
echo "Add it with: export PATH=\"${INSTALL_DIR}:\$PATH\""
;;
esac
echo ""
echo "Get started:"
echo " ak instance add myserver https://your-registry.example.com"
echo " ak auth login"
echo " ak repo list"