Skip to content

test: build ci

test: build ci #46

Workflow file for this run

name: iOS CI
on:
pull_request:
env:
SCHEME: DevLog
permissions:
contents: read
issues: write
pull-requests: write
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Select iOS Simulator Runtime (installed)
id: pick_ios
shell: bash
run: |
set -euo pipefail
# macOS 메인 버전에 맞는 iOS 버전 중 최신 버전의 iPhone 선택
RESULT=$(python3 - <<'PY'
import re, subprocess, sys
mac_ver = subprocess.check_output(["sw_vers", "-productVersion"], text=True).strip()
mac_major = mac_ver.split('.')[0]
text = subprocess.check_output(["xcrun", "simctl", "list", "devices"], text=True)
lines = text.splitlines()
def ver_key(v):
return tuple(int(x) for x in v.split('.'))
# 1) 최신 iOS 버전(해당 mac 메이저) 찾기
latest_ver = None
for line in lines:
header = re.match(r"^-- iOS ([0-9]+(?:\.[0-9]+)*) --$", line.strip())
if not header:
continue
ver = header.group(1)
if not ver.startswith(f"{mac_major}."):
continue
if latest_ver is None or ver_key(ver) > ver_key(latest_ver):
latest_ver = ver
if latest_ver is None:
print(f"No iOS versions found for macOS major {mac_major}", file=sys.stderr)
sys.exit(1)
# 2) 해당 버전 섹션에서 첫 iPhone 찾고 즉시 종료
current_ver = None
for line in lines:
header = re.match(r"^-- iOS ([0-9]+(?:\.[0-9]+)*) --$", line.strip())
if header:
current_ver = header.group(1)
continue
if current_ver != latest_ver:
continue
if "(unavailable)" in line:
continue
if "iPhone" in line:
name = line.strip()
print(f"{latest_ver}|{name}")
sys.exit(0)
print(f"No iPhone candidates found for iOS {latest_ver}", file=sys.stderr)
sys.exit(1)
PY
)
if [ -z "${RESULT:-}" ]; then
echo "No iPhone simulator devices detected." >&2
exit 1
fi
IFS='|' read -r IOS_VER DEVICE_NAME <<< "$RESULT"
echo "Chosen iOS runtime version (iPhone): $IOS_VER"
echo "Chosen simulator: $DEVICE_NAME"
echo "ios_version=$IOS_VER" >> "$GITHUB_OUTPUT"
echo "device_name=$DEVICE_NAME" >> "$GITHUB_OUTPUT"
- name: Build
shell: bash
run: |
set -euo pipefail
set -x
IOS_VER="${{ steps.pick_ios.outputs.ios_version }}"
DEVICE_NAME="${{ steps.pick_ios.outputs.device_name }}"
xcodebuild -version
echo "Using scheme: $SCHEME"
echo "Using simulator: $DEVICE_NAME (iOS ${IOS_VER})"
# 예시: 시뮬레이터 대상으로 빌드/테스트 시 destination에서 OS 지정
set -o pipefail
xcodebuild \
-scheme "$SCHEME" \
-configuration Debug \
-destination "platform=iOS Simulator,OS=${IOS_VER},name=${DEVICE_NAME}" \
-showBuildTimingSummary \
build \
| cat