#!/bin/bash # GitHub Setup Script for PetBot # Run this script after creating your GitHub repository and setting up authentication echo "🚀 PetBot GitHub Setup" echo "======================" # Check if we're in a git repository if [ ! -d ".git" ]; then echo "❌ Error: Not in a git repository" exit 1 fi echo "🔐 GitHub Authentication Setup Required" echo "=======================================" echo "" echo "GitHub requires secure authentication. Choose one option:" echo "" echo "Option 1: SSH Key (Recommended)" echo " • More secure and convenient" echo " • No password prompts after setup" echo " • Repository URL format: git@github.com:username/repo.git" echo "" echo "Option 2: Personal Access Token" echo " • Use HTTPS with token instead of password" echo " • Repository URL format: https://github.com/username/repo.git" echo "" echo "📖 Setup guides:" echo " SSH Keys: https://docs.github.com/en/authentication/connecting-to-github-with-ssh" echo " Access Tokens: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token" echo "" # Ask user which method they want to use echo "Which authentication method did you set up?" echo "1) SSH Key" echo "2) Personal Access Token (HTTPS)" read -p "Enter choice (1 or 2): " AUTH_CHOICE case $AUTH_CHOICE in 1) echo "" echo "📝 Enter your SSH repository URL:" echo " Format: git@github.com:yourusername/petbot-irc-game.git" read -p "SSH URL: " REPO_URL if [[ ! "$REPO_URL" =~ ^git@github\.com: ]]; then echo "❌ Error: Please use SSH URL format (git@github.com:username/repo.git)" exit 1 fi ;; 2) echo "" echo "📝 Enter your HTTPS repository URL:" echo " Format: https://github.com/yourusername/petbot-irc-game.git" read -p "HTTPS URL: " REPO_URL if [[ ! "$REPO_URL" =~ ^https://github\.com/ ]]; then echo "❌ Error: Please use HTTPS URL format (https://github.com/username/repo.git)" exit 1 fi echo "" echo "⚠️ Important: When prompted for password, use your Personal Access Token" echo " Do NOT use your GitHub account password" ;; *) echo "❌ Invalid choice" exit 1 ;; esac if [ -z "$REPO_URL" ]; then echo "❌ Error: No URL provided" exit 1 fi # Test GitHub connection echo "" echo "🔍 Testing GitHub connection..." if [ "$AUTH_CHOICE" = "1" ]; then ssh -T git@github.com 2>/dev/null if [ $? -ne 1 ]; then echo "❌ SSH connection test failed. Please check your SSH key setup." echo " Guide: https://docs.github.com/en/authentication/connecting-to-github-with-ssh" exit 1 fi echo "✅ SSH connection successful" else echo "⚠️ HTTPS connection will be tested during push" fi # Add remote origin echo "" echo "🔗 Adding GitHub remote..." git remote add origin "$REPO_URL" 2>/dev/null || { echo "🔄 Remote already exists, updating..." git remote set-url origin "$REPO_URL" } # Push to GitHub echo "⬆️ Pushing to GitHub..." if ! git push -u origin main; then echo "" echo "❌ Push failed. Common solutions:" if [ "$AUTH_CHOICE" = "1" ]; then echo " • Check SSH key is added to GitHub: https://github.com/settings/keys" echo " • Verify SSH agent is running: ssh-add -l" else echo " • Use Personal Access Token as password (not account password)" echo " • Create token at: https://github.com/settings/tokens" echo " • Token needs 'repo' scope for private repos" fi echo " • Verify repository exists and you have write access" exit 1 fi # Push tags echo "🏷️ Pushing tags..." git push --tags echo "" echo "✅ Setup complete!" echo "" echo "🎯 Your repository is now on GitHub:" echo " Repository: $REPO_URL" echo " Current version: v0.1.0" echo " Authentication: $([ "$AUTH_CHOICE" = "1" ] && echo "SSH Key" || echo "Personal Access Token")" echo "" echo "🔄 Future updates will be automatic:" echo " - Claude will commit changes with descriptive messages" echo " - Changelog will be updated automatically" echo " - Version tags will be created for releases" echo " - All changes will be pushed to GitHub" echo "" echo "📚 Useful commands:" echo " git status - Check repository status" echo " git log --oneline - View commit history" echo " git tag -l - List all version tags"