-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish_to_github.py
More file actions
246 lines (192 loc) · 6.8 KB
/
publish_to_github.py
File metadata and controls
246 lines (192 loc) · 6.8 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/env python3
"""
GitHub Publisher Script
This script automates the process of publishing the AI Collaboration Framework
to GitHub with proper configuration and documentation.
"""
import os
import subprocess
from pathlib import Path
def run_command(cmd: str, cwd: str = None) -> tuple[bool, str]:
"""Run a shell command and return success status and output."""
try:
result = subprocess.run(
cmd,
shell=True,
cwd=cwd,
capture_output=True,
text=True,
timeout=30
)
return result.returncode == 0, result.stdout + result.stderr
except subprocess.TimeoutExpired:
return False, "Command timed out"
except Exception as e:
return False, str(e)
def init_git_repo(project_path: str) -> bool:
"""Initialize git repository."""
print("📝 Initializing git repository...")
success, output = run_command("git init", cwd=project_path)
if not success:
print(f"❌ Failed to init git: {output}")
return False
success, output = run_command(
'git config user.name "AI Framework"',
cwd=project_path
)
success, output = run_command(
'git config user.email "ai@framework.dev"',
cwd=project_path
)
print("✅ Git repository initialized")
return True
def add_and_commit(project_path: str) -> bool:
"""Add files and create initial commit."""
print("📦 Creating initial commit...")
success, output = run_command("git add .", cwd=project_path)
if not success:
print(f"❌ Failed to add files: {output}")
return False
success, output = run_command(
'git commit -m "Initial commit: AI Multi-Agent Collaboration Framework v1.0"',
cwd=project_path
)
if not success:
print(f"❌ Failed to commit: {output}")
return False
print("✅ Initial commit created")
return True
def rename_branch(project_path: str) -> bool:
"""Rename master branch to main."""
print("🔄 Renaming branch to main...")
success, output = run_command("git branch -M main", cwd=project_path)
if not success:
print(f"⚠️ Could not rename branch: {output}")
return False
print("✅ Branch renamed to main")
return True
def add_remote(project_path: str, github_url: str) -> bool:
"""Add remote repository."""
print(f"🔗 Adding remote repository...")
success, output = run_command(
f"git remote add origin {github_url}",
cwd=project_path
)
if not success:
print(f"⚠️ Could not add remote: {output}")
return False
print("✅ Remote repository added")
return True
def push_to_github(project_path: str) -> bool:
"""Push to GitHub."""
print("🚀 Pushing to GitHub...")
success, output = run_command(
"git push -u origin main",
cwd=project_path
)
if not success:
print(f"❌ Failed to push: {output}")
return False
print("✅ Pushed to GitHub successfully")
return True
def create_github_instructions(project_path: str, github_username: str, repo_name: str) -> None:
"""Create instructions file for GitHub setup."""
instructions = f"""# GitHub Setup Instructions
## Repository Created Successfully!
Your AI Collaboration Framework has been initialized and is ready to be published to GitHub.
### Quick Setup
1. **Create repository on GitHub**
- Visit: https://github.com/new
- Repository name: `{repo_name}`
- Description: "A production-grade AI multi-agent collaboration framework"
- Public: Yes
- Initialize: No
2. **Push to GitHub**
```bash
cd {project_path}
git remote add origin https://github.com/{github_username}/{repo_name}.git
git branch -M main
git push -u origin main
```
3. **Configure Repository**
- Go to Settings → General
- Add Topics: ai, multi-agent, collaboration, framework, crewai, langchain
4. **Create Release**
- Go to Releases
- Create new release v1.0.0
- Copy README.md content as description
### Project Structure
```
{repo_name}/
├── README.md # Project documentation
├── LICENSE # MIT License
├── requirements.txt # Python dependencies
├── setup.py # Package installation
├── .gitignore # Git ignore rules
├── src/
│ ├── __init__.py
│ ├── ai_collaboration_framework.py
│ └── advanced_ai_collaboration_system.py
├── examples/
│ └── basic_usage.py
├── tests/
│ └── (test files)
└── docs/
├── API_REFERENCE.md
├── BEST_PRACTICES.md
└── EXTENDING.md
```
### Next Steps
1. ✅ Complete GitHub setup (see instructions above)
2. 📝 Customize README.md with your information
3. 🧪 Add unit tests in tests/
4. 🔄 Set up GitHub Actions for CI/CD
5. 📊 Add code coverage badges
6. 🌟 Share with the community!
---
For more information, see the documentation in the docs/ directory.
"""
instructions_file = Path(project_path) / "GITHUB_INSTRUCTIONS.md"
instructions_file.write_text(instructions)
print(f"📄 Created GITHUB_INSTRUCTIONS.md")
def main():
"""Main function."""
import sys
if len(sys.argv) < 2:
print("Usage: python publish_to_github.py <project_path> [github_username] [repo_name]")
print("Example: python publish_to_github.py /home/ubuntu/my-framework coderyjq ai-collaboration-framework")
sys.exit(1)
project_path = sys.argv[1]
github_username = sys.argv[2] if len(sys.argv) > 2 else "yourusername"
repo_name = sys.argv[3] if len(sys.argv) > 3 else "ai-collaboration-framework"
print("=" * 60)
print("🚀 AI Collaboration Framework - GitHub Publisher")
print("=" * 60)
print(f"Project: {project_path}")
print(f"GitHub: {github_username}/{repo_name}")
print()
# Initialize git
if not init_git_repo(project_path):
sys.exit(1)
# Add and commit
if not add_and_commit(project_path):
sys.exit(1)
# Rename branch
rename_branch(project_path)
# Create instructions
github_url = f"https://github.com/{github_username}/{repo_name}.git"
create_github_instructions(project_path, github_username, repo_name)
print()
print("=" * 60)
print("✅ Framework prepared for GitHub!")
print("=" * 60)
print()
print("📋 Next steps:")
print(f"1. Create repository at: https://github.com/new")
print(f"2. Run: cd {project_path}")
print(f"3. Run: git remote add origin {github_url}")
print(f"4. Run: git push -u origin main")
print()
print("📄 See GITHUB_INSTRUCTIONS.md for detailed setup")
if __name__ == "__main__":
main()