-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish_to_github.sh
More file actions
executable file
·39 lines (31 loc) · 959 Bytes
/
publish_to_github.sh
File metadata and controls
executable file
·39 lines (31 loc) · 959 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
if [[ "${ALLOW_REMOTE_PUBLISH:-0}" != "1" ]]; then
echo "Remote publish is disabled by local-only policy."
echo "This project is configured for laptop-local work."
echo "If you intentionally want to publish, run with:"
echo " ALLOW_REMOTE_PUBLISH=1 $0 <owner> <repo> [public|private]"
exit 1
fi
if [[ $# -lt 2 ]]; then
echo "Usage: $0 <owner> <repo> [public|private]"
exit 1
fi
OWNER="$1"
REPO="$2"
VISIBILITY="${3:-public}"
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
if [[ ! -d .git ]]; then
git init -b main
fi
git add .
if ! git diff --cached --quiet; then
git commit -m "Initial public release"
fi
if [[ "$VISIBILITY" == "private" ]]; then
gh repo create "${OWNER}/${REPO}" --private --source=. --remote=origin --push
else
gh repo create "${OWNER}/${REPO}" --public --source=. --remote=origin --push
fi
echo "Published: https://github.com/${OWNER}/${REPO}"