Skip to content

Commit d4c81d2

Browse files
committed
Create install.sh (#189)
1 parent 67566aa commit d4c81d2

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

Diff for: .github/workflows/go.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ jobs:
2222
go-version-file: "go.mod"
2323
- name: Lint
2424
run: make lint
25+
installer:
26+
name: installer
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Install
30+
run: curl -sSL https://raw.githubusercontent.com/bakito/toolbox/${GITHUB_SHA}/install.sh | sh
31+
- name: Run binary
32+
run: $HOME/bin/toolbox --version
2533
test:
2634
name: test
2735
runs-on: ubuntu-latest

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
🧰 A little toolbox to help fetching tools
77

8+
## Installation
9+
10+
### Linux
11+
12+
```bash
13+
curl -sSL https://raw.githubusercontent.com/bakito/toolbox/refs/heads/main/install.sh | sh
14+
```
15+
816
## Fetch tools
917

1018
```text

Diff for: install.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Define variables
5+
REPO="bakito/toolbox"
6+
INSTALL_DIR="$HOME/bin"
7+
BIN_NAME="toolbox"
8+
9+
# Ensure the installation directory exists
10+
mkdir -p "$INSTALL_DIR"
11+
12+
# Get the latest release tag
13+
LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | cut -d '"' -f 4)
14+
15+
# Construct download URL
16+
17+
ARCHIVE_NAME="${BIN_NAME}_${LATEST_TAG#v}_linux_amd64.tar.gz"
18+
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/$ARCHIVE_NAME"
19+
20+
# Temporary directory for extraction
21+
TMP_DIR=$(mktemp -d)
22+
23+
# Download the archive
24+
echo "Downloading $BIN_NAME version $LATEST_TAG..."
25+
curl -L "$DOWNLOAD_URL" -o "$TMP_DIR/$ARCHIVE_NAME"
26+
27+
# Extract the archive
28+
tar -xzf "$TMP_DIR/$ARCHIVE_NAME" -C "$TMP_DIR"
29+
30+
# Move the binary to the install directory
31+
mv "$TMP_DIR/$BIN_NAME" "$INSTALL_DIR/"
32+
33+
# Make it executable
34+
chmod +x "$INSTALL_DIR/$BIN_NAME"
35+
36+
# Clean up
37+
rm -rf "$TMP_DIR"
38+
39+
# Print success message
40+
echo "$BIN_NAME installed successfully to $INSTALL_DIR"
41+
echo "Add $INSTALL_DIR to your PATH if not already included"

0 commit comments

Comments
 (0)