setup_github.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #!/bin/bash
  2. # GitHub Repository Setup Script for Solar of Things Integration
  3. # This script will create a GitHub repository and push your integration
  4. echo "=================================================="
  5. echo "Solar of Things HA Integration - GitHub Setup"
  6. echo "=================================================="
  7. echo ""
  8. # Configuration
  9. REPO_NAME="solar-of-things-ha"
  10. GITHUB_USERNAME="conexocasa"
  11. GITHUB_EMAIL="bob@conexo.casa"
  12. echo "Repository Name: $REPO_NAME"
  13. echo "GitHub Username: $GITHUB_USERNAME"
  14. echo "GitHub Email: $GITHUB_EMAIL"
  15. echo ""
  16. # Check if we're in the right directory
  17. if [ ! -f "manifest.json" ]; then
  18. echo "Error: Please run this script from the solar_of_things_integration directory"
  19. exit 1
  20. fi
  21. # Check if git is configured
  22. if [ "$(git config user.email)" != "$GITHUB_EMAIL" ]; then
  23. echo "Configuring git..."
  24. git config --global user.email "$GITHUB_EMAIL"
  25. git config --global user.name "$GITHUB_USERNAME"
  26. fi
  27. # Rename master to main (GitHub's default)
  28. echo "Renaming branch to main..."
  29. git branch -M main
  30. echo ""
  31. echo "=================================================="
  32. echo "STEP 1: Create GitHub Personal Access Token"
  33. echo "=================================================="
  34. echo ""
  35. echo "1. Go to: https://github.com/settings/tokens/new"
  36. echo "2. Token name: 'Solar of Things Integration'"
  37. echo "3. Expiration: Choose your preference"
  38. echo "4. Select scopes:"
  39. echo " ☑ repo (all repo permissions)"
  40. echo "5. Click 'Generate token'"
  41. echo "6. COPY THE TOKEN (you won't see it again!)"
  42. echo ""
  43. echo -n "Paste your GitHub Personal Access Token here: "
  44. read -s GITHUB_TOKEN
  45. echo ""
  46. echo ""
  47. if [ -z "$GITHUB_TOKEN" ]; then
  48. echo "Error: Token is required!"
  49. exit 1
  50. fi
  51. echo "=================================================="
  52. echo "STEP 2: Create GitHub Repository"
  53. echo "=================================================="
  54. echo ""
  55. # Create repository using GitHub API
  56. echo "Creating repository on GitHub..."
  57. RESPONSE=$(curl -s -X POST \
  58. -H "Authorization: token $GITHUB_TOKEN" \
  59. -H "Accept: application/vnd.github.v3+json" \
  60. https://api.github.com/user/repos \
  61. -d "{
  62. \"name\":\"$REPO_NAME\",
  63. \"description\":\"Home Assistant integration for Solar of Things (Siseli) solar inverter systems with full monitoring and control capabilities\",
  64. \"homepage\":\"https://github.com/$GITHUB_USERNAME/$REPO_NAME\",
  65. \"private\":false,
  66. \"has_issues\":true,
  67. \"has_projects\":false,
  68. \"has_wiki\":false
  69. }")
  70. # Check if repository was created successfully
  71. if echo "$RESPONSE" | grep -q "\"full_name\""; then
  72. echo "✓ Repository created successfully!"
  73. REPO_URL=$(echo "$RESPONSE" | grep -o '"clone_url":"[^"]*"' | cut -d'"' -f4)
  74. echo " Repository URL: https://github.com/$GITHUB_USERNAME/$REPO_NAME"
  75. else
  76. if echo "$RESPONSE" | grep -q "already exists"; then
  77. echo "⚠ Repository already exists. Using existing repository."
  78. REPO_URL="https://github.com/$GITHUB_USERNAME/$REPO_NAME.git"
  79. else
  80. echo "✗ Error creating repository:"
  81. echo "$RESPONSE" | grep -o '"message":"[^"]*"' | cut -d'"' -f4
  82. exit 1
  83. fi
  84. fi
  85. echo ""
  86. echo "=================================================="
  87. echo "STEP 3: Push to GitHub"
  88. echo "=================================================="
  89. echo ""
  90. # Add remote with token authentication
  91. REPO_URL_WITH_TOKEN="https://$GITHUB_TOKEN@github.com/$GITHUB_USERNAME/$REPO_NAME.git"
  92. echo "Adding remote origin..."
  93. git remote remove origin 2>/dev/null
  94. git remote add origin "$REPO_URL_WITH_TOKEN"
  95. echo "Pushing to GitHub..."
  96. if git push -u origin main; then
  97. echo "✓ Successfully pushed to GitHub!"
  98. else
  99. echo "✗ Error pushing to GitHub"
  100. exit 1
  101. fi
  102. echo ""
  103. echo "=================================================="
  104. echo "STEP 4: Create Release Tag"
  105. echo "=================================================="
  106. echo ""
  107. echo "Creating v2.0.0 tag..."
  108. git tag -a v2.0.0 -m "Version 2.0.0 - Full Control Features
  109. Major release with complete control capabilities:
  110. - 8 new control entities (Number, Select, Switch)
  111. - Battery charge/discharge limits
  112. - Operating mode selection
  113. - Grid charging control
  114. - Comprehensive documentation
  115. - 15+ automation examples"
  116. echo "Pushing tag to GitHub..."
  117. git push origin v2.0.0
  118. echo ""
  119. echo "=================================================="
  120. echo "SUCCESS! Repository Created"
  121. echo "=================================================="
  122. echo ""
  123. echo "Your repository is now available at:"
  124. echo "https://github.com/$GITHUB_USERNAME/$REPO_NAME"
  125. echo ""
  126. echo "Next steps:"
  127. echo "1. Visit your repository: https://github.com/$GITHUB_USERNAME/$REPO_NAME"
  128. echo "2. Edit the README if needed"
  129. echo "3. Add topics: homeassistant, solar, siseli, home-automation"
  130. echo "4. Submit to HACS (optional)"
  131. echo ""
  132. echo "To add to HACS default repository:"
  133. echo "1. Fork: https://github.com/hacs/default"
  134. echo "2. Add your repo to integration list"
  135. echo "3. Create pull request"
  136. echo ""
  137. echo "Repository details:"
  138. echo "- Name: $REPO_NAME"
  139. echo "- Version: 2.0.0"
  140. echo "- Branch: main"
  141. echo "- Files: 23 files committed"
  142. echo ""
  143. # Clean up token from git config (security)
  144. git remote set-url origin "https://github.com/$GITHUB_USERNAME/$REPO_NAME.git"
  145. echo "✓ Setup complete!"