-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-to-github.sh
More file actions
executable file
·263 lines (231 loc) · 12.9 KB
/
Copy pathupload-to-github.sh
File metadata and controls
executable file
·263 lines (231 loc) · 12.9 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/bin/bash
# ============================================================================
# GITHUB UPLOAD SCRIPT for SyncVold
# ============================================================================
#
# Uploads this project to a GitHub account of your choice.
# Uses a Personal Access Token (PAT) — does NOT affect your
# VS Code / gh CLI login on your main account.
#
# BEFORE RUNNING:
# 1. Go to: https://github.com/settings/tokens/new
# 2. Create a new token with scope: repo
# 3. Copy the token (ghp_xxxxxxxxxxxx)
# 4. Run this script
#
# USAGE:
# cd ~/Desktop/syncvold-spm
# chmod +x upload-to-github.sh
# ./upload-to-github.sh
#
# ============================================================================
set -e
# ── Configuration ───────────────────────────────────────────────────────────
REPO_NAME="syncvold"
REPO_DESCRIPTION="Multi-device audio volume synchronizer for macOS — synchronize Volume +/−/Mute across all Loopback virtual devices for 5.1/7.1 surround on Hackintosh. SwiftUI GUI + headless CLI. Built with Core Audio HAL."
REPO_TOPICS="macos,audio,volume,loopback,surround-sound,hackintosh,coreaudio,swiftui,swift,menu-bar,5-1-surround,volume-sync,media-keys,multi-output"
# ────────────────────────────────────────────────────────────────────────────
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ SyncVold — GitHub Upload Script ║"
echo "║ ║"
echo "║ Uploads to ANY GitHub account (does not affect VS Code) ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
# ── Check git ──────────────────────────────────────────────────────────────
if ! command -v git &> /dev/null; then
echo "❌ git is not installed. Install with: xcode-select --install"
exit 1
fi
echo "✅ git found: $(git --version)"
echo ""
# ── Ask for GitHub credentials ─────────────────────────────────────────────
echo "═══════════════════════════════════════════════════════════════════"
echo " Enter the GitHub account you want to upload to."
echo " This will NOT change your VS Code or gh CLI login."
echo "═══════════════════════════════════════════════════════════════════"
echo ""
read -p " GitHub username: " GITHUB_USER
echo ""
echo " You need a Personal Access Token (PAT)."
echo " Create one at: https://github.com/settings/tokens/new"
echo " Required scopes: repo (full control of private repositories)"
echo ""
read -s -p " GitHub token (hidden): " GITHUB_TOKEN
echo ""
echo ""
if [ -z "$GITHUB_USER" ] || [ -z "$GITHUB_TOKEN" ]; then
echo "❌ Username and token are required."
exit 1
fi
# ── Verify credentials ────────────────────────────────────────────────────
echo "🔑 Verifying credentials..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/user")
if [ "$HTTP_CODE" != "200" ]; then
echo "❌ Authentication failed (HTTP $HTTP_CODE)."
echo " Check your username and token."
exit 1
fi
VERIFIED_USER=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/user" | grep '"login"' | head -1 | sed 's/.*: "//;s/".*//')
echo "✅ Authenticated as: $VERIFIED_USER"
echo ""
# ── Clean .DS_Store files ──────────────────────────────────────────────────
echo "🧹 Cleaning .DS_Store files..."
find . -name ".DS_Store" -type f -delete 2>/dev/null || true
echo ""
# ── Initialize git repo ───────────────────────────────────────────────────
if [ -d ".git" ]; then
echo "⚠️ Git repo already initialized. Skipping git init."
else
echo "📁 Initializing git repository..."
git init
git branch -M main
fi
echo ""
# ── Configure git identity for THIS repo only ─────────────────────────────
echo "🔧 Setting git identity for this repo only..."
GITHUB_EMAIL=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/user" | grep '"email"' | head -1 | sed 's/.*: "//;s/".*//')
if [ "$GITHUB_EMAIL" = "null" ] || [ -z "$GITHUB_EMAIL" ]; then
GITHUB_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/user" | grep '"id"' | head -1 | sed 's/[^0-9]//g')
GITHUB_EMAIL="${GITHUB_ID}+${VERIFIED_USER}@users.noreply.github.com"
fi
git config user.name "$VERIFIED_USER"
git config user.email "$GITHUB_EMAIL"
echo " Name: $VERIFIED_USER"
echo " Email: $GITHUB_EMAIL"
echo " (local to this repo only)"
echo ""
# ── Stage all files ────────────────────────────────────────────────────────
echo "📦 Staging files..."
git add -A
echo ""
echo "📋 Files to be committed:"
git status --short
echo ""
# ── Commit ─────────────────────────────────────────────────────────────────
echo "💾 Creating initial commit..."
git commit -m "Initial release: SyncVold v1.0.0
Multi-device audio volume synchronizer for macOS.
Synchronizes Volume +/−/Mute across multiple audio output devices —
built for 5.1 surround sound setups using Loopback virtual audio routing.
Features:
- SwiftUI GUI with menu bar integration
- Headless CLI with launchd daemon support
- Media key interception (Volume +/−/Mute)
- Per-device volume offsets (±30%)
- Persistent settings, auto-start, resume last state
- Safety mute (all devices → 0% when master hits 0%)
- Built with Core Audio HAL API (no private APIs)
Requires: macOS 13.0+, Loopback by Rogue Amoeba"
echo ""
# ── Create GitHub repo via API ─────────────────────────────────────────────
echo "🌐 Creating GitHub repository: $REPO_NAME ..."
CREATE_RESPONSE=$(curl -s -w "\n%{http_code}" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-X POST "https://api.github.com/user/repos" \
-d "{
\"name\": \"$REPO_NAME\",
\"description\": \"$REPO_DESCRIPTION\",
\"private\": false,
\"has_issues\": true,
\"has_wiki\": false,
\"auto_init\": false
}")
CREATE_HTTP=$(echo "$CREATE_RESPONSE" | tail -1)
CREATE_BODY=$(echo "$CREATE_RESPONSE" | sed '$d')
if [ "$CREATE_HTTP" = "201" ]; then
echo "✅ Repository created successfully."
elif [ "$CREATE_HTTP" = "422" ]; then
echo "⚠️ Repository already exists. Will push to existing repo."
else
echo "❌ Failed to create repository (HTTP $CREATE_HTTP)."
echo "$CREATE_BODY" | head -5
exit 1
fi
echo ""
# ── Set remote with embedded token ─────────────────────────────────────────
REMOTE_URL="https://${VERIFIED_USER}:${GITHUB_TOKEN}@github.com/${VERIFIED_USER}/${REPO_NAME}.git"
git remote remove origin 2>/dev/null || true
git remote add origin "$REMOTE_URL"
# ── Push ───────────────────────────────────────────────────────────────────
echo "🚀 Pushing to GitHub..."
git push -u origin main
echo ""
# ── Remove token from remote URL (security) ───────────────────────────────
SAFE_URL="https://github.com/${VERIFIED_USER}/${REPO_NAME}.git"
git remote set-url origin "$SAFE_URL"
echo "🔒 Token removed from git remote (security cleanup)."
echo ""
# ── Set topics ─────────────────────────────────────────────────────────────
echo "🏷️ Setting repository topics..."
IFS=',' read -ra TOPICS <<< "$REPO_TOPICS"
TOPIC_JSON='{"names":['
for i in "${!TOPICS[@]}"; do
[ $i -gt 0 ] && TOPIC_JSON+=','
TOPIC_JSON+="\"${TOPICS[$i]}\""
done
TOPIC_JSON+=']}'
curl -s -o /dev/null \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-X PUT "https://api.github.com/repos/$VERIFIED_USER/$REPO_NAME/topics" \
-d "$TOPIC_JSON" || echo " (topics may need to be set manually)"
echo "✅ Topics set."
echo ""
# ── Upload DMG as GitHub Release ───────────────────────────────────────────
DMG_FILE="SyncVold-1.0.0.dmg"
if [ -f "$DMG_FILE" ]; then
echo "📀 Creating GitHub Release v1.0.0 with $DMG_FILE ..."
RELEASE_RESPONSE=$(curl -s -w "\n%{http_code}" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-X POST "https://api.github.com/repos/$VERIFIED_USER/$REPO_NAME/releases" \
-d "{
\"tag_name\": \"v1.0.0\",
\"name\": \"SyncVold v1.0.0\",
\"body\": \"## SyncVold v1.0.0 — Initial Release\n\nMulti-device audio volume synchronizer for macOS.\n\n### Installation\n1. Download \`SyncVold-1.0.0.dmg\` below\n2. Open DMG → drag SyncVold.app to Applications\n3. Launch and grant Accessibility permission\n4. Select your audio devices and click Start Sync\n\n### Requirements\n- macOS 13.0 (Ventura) or later\n- [Loopback by Rogue Amoeba](https://rogueamoeba.com/loopback/) for multi-device audio routing\n- Accessibility permission for media key capture\",
\"draft\": false,
\"prerelease\": false
}")
RELEASE_HTTP=$(echo "$RELEASE_RESPONSE" | tail -1)
RELEASE_BODY=$(echo "$RELEASE_RESPONSE" | sed '$d')
if [ "$RELEASE_HTTP" = "201" ]; then
UPLOAD_URL=$(echo "$RELEASE_BODY" | grep '"upload_url"' | sed 's/.*"upload_url": "//;s/{.*//')
echo "📤 Uploading $DMG_FILE to release..."
curl -s -o /dev/null \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
-X POST "${UPLOAD_URL}?name=${DMG_FILE}&label=SyncVold%20Installer%20(DMG)" \
--data-binary "@$DMG_FILE"
echo "✅ DMG uploaded to release."
else
echo "⚠️ Could not create release (HTTP $RELEASE_HTTP). Upload DMG manually."
fi
echo ""
else
echo "ℹ️ No DMG file found. Skipping release creation."
echo ""
fi
# ── Clear token from memory ───────────────────────────────────────────────
unset GITHUB_TOKEN
# ── Done ───────────────────────────────────────────────────────────────────
REPO_URL="https://github.com/$VERIFIED_USER/$REPO_NAME"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ ✅ SUCCESS! Repository uploaded to GitHub. ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo "🔗 Repository URL: $REPO_URL"
echo ""
echo "Your VS Code GitHub account was NOT modified."
echo "The token was used only for this upload and has been cleared."
echo ""
echo "Next steps (optional):"
echo " • Open in browser: open $REPO_URL"
echo " • Share on Reddit r/hackintosh, InsanelyMac, etc."
echo ""