test: build ci #39
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 | |
| # 런타임 키를 오름차순으로 정렬하고, iPhone 시뮬레이터가 있으면 선택 | |
| RESULT=$(python3 - <<'PY' | |
| import json, subprocess, sys | |
| devices = json.loads(subprocess.check_output(["xcrun", "simctl", "list", "devices", "-j"], text=True)).get("devices", {}) | |
| def is_available(d): | |
| return d.get("isAvailable") or d.get("availability") == "(available)" | |
| def parse_runtime(runtime_key): | |
| # com.apple.CoreSimulator.SimRuntime.iOS-17-2 -> ([17, 2], "17.2") | |
| if "iOS-" not in runtime_key: | |
| return None | |
| parts = runtime_key.split("iOS-")[-1].split("-") | |
| try: | |
| nums = [int(p) for p in parts] | |
| except ValueError: | |
| return None | |
| return nums, ".".join(str(n) for n in nums) | |
| runtimes = [] | |
| for key in devices.keys(): | |
| parsed = parse_runtime(key) | |
| if parsed is None: | |
| continue | |
| nums, ver = parsed | |
| runtimes.append((nums, ver, key)) | |
| for _, ver, key in sorted(runtimes, key=lambda x: x[0]): | |
| for d in devices.get(key, []): | |
| if is_available(d) and "iPhone" in d.get("name", ""): | |
| print(f"{ver}|{d['name']}") | |
| sys.exit(0) | |
| 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 |