-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-setup.sh
More file actions
182 lines (159 loc) Β· 5.06 KB
/
github-setup.sh
File metadata and controls
182 lines (159 loc) Β· 5.06 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
#!/bin/bash
# GitHub Setup Helper Script
# This script helps you push your project to GitHub
set -e
echo "π GitHub Setup Helper for MIDI CW Keyer"
echo "========================================"
echo
# Check if git is installed
if ! command -v git &> /dev/null; then
echo "β Git is not installed. Please install git first:"
echo " sudo apt install git"
exit 1
fi
echo "β
Git is installed"
echo
# Check if already initialized
if [ -d .git ]; then
echo "β
Git repository already initialized"
else
echo "π¦ Initializing git repository..."
git init
echo "β
Git repository initialized"
fi
echo
# Check git config
if ! git config user.name &> /dev/null; then
echo "β οΈ Git user.name not configured"
read -p "Enter your name: " username
git config user.name "$username"
echo "β
Set git user.name to: $username"
fi
if ! git config user.email &> /dev/null; then
echo "β οΈ Git user.email not configured"
read -p "Enter your email: " useremail
git config user.email "$useremail"
echo "β
Set git user.email to: $useremail"
fi
echo
echo "Current git configuration:"
echo " Name: $(git config user.name)"
echo " Email: $(git config user.email)"
echo
# Check for remote
if git remote | grep -q origin; then
echo "β
Remote 'origin' already configured:"
git remote -v
echo
read -p "Do you want to change it? (y/N): " change_remote
if [[ $change_remote =~ ^[Yy]$ ]]; then
read -p "Enter new GitHub repository URL: " repo_url
git remote set-url origin "$repo_url"
echo "β
Remote updated"
fi
else
echo "β οΈ No remote configured yet"
echo
echo "First, create a repository on GitHub:"
echo " 1. Go to: https://github.com/new"
echo " 2. Repository name: midicwkeyer"
echo " 3. Description: MIDI CW keyer with audio output - Rust implementation"
echo " 4. Choose Public or Private"
echo " 5. DO NOT initialize with README or .gitignore"
echo " 6. Click 'Create repository'"
echo
read -p "Have you created the repository? (y/N): " created
if [[ ! $created =~ ^[Yy]$ ]]; then
echo "β Please create the repository first, then run this script again"
exit 0
fi
echo
read -p "Enter your GitHub username: " github_user
read -p "Enter repository name (default: midicwkeyer): " repo_name
repo_name=${repo_name:-midicwkeyer}
repo_url="https://github.com/$github_user/$repo_name.git"
echo
echo "Adding remote: $repo_url"
git remote add origin "$repo_url"
echo "β
Remote added"
fi
echo
echo "π Preparing to commit..."
# Check if there are changes to commit
if git diff --quiet && git diff --cached --quiet 2>/dev/null; then
if git rev-parse HEAD >/dev/null 2>&1; then
echo "β
No changes to commit (already committed)"
else
echo "π¦ Adding all files..."
git add .
echo "β
Files staged"
fi
else
echo "π¦ Adding all files..."
git add .
echo "β
Files staged"
fi
echo
echo "Files to be committed:"
git status --short | head -20
if [ $(git status --short | wc -l) -gt 20 ]; then
echo "... and more"
fi
echo
read -p "Proceed with commit? (y/N): " do_commit
if [[ ! $do_commit =~ ^[Yy]$ ]]; then
echo "β Commit cancelled"
exit 0
fi
# Check if we need to make initial commit
if ! git rev-parse HEAD >/dev/null 2>&1; then
echo
echo "π Creating initial commit..."
git commit -m "Initial commit: MIDI CW keyer Rust implementation
- Converted from Python to Rust
- Cross-platform MIDI and audio support
- MSVC cross-compilation for Windows
- GitHub Actions for macOS builds
- Comprehensive documentation"
echo "β
Initial commit created"
else
echo
read -p "Enter commit message: " commit_msg
commit_msg=${commit_msg:-"Update project"}
git commit -m "$commit_msg"
echo "β
Commit created"
fi
echo
echo "π€ Setting main branch..."
git branch -M main
echo "β
On main branch"
echo
echo "π Pushing to GitHub..."
echo
echo "β οΈ IMPORTANT: When prompted for password, use your Personal Access Token!"
echo " Get one at: https://github.com/settings/tokens"
echo " Required scopes: 'repo' and 'workflow'"
echo
read -p "Press Enter to continue..."
if git push -u origin main; then
echo
echo "π SUCCESS! Your project is now on GitHub!"
echo
echo "Next steps:"
echo " 1. Visit your repository: $(git remote get-url origin | sed 's/\.git$//')"
echo " 2. Check Actions tab - builds are running for all platforms"
echo " 3. Wait ~5 minutes for builds to complete"
echo " 4. Download macOS binaries from Actions β Artifacts"
echo
echo "Repository URL: $(git remote get-url origin | sed 's/\.git$//')"
else
echo
echo "β Push failed"
echo
echo "Common solutions:"
echo " 1. Make sure you're using a Personal Access Token (not password)"
echo " 2. Check your token has 'repo' and 'workflow' scopes"
echo " 3. Verify repository URL: $(git remote get-url origin)"
echo
echo "See GITHUB_SETUP.md for detailed troubleshooting"
fi