-
Notifications
You must be signed in to change notification settings - Fork 131
60 lines (51 loc) · 2.1 KB
/
build-and-analyze.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Build Xcode project
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
name: Build Xcode project
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Set Default Scheme
run: |
scheme_list=$(xcodebuild -list -json | tr -d "\n")
default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]")
echo $default | cat >default
echo Using default scheme: $default
- name: Build
env:
scheme: ${{ 'ownCloud' }}
platform: ${{ 'iOS Simulator' }}
run: |
set -e # Exit immediately on any error
# Get the latest iOS version
latest_ios_version=$(xcrun simctl list devices | grep -oE '^-- iOS [0-9.]+' | awk '{print $3}' | sort -r | head -1)
# Get the first available iPhone for that iOS version
device=$(xcrun simctl list devices | grep -A 1 "^-- iOS $latest_ios_version" | grep -oE 'iPhone [^()]*' | head -1)
# Set scheme if it's default
if [ "$scheme" = "default" ]; then
scheme=$(cat default)
fi
# Find the Xcode workspace or project
if ls *.xcworkspace >/dev/null 2>&1; then
filetype_parameter="workspace"
file_to_build=$(find . -maxdepth 1 -name "*.xcworkspace" | head -1)
elif ls *.xcodeproj >/dev/null 2>&1; then
filetype_parameter="project"
file_to_build=$(find . -maxdepth 1 -name "*.xcodeproj" | head -1)
else
echo "Error: No .xcworkspace or .xcodeproj found!"
exit 1
fi
# Clean up the file name
file_to_build=$(echo "$file_to_build" | awk '{$1=$1;print}')
# Run xcodebuild with xcpretty
xcodebuild clean build analyze -scheme "$scheme" -"$filetype_parameter" "$file_to_build" -destination "platform=iOS Simulator,name=$device,OS=$latest_ios_version" ARCHS=x86_64 | xcpretty
exit ${PIPESTATUS[0]}