Repository navigation
Expand file tree
/
Copy pathsetup_github.ps1
More file actions
175 lines (156 loc) · 6.66 KB
/
Copy pathsetup_github.ps1
File metadata and controls
175 lines (156 loc) · 6.66 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
# MineConnect GitHub Setup Script
Write-Host "=== MineConnect GitHub Setup ===" -ForegroundColor Cyan
Write-Host ""
# Check if git is installed
Write-Host "Checking Git installation..." -ForegroundColor Yellow
try {
$gitVersion = git --version
Write-Host " Found: $gitVersion" -ForegroundColor Green
} catch {
Write-Host " Error: Git not found. Please install Git first." -ForegroundColor Red
Write-Host " Download from: https://git-scm.com/downloads" -ForegroundColor Yellow
exit 1
}
# Check if already a git repository
if (Test-Path ".git") {
Write-Host ""
Write-Host "This directory is already a Git repository!" -ForegroundColor Yellow
Write-Host ""
$response = Read-Host "Do you want to continue and push to a new remote? (y/n)"
if ($response -ne "y") {
Write-Host "Setup cancelled." -ForegroundColor Red
exit 0
}
} else {
# Initialize git repository
Write-Host ""
Write-Host "Initializing Git repository..." -ForegroundColor Yellow
git init
Write-Host " Repository initialized!" -ForegroundColor Green
}
# Get GitHub username and repository name
Write-Host ""
Write-Host "=== GitHub Repository Information ===" -ForegroundColor Cyan
Write-Host ""
$githubUser = Read-Host "Enter your GitHub username"
$repoName = Read-Host "Enter repository name (e.g., MineConnect)"
if ([string]::IsNullOrWhiteSpace($githubUser) -or [string]::IsNullOrWhiteSpace($repoName)) {
Write-Host ""
Write-Host "Error: Username and repository name are required!" -ForegroundColor Red
exit 1
}
$repoFullName = "$githubUser/$repoName"
$repoUrl = "https://github.com/$repoFullName.git"
Write-Host ""
Write-Host "Repository: $repoFullName" -ForegroundColor Green
Write-Host "URL: $repoUrl" -ForegroundColor Green
# Update updater.py with the repository name
Write-Host ""
Write-Host "Updating updater.py with repository info..." -ForegroundColor Yellow
$updaterPath = "client\updater.py"
if (Test-Path $updaterPath) {
$content = Get-Content $updaterPath -Raw
$content = $content -replace 'GITHUB_REPO = "YOUR_USERNAME/MineConnect"', "GITHUB_REPO = `"$repoFullName`""
Set-Content $updaterPath $content
Write-Host " Updated! GITHUB_REPO = `"$repoFullName`"" -ForegroundColor Green
} else {
Write-Host " Warning: client\updater.py not found" -ForegroundColor Yellow
}
# Ask if they want to create the repository on GitHub
Write-Host ""
Write-Host "=== Next Steps ===" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Create the repository on GitHub:" -ForegroundColor White
Write-Host " - Go to: https://github.com/new" -ForegroundColor Cyan
Write-Host " - Repository name: $repoName" -ForegroundColor Yellow
Write-Host " - Description: Minecraft tunnel client with auto-updates" -ForegroundColor Gray
Write-Host " - Choose: Public (recommended for auto-updates)" -ForegroundColor Gray
Write-Host " - DON'T initialize with README (we already have files)" -ForegroundColor Red
Write-Host " - Click 'Create repository'" -ForegroundColor Gray
Write-Host ""
$response = Read-Host "Have you created the repository on GitHub? (y/n)"
if ($response -ne "y") {
Write-Host ""
Write-Host "Please create the repository first, then run this script again." -ForegroundColor Yellow
Write-Host ""
Write-Host "Or manually run these commands after creating the repo:" -ForegroundColor Cyan
Write-Host " git add ." -ForegroundColor White
Write-Host " git commit -m `"Initial commit`"" -ForegroundColor White
Write-Host " git branch -M main" -ForegroundColor White
Write-Host " git remote add origin $repoUrl" -ForegroundColor White
Write-Host " git push -u origin main" -ForegroundColor White
exit 0
}
# Add all files
Write-Host ""
Write-Host "Adding files to Git..." -ForegroundColor Yellow
git add .
# Show status
Write-Host ""
Write-Host "Files to be committed:" -ForegroundColor Yellow
git status --short
# Commit
Write-Host ""
Write-Host "Creating initial commit..." -ForegroundColor Yellow
git commit -m "Initial commit - MineConnect v1.0.0
- Client application with auto-update system
- Server package for PyPI
- Installer with self-update capability
- Beautiful HTML/CSS GUI
- WebSocket tunnel support for Java & Bedrock editions"
# Set main branch
Write-Host ""
Write-Host "Setting default branch to 'main'..." -ForegroundColor Yellow
git branch -M main
# Add remote
Write-Host ""
Write-Host "Adding GitHub remote..." -ForegroundColor Yellow
$existingRemote = git remote get-url origin 2>$null
if ($existingRemote) {
Write-Host " Remote 'origin' already exists: $existingRemote" -ForegroundColor Yellow
$response = Read-Host " Replace with $repoUrl? (y/n)"
if ($response -eq "y") {
git remote remove origin
git remote add origin $repoUrl
Write-Host " Remote updated!" -ForegroundColor Green
}
} else {
git remote add origin $repoUrl
Write-Host " Remote added!" -ForegroundColor Green
}
# Push to GitHub
Write-Host ""
Write-Host "Pushing to GitHub..." -ForegroundColor Yellow
Write-Host " (You may be prompted for GitHub credentials)" -ForegroundColor Gray
Write-Host ""
try {
git push -u origin main
Write-Host ""
Write-Host "=== Success! ===" -ForegroundColor Green
Write-Host ""
Write-Host "Your code is now on GitHub!" -ForegroundColor Green
Write-Host "Repository: https://github.com/$repoFullName" -ForegroundColor Cyan
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host " 1. Update VERSION in client\config.py when ready to release" -ForegroundColor White
Write-Host " 2. Build executables: cd client; .\build.ps1" -ForegroundColor White
Write-Host " 3. Create a GitHub Release:" -ForegroundColor White
Write-Host " - Go to: https://github.com/$repoFullName/releases/new" -ForegroundColor Cyan
Write-Host " - Tag: v1.0.0 (match VERSION in config.py)" -ForegroundColor White
Write-Host " - Upload: dist\MineConnectInstaller.exe" -ForegroundColor White
Write-Host " - Add release notes" -ForegroundColor White
Write-Host " - Publish!" -ForegroundColor White
Write-Host ""
Write-Host "Auto-updates will work automatically once you publish releases!" -ForegroundColor Green
} catch {
Write-Host ""
Write-Host "Error pushing to GitHub!" -ForegroundColor Red
Write-Host ""
Write-Host "Common issues:" -ForegroundColor Yellow
Write-Host " - Repository doesn't exist on GitHub" -ForegroundColor White
Write-Host " - Wrong credentials" -ForegroundColor White
Write-Host " - Network issues" -ForegroundColor White
Write-Host ""
Write-Host "Try again with:" -ForegroundColor Yellow
Write-Host " git push -u origin main" -ForegroundColor White
}