Skip to content

Commit d3c9887

Browse files
authored
Merge pull request #302 from Runnect/chore/v2.5.0-setup-script
[Chore] - 신규 클론 환경 자동 셋업 스크립트(bin/setup) 추가
2 parents 3d59fac + 73b8084 commit d3c9887

3 files changed

Lines changed: 144 additions & 3 deletions

File tree

CLAUDE.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
|---|---|
1818
| `Runnect-iOS/Network/Foundation/Config.swift` | 서버 baseURL, kakaoRestAPIKey, tmapAPIKey, kakaoNativeAppKey, naverMapClientId, 개발자 패스워드 |
1919
| `Runnect-iOS/Network/Foundation/AdConfig.swift` | AdMob 광고 단위 ID |
20+
| `Runnect-iOS/GoogleService-Info.plist` | Firebase 설정 |
2021

2122
**관리 흐름**:
22-
- 두 파일 모두 `.gitignore` 등록 + 메인 레포에서 추적 해제됨
23-
- 실제 값은 **별도 private 레포** `thingineeer/thingineeer-env``Runnect-env` 에서 관리
24-
- 클론 후 private 레포에서 두 파일을 가져와 동일 경로에 배치해야 빌드 가능
23+
- 위 파일 모두 `.gitignore` 등록 + 메인 레포에서 추적 해제됨
24+
- 실제 값은 **별도 private 레포** `thingineeer/thingineeer-env``Runnect-env/` 에서 관리
25+
- **신규 셋업**: `gh auth login` 후 git root 에서 `./bin/setup` 한 줄로 자동 배치
26+
- `gh` CLI 본인 계정 인증을 활용해 private 레포 접근. 권한 없는 계정은 자동 차단
2527

2628
**작업 시 주의**:
2729
- `git status --ignored` 가 아닌 일반 status 에는 안 보이지만, 실수로라도 **`git add -f` / staged 처리 / commit 금지**

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55

66
### 앱스토어 링크: [Appstore](https://apps.apple.com/kr/app/runnect-%EC%BD%94%EC%8A%A4%EB%A5%BC-%EA%B7%B8%EB%A6%AC%EA%B3%A0-%EA%B3%B5%EC%9C%A0%ED%95%98%EB%8A%94-%EB%8D%B0%EC%9D%BC%EB%A6%AC-%EB%9F%AC%EB%8B%9D%EC%95%B1/id1663884202) v2.4.3
77

8+
## 신규 셋업
9+
10+
본 레포는 public 입니다. 빌드에 필요한 secret 파일들(`Config.swift`, `AdConfig.swift`, `GoogleService-Info.plist`)은 별도 private 레포 `thingineeer/thingineeer-env``Runnect-env/` 에서 관리됩니다.
11+
12+
```bash
13+
# 1. 클론
14+
git clone https://github.com/Runnect/Runnect-iOS.git
15+
cd Runnect-iOS
16+
17+
# 2. GitHub 인증 (한 번만)
18+
gh auth login
19+
20+
# 3. 비밀 파일 자동 배치
21+
./bin/setup
22+
```
23+
24+
`./bin/setup``gh` CLI 본인 계정 인증을 사용해 private 레포에 접근하므로, 권한이 없는 계정에서는 자동 차단됩니다.
25+
826
![1](https://github.com/thingineeer/Runnect-iOS/assets/88179341/937f9e65-61e5-4298-b703-bc2cf5022bf6)
927
![2](https://github.com/thingineeer/Runnect-iOS/assets/88179341/ad913367-65f2-4839-9658-e538bccf2d6c)
1028

bin/setup

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Runnect-iOS 신규 클론 후 비밀 파일을 자동 배치.
4+
# - Config.swift (서버 baseURL, kakao/tmap/naverMap 키)
5+
# - AdConfig.swift (AdMob 광고 단위 ID)
6+
# - GoogleService-Info.plist (Firebase)
7+
#
8+
# 비밀 파일들은 private 레포 `thingineeer/thingineeer-env` 의 `Runnect-env/` 에 보관됨.
9+
# 본 스크립트는 `gh` CLI 인증을 사용하므로 해당 private 레포 접근 권한이 있는 계정만 동작.
10+
#
11+
# Usage: ./bin/setup
12+
#
13+
14+
set -euo pipefail
15+
16+
ENV_REPO="thingineeer/thingineeer-env"
17+
ENV_SUBDIR="Runnect-env"
18+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19+
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
20+
APP_DIR="${REPO_ROOT}/Runnect-iOS/Runnect-iOS"
21+
22+
# ──────────────────────────────────────────────────────────
23+
# 0. 사전 체크
24+
# ──────────────────────────────────────────────────────────
25+
26+
cyan() { printf "\033[36m%s\033[0m\n" "$*"; }
27+
green() { printf "\033[32m%s\033[0m\n" "$*"; }
28+
yellow() { printf "\033[33m%s\033[0m\n" "$*"; }
29+
red() { printf "\033[31m%s\033[0m\n" "$*"; }
30+
31+
cyan "📦 Runnect-iOS secret setup"
32+
echo " 대상 디렉토리: ${APP_DIR}"
33+
echo
34+
35+
if ! command -v gh >/dev/null 2>&1; then
36+
red "❌ gh CLI 가 필요합니다."
37+
echo " 설치: brew install gh"
38+
exit 1
39+
fi
40+
41+
if ! gh auth status >/dev/null 2>&1; then
42+
red "❌ GitHub 인증이 필요합니다."
43+
echo " 실행: gh auth login"
44+
exit 1
45+
fi
46+
47+
if [[ ! -d "${APP_DIR}" ]]; then
48+
red "❌ 잘못된 위치에서 실행 중입니다."
49+
echo " 기대 경로: ${APP_DIR}"
50+
echo " 현재 git root: ${REPO_ROOT}"
51+
exit 1
52+
fi
53+
54+
# ──────────────────────────────────────────────────────────
55+
# 1. private env repo 임시 클론
56+
# ──────────────────────────────────────────────────────────
57+
58+
TMPDIR="$(mktemp -d -t runnect-env-XXXXXX)"
59+
trap 'rm -rf "${TMPDIR}"' EXIT
60+
61+
cyan "🔐 ${ENV_REPO} 클론 중..."
62+
if ! gh repo clone "${ENV_REPO}" "${TMPDIR}/env" -- --depth=1 --quiet 2>/dev/null; then
63+
red "${ENV_REPO} 접근 불가."
64+
echo " 권한 있는 계정인지 확인하세요 (private 레포)."
65+
echo " 실행: gh auth status"
66+
exit 1
67+
fi
68+
69+
ENV_DIR="${TMPDIR}/env/${ENV_SUBDIR}"
70+
if [[ ! -d "${ENV_DIR}" ]]; then
71+
red "${ENV_REPO}/${ENV_SUBDIR} 가 없습니다."
72+
echo " private 레포 구조를 확인하세요."
73+
exit 1
74+
fi
75+
76+
# ──────────────────────────────────────────────────────────
77+
# 2. 파일 배치
78+
# ──────────────────────────────────────────────────────────
79+
80+
declare -a MAPPING=(
81+
"Config.swift|Network/Foundation/Config.swift"
82+
"AdConfig.swift|Network/Foundation/AdConfig.swift"
83+
"GoogleService-Info.plist|GoogleService-Info.plist"
84+
)
85+
86+
cyan "📋 파일 배치"
87+
for entry in "${MAPPING[@]}"; do
88+
src_name="${entry%%|*}"
89+
dst_rel="${entry##*|}"
90+
src_path="${ENV_DIR}/${src_name}"
91+
dst_path="${APP_DIR}/${dst_rel}"
92+
93+
if [[ ! -f "${src_path}" ]]; then
94+
yellow " ⚠️ 스킵: ${src_name} (env 레포에 없음)"
95+
continue
96+
fi
97+
98+
mkdir -p "$(dirname "${dst_path}")"
99+
cp "${src_path}" "${dst_path}"
100+
green "${dst_rel}"
101+
done
102+
103+
# ──────────────────────────────────────────────────────────
104+
# 3. .gitignore 처리 검증
105+
# ──────────────────────────────────────────────────────────
106+
107+
cyan "🔒 추적 상태 검증"
108+
cd "${REPO_ROOT}"
109+
for entry in "${MAPPING[@]}"; do
110+
dst_rel="${entry##*|}"
111+
rel_from_root="Runnect-iOS/Runnect-iOS/${dst_rel}"
112+
if git check-ignore -q "${rel_from_root}" 2>/dev/null; then
113+
green "${dst_rel} (gitignored)"
114+
else
115+
yellow " ⚠️ ${dst_rel} 가 .gitignore 에 없습니다. 커밋되지 않도록 주의하세요."
116+
fi
117+
done
118+
119+
echo
120+
green "✅ Setup 완료. Xcode 에서 빌드 가능합니다."
121+
echo " 메인 앱 스킴: Runnect-iOS"

0 commit comments

Comments
 (0)