fix: CD steps내에 versionName 추출 로직 변경#162
Conversation
build-logic ApplicationConstants -> libs.version.toml
WalkthroughAndroid CD 워크플로우에서 앱 버전 추출 소스를 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/android-cd.yml (2)
49-51: 출력 안전성/로그 가독성 소폭 개선 제안단일 라인이어도
printf로 출력하면 개행/공백 이슈를 예방할 수 있고, 로그에는 정확한 소스 경로를 남기는 편이 추적에 유리합니다.- echo "version=v${VERSION}" >> "$GITHUB_OUTPUT" - echo "Version extracted from toml: v${VERSION}" + printf "version=v%s\n" "$VERSION" >> "$GITHUB_OUTPUT" + echo "Version extracted from gradle/libs.versions.toml: v${VERSION}"
41-51: 대안: TOML 파서를 사용해 형식 의존성 최소화가능하다면 셸 정규식 대신 TOML 파싱으로 형식 변화(공백, 주석, 순서) 내성을 높이는 방법을 고려해 주세요. GitHub 호스트 런너는 Python 3.11+가 기본 제공되므로
tomllib로 파싱 가능합니다.예시(참고용):
VERSION=$( python - <<'PY' import sys, tomllib with open("gradle/libs.versions.toml","rb") as f: data = tomllib.load(f) # versionName의 위치가 [versions] 섹션에 있다면: print(data.get("versions", {}).get("versionName","")) PY )위와 같이 추출한 뒤 현재의
-z "$VERSION"체크를 그대로 유지하면 됩니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/android-cd.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: ci-build
🔇 Additional comments (1)
.github/workflows/android-cd.yml (1)
7-11: 트리거 브랜치 확인 필요: 현재 PR은 develop 대상이지만 워크플로우는 main에만 반응PR 메타데이터상 대상 브랜치가 develop입니다. 본 워크플로우는
pull_request의branches: [main]에만 트리거되어 이 PR에서는 실행되지 않을 수 있습니다. 의도된 설정인지 확인 부탁드립니다.필요 시:
on: pull_request: branches: - - main + - main + - develop
| VERSION=$(grep "versionName" gradle/libs.versions.toml | sed -E 's/.*versionName\s*=\s*"([^"]+)".*/\1/') | ||
| if [[ -z "$VERSION" ]]; then | ||
| echo "Error: ApplicationConstants.kt에서 VERSION_NAME 값을 추출하지 못했습니다." >&2 | ||
| echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2 | ||
| exit 1 |
There was a problem hiding this comment.
pipefail + grep|sed 파이프라인으로 인해 커스텀 에러 메시지 전에 스텝이 종료될 수 있음
set -euo pipefail 상태에서 grep이 매치를 못 찾으면 파이프라인이 즉시 실패하여 아래의 -z "$VERSION" 체크와 에러 로그가 실행되지 않습니다. 또한 현재 패턴은 주석/여러 매치에 취약합니다. grep을 제거하고 sed 단독(첫 매치만)으로 앵커링된 패턴을 사용해 안전하게 추출하는 편이 좋습니다. 파일 존재 여부도 선제 체크해 주세요.
적용 제안:
- VERSION=$(grep "versionName" gradle/libs.versions.toml | sed -E 's/.*versionName\s*=\s*"([^"]+)".*/\1/')
+ # 파일 존재 여부 확인
+ if [[ ! -f gradle/libs.versions.toml ]]; then
+ echo "Error: gradle/libs.versions.toml 파일을 찾을 수 없습니다." >&2
+ exit 1
+ fi
+ # 주석/여러 매치 대비: 첫 번째 유효한 versionName만 추출
+ VERSION=$(sed -nE 's/^[[:space:]]*versionName[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' gradle/libs.versions.toml | head -n1)
if [[ -z "$VERSION" ]]; then
echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2
exit 1
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| VERSION=$(grep "versionName" gradle/libs.versions.toml | sed -E 's/.*versionName\s*=\s*"([^"]+)".*/\1/') | |
| if [[ -z "$VERSION" ]]; then | |
| echo "Error: ApplicationConstants.kt에서 VERSION_NAME 값을 추출하지 못했습니다." >&2 | |
| echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2 | |
| exit 1 | |
| # 파일 존재 여부 확인 | |
| if [[ ! -f gradle/libs.versions.toml ]]; then | |
| echo "Error: gradle/libs.versions.toml 파일을 찾을 수 없습니다." >&2 | |
| exit 1 | |
| fi | |
| # 주석/여러 매치 대비: 첫 번째 유효한 versionName만 추출 | |
| VERSION=$(sed -nE 's/^[[:space:]]*versionName[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' gradle/libs.versions.toml | head -n1) | |
| if [[ -z "$VERSION" ]]; then | |
| echo "Error: toml에서 versionName 값을 추출하지 못했습니다." >&2 | |
| exit 1 | |
| fi |
🤖 Prompt for AI Agents
.github/workflows/android-cd.yml around lines 44 to 47: the current pipeline
uses grep|sed which can cause early exit under set -euo pipefail and is fragile
to comments/multiple matches; replace the grep|sed pipeline by first checking
that gradle/libs.versions.toml exists, then use a single sed invocation that
anchors to the versionName key and extracts only the first quoted value (so
comments or multiple matches won't break it), assign that to VERSION, and then
check if VERSION is empty and emit the custom error and exit non‑zero.
build-logic ApplicationConstants -> libs.version.toml
🔗 관련 이슈
📙 작업 설명
🧪 테스트 내역 (선택)
📸 스크린샷 또는 시연 영상 (선택)
💬 추가 설명 or 리뷰 포인트 (선택)
Summary by CodeRabbit