test: build ci #27
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: iOS CI | |
| on: | |
| pull_request: | |
| env: | |
| SCHEME: DevLog | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| build: | |
| runs-on: macos-14 # iOS 17 시뮬레이터 런타임 포함 | |
| 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 | |
| # 설치된 iOS Simulator 런타임 버전들 추출 (예: 17.2, 18.0 ...) | |
| # 출력 포맷이 달라질 수 있어, "iOS <version>" 패턴에서 숫자만 뽑습니다. | |
| versions=() | |
| while IFS= read -r v; do | |
| versions+=("$v") | |
| done < <( | |
| xcrun simctl runtime list 2>/dev/null \ | |
| | grep -Eo 'iOS ([0-9]+(\.[0-9]+)*)' \ | |
| | awk '{print $2}' \ | |
| | sort -V \ | |
| | uniq | |
| ) | |
| if [ "${#versions[@]}" -eq 0 ]; then | |
| echo "No iOS simulator runtimes detected." >&2 | |
| exit 1 | |
| fi | |
| # 실제 존재하는 런타임 중 가장 낮은 버전 선택 | |
| MIN_IOS="${versions[0]}" | |
| chosen="$MIN_IOS" | |
| echo "Detected runtimes: ${versions[*]:-<none>}" | |
| echo "Chosen iOS runtime version: $chosen" | |
| echo "ios_version=$chosen" >> "$GITHUB_OUTPUT" | |
| - name: Build | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| set -x | |
| IOS_VER="${{ steps.pick_ios.outputs.ios_version }}" | |
| export IOS_VER | |
| xcodebuild -version | |
| echo "Using scheme: $SCHEME" | |
| # 선택된 iOS 런타임에서 'iPhone'이 포함된 첫 번째 시뮬레이터 이름 선택 (JSON 파싱) | |
| DEVICE_INFO=$(python3 - <<'PY' | |
| import json, os, subprocess, sys | |
| ios_ver = os.environ['IOS_VER'] | |
| prefix = f"com.apple.CoreSimulator.SimRuntime.iOS-{ios_ver.replace('.', '-') }" | |
| data = subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True) | |
| j = json.loads(data) | |
| for runtime, devices in j.get("devices", {}).items(): | |
| if not runtime.startswith(prefix): | |
| continue | |
| for d in devices: | |
| if d.get("isAvailable") and "iPhone" in d.get("name", ""): | |
| os_ver = runtime.split("iOS-")[-1].replace("-", ".") | |
| print(f"{d['name']}|{os_ver}") | |
| sys.exit(0) | |
| sys.exit(1) | |
| PY | |
| ) | |
| IFS='|' read -r DEVICE_NAME DEVICE_OS <<< "$DEVICE_INFO" | |
| IOS_VER="$DEVICE_OS" | |
| export IOS_VER | |
| if [ -z "${DEVICE_NAME:-}" ] || [ -z "${IOS_VER:-}" ]; then | |
| echo "No available simulator device found for iOS ${IOS_VER}." >&2 | |
| exit 1 | |
| fi | |
| 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 |