-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_gen.sh
More file actions
executable file
·66 lines (57 loc) · 1.92 KB
/
post_gen.sh
File metadata and controls
executable file
·66 lines (57 loc) · 1.92 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
#!/bin/bash
set -e
PROJECT_NAME=$(basename "$PWD")
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if GitHub CLI is installed
if ! command_exists gh; then
echo "❌ GitHub CLI (gh) is not installed."
echo ""
echo "📦 To install GitHub CLI:"
echo ""
echo "🍎 On macOS (using Homebrew):"
echo " brew install gh"
echo ""
echo "🐧 On Linux (Ubuntu/Debian):"
echo " curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg"
echo " echo \"deb [arch=\$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main\" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null"
echo " sudo apt update"
echo " sudo apt install gh"
echo ""
echo "🪟 On Windows:"
echo " winget install --id GitHub.cli"
echo " # or download from: https://github.com/cli/cli/releases"
echo ""
echo "After installation, run:"
echo " gh auth login"
echo " ./post_gen.sh"
echo ""
exit 1
fi
# Check if user is authenticated with GitHub
if ! gh auth status >/dev/null 2>&1; then
echo "❌ You are not authenticated with GitHub CLI."
echo ""
echo "🔐 Please run:"
echo " gh auth login"
echo ""
echo "Then run this script again:"
echo " ./post_gen.sh"
echo ""
exit 1
fi
echo "🚀 Creating Git repository and pushing to GitHub..."
git init
git add .
git commit -m "Initial commit from Hamze's custom Rust template"
# Rename the current branch to main (if not already)
git branch -M main
gh repo create "$PROJECT_NAME" \
--private \
--source=. \
--remote=origin \
--push
echo "✅ Repo '$PROJECT_NAME' created and pushed to GitHub."
echo "🌐 Repository URL: https://github.com/$(gh api user --jq .login)/$PROJECT_NAME"