Last active
January 7, 2026 21:24
-
-
Save BraydenGirard/f5aa8ad4aa2f8882cf97b4ada3f7a9cf to your computer and use it in GitHub Desktop.
Install Teamwork Time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Teamwork CLI Time Logger Installation Script | |
| # | |
| # Usage: curl -fsSL https://gist.githubusercontent.com/arcticleaf/YOUR_GIST_ID/raw | bash | |
| # | |
| # NOTE: This file is distributed via a public GitHub Gist. | |
| # When you update this file, remember to also update the gist at: | |
| # https://gist.github.com/arcticleaf/YOUR_GIST_ID | |
| set -e | |
| # Colors for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| NC='\033[0m' # No Color | |
| # Configuration | |
| REPO="git@github.com:arcticleaf/teamwork-cli-time.git" | |
| BINARY_NAME="teamwork-time" | |
| INSTALL_DIR="$HOME/.local/bin" | |
| # Detect OS and architecture | |
| detect_platform() { | |
| OS="$(uname -s)" | |
| ARCH="$(uname -m)" | |
| case "$OS" in | |
| Linux*) OS="linux";; | |
| Darwin*) OS="darwin";; | |
| *) | |
| echo -e "${RED}Error: Unsupported operating system: $OS${NC}" | |
| exit 1 | |
| ;; | |
| esac | |
| case "$ARCH" in | |
| x86_64|amd64) ARCH="x86_64";; | |
| aarch64|arm64) ARCH="aarch64";; | |
| *) | |
| echo -e "${RED}Error: Unsupported architecture: $ARCH${NC}" | |
| exit 1 | |
| ;; | |
| esac | |
| echo -e "${GREEN}Detected platform: ${OS}-${ARCH}${NC}" | |
| } | |
| # Check if SSH keys are configured for GitHub | |
| check_ssh_keys() { | |
| if [ ! -f "$HOME/.ssh/id_rsa" ] && [ ! -f "$HOME/.ssh/id_ed25519" ]; then | |
| echo -e "${RED}Error: No SSH keys found${NC}" | |
| echo -e "${YELLOW}This repository requires SSH authentication.${NC}" | |
| echo "" | |
| echo "Please set up SSH keys for GitHub:" | |
| echo "1. Generate SSH key: ssh-keygen -t ed25519 -C \"your_email@example.com\"" | |
| echo "2. Add to GitHub: https://github.com/settings/keys" | |
| echo "3. Test connection: ssh -T git@github.com" | |
| echo "" | |
| exit 1 | |
| fi | |
| # Test SSH connection to GitHub | |
| if ! ssh -T git@github.com 2>&1 | grep -q "successfully authenticated"; then | |
| echo -e "${YELLOW}Warning: Cannot authenticate with GitHub via SSH${NC}" | |
| echo "Make sure your SSH key is added to your GitHub account:" | |
| echo "https://github.com/settings/keys" | |
| echo "" | |
| read -p "Continue anyway? (y/N) " -n 1 -r | |
| echo | |
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | |
| exit 1 | |
| fi | |
| else | |
| echo -e "${GREEN}GitHub SSH authentication verified${NC}" | |
| fi | |
| } | |
| # Check if Rust/Cargo is installed | |
| check_rust() { | |
| if ! command -v cargo &> /dev/null; then | |
| echo -e "${YELLOW}Rust/Cargo not found. Installing rustup...${NC}" | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
| source "$HOME/.cargo/env" | |
| fi | |
| echo -e "${GREEN}Rust/Cargo found${NC}" | |
| } | |
| # Create install directory if it doesn't exist | |
| setup_install_dir() { | |
| if [ ! -d "$INSTALL_DIR" ]; then | |
| mkdir -p "$INSTALL_DIR" | |
| echo -e "${GREEN}Created install directory: $INSTALL_DIR${NC}" | |
| fi | |
| } | |
| # Build and install from source | |
| install_from_source() { | |
| echo -e "${YELLOW}Building from source...${NC}" | |
| # Create temporary directory | |
| TMP_DIR=$(mktemp -d) | |
| cd "$TMP_DIR" | |
| # Clone repository | |
| echo "Cloning repository..." | |
| git clone --depth 1 "$REPO" . | |
| # Build release binary | |
| echo "Building release binary (this may take a few minutes)..." | |
| cargo build --release | |
| # Copy binary to install directory | |
| cp "target/release/$BINARY_NAME" "$INSTALL_DIR/" | |
| chmod +x "$INSTALL_DIR/$BINARY_NAME" | |
| # Cleanup | |
| cd - > /dev/null | |
| rm -rf "$TMP_DIR" | |
| echo -e "${GREEN}Binary installed to: $INSTALL_DIR/$BINARY_NAME${NC}" | |
| } | |
| # Download pre-built binary (if available) | |
| # Note: For private repos with SSH URLs, this will skip and build from source | |
| download_binary() { | |
| # Check if REPO is an SSH URL (starts with git@) | |
| if [[ "$REPO" == git@* ]]; then | |
| # SSH repos can't download releases via curl, skip to source build | |
| return 1 | |
| fi | |
| # Convert git URL to HTTPS release URL | |
| HTTPS_REPO=$(echo "$REPO" | sed 's/\.git$//') | |
| RELEASE_URL="${HTTPS_REPO}/releases/latest/download/${BINARY_NAME}-${OS}-${ARCH}" | |
| echo -e "${YELLOW}Checking for pre-built binary...${NC}" | |
| if curl -fsSL "$RELEASE_URL" -o "$INSTALL_DIR/$BINARY_NAME" 2>/dev/null; then | |
| chmod +x "$INSTALL_DIR/$BINARY_NAME" | |
| echo -e "${GREEN}Binary downloaded to: $INSTALL_DIR/$BINARY_NAME${NC}" | |
| return 0 | |
| else | |
| return 1 | |
| fi | |
| } | |
| # Add to PATH if needed | |
| setup_path() { | |
| # Check if already in PATH | |
| if [[ ":$PATH:" == *":$INSTALL_DIR:"* ]]; then | |
| echo -e "${GREEN}$INSTALL_DIR is already in PATH${NC}" | |
| return | |
| fi | |
| # Determine shell config file | |
| SHELL_CONFIG="" | |
| if [ -n "$BASH_VERSION" ]; then | |
| SHELL_CONFIG="$HOME/.bashrc" | |
| elif [ -n "$ZSH_VERSION" ]; then | |
| SHELL_CONFIG="$HOME/.zshrc" | |
| else | |
| SHELL_CONFIG="$HOME/.profile" | |
| fi | |
| # Add to PATH in shell config | |
| echo "" >> "$SHELL_CONFIG" | |
| echo "# Added by teamwork-time installer" >> "$SHELL_CONFIG" | |
| echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$SHELL_CONFIG" | |
| echo -e "${YELLOW}Added $INSTALL_DIR to PATH in $SHELL_CONFIG${NC}" | |
| echo -e "${YELLOW}Please run: source $SHELL_CONFIG${NC}" | |
| echo -e "${YELLOW}Or restart your terminal${NC}" | |
| } | |
| # Verify installation | |
| verify_installation() { | |
| if [ -x "$INSTALL_DIR/$BINARY_NAME" ]; then | |
| echo -e "${GREEN}✓ Installation successful!${NC}" | |
| echo "" | |
| echo "To get started, run:" | |
| echo -e "${GREEN} $BINARY_NAME${NC}" | |
| echo "" | |
| echo "Note: You may need to restart your terminal or run:" | |
| echo -e "${GREEN} export PATH=\"\$PATH:$INSTALL_DIR\"${NC}" | |
| return 0 | |
| else | |
| echo -e "${RED}✗ Installation failed${NC}" | |
| return 1 | |
| fi | |
| } | |
| # Main installation flow | |
| main() { | |
| echo -e "${GREEN}=== Teamwork CLI Time Logger Installer ===${NC}" | |
| echo "" | |
| detect_platform | |
| check_ssh_keys | |
| check_rust | |
| setup_install_dir | |
| # Try to download binary, fall back to source build | |
| if ! download_binary; then | |
| install_from_source | |
| fi | |
| setup_path | |
| verify_installation | |
| } | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment