11name : build
2+ permissions :
3+ contents : read
24
35on :
46 push :
8082 - name : Prepare Destination Device Name
8183 shell : bash
8284 run : |
83- DESTNAME=$(xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" | perl -nle 'if (m/iOS\sSimulator.*(iPhone\s[\d]{2}.*)\s\}\.*/g) { print $1; }' | sort -r | head -n 1)
84- echo Using device \"$DESTNAME\"
85+ xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" > destinations.txt
86+ SIMPLATFORM="iOS"
87+ SIMDEVICE="iPhone\s\d{2}\s"
88+ REGEX="m/\{\splatform:(.*\sSimulator),.*OS:(\d{1,2}\.\d),.*name:([a-zA-Z0-9\(\)\s]*)\s\}/g"
89+ SIMPATFORMLIST=$(cat destinations.txt | perl -nle 'if ('$REGEX') { $p = $1; $os = $2; $n = $3; if ($p =~ /'$SIMPLATFORM'/ and $n =~ /'$SIMDEVICE'/) { print "- ${n} (${p}) (${os})"; } }')
90+ echo "Available $SIMPLATFORM simulators:"
91+ echo "$SIMPATFORMLIST"
92+ DESTNAME=$(cat destinations.txt | perl -nle 'if ('$REGEX') { $p = $1; $os = $2; $n = $3; if ($1 =~ /'$SIMPLATFORM'/ and $n =~ /'$SIMDEVICE'/) { print $n; } }' | sort -r | head -n 1)
93+ echo "Using device name \"$DESTNAME\""
8594 echo "DESTNAME=$DESTNAME" >> "$GITHUB_ENV"
8695 - name : Unit Tests
8796 run : xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=iOS Simulator,name=$DESTNAME" | xcbeautify && exit ${PIPESTATUS[0]}
@@ -99,8 +108,15 @@ jobs:
99108 - name : Prepare Destination Device Name
100109 shell : bash
101110 run : |
102- DESTNAME=$(xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" | perl -nle 'if (m/tvOS\sSimulator.*(Apple\sTV\s4K.*)\s\}\.*/g) { print $1; }' | sort -r | head -n 1)
103- echo Using device \"$DESTNAME\"
111+ xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" > destinations.txt
112+ SIMPLATFORM="tvOS"
113+ SIMDEVICE="Apple\sTV"
114+ REGEX="m/\{\splatform:(.*\sSimulator),.*OS:(\d{1,2}\.\d),.*name:([a-zA-Z0-9\(\)\s]*)\s\}/g"
115+ SIMPATFORMLIST=$(cat destinations.txt | perl -nle 'if ('$REGEX') { $p = $1; $os = $2; $n = $3; if ($p =~ /'$SIMPLATFORM'/ and $n =~ /'$SIMDEVICE'/) { print "- ${n} (${p}) (${os})"; } }')
116+ echo "Available $SIMPLATFORM simulators:"
117+ echo "$SIMPATFORMLIST"
118+ DESTNAME=$(cat destinations.txt | perl -nle 'if ('$REGEX') { $p = $1; $os = $2; $n = $3; if ($1 =~ /'$SIMPLATFORM'/ and $n =~ /'$SIMDEVICE'/) { print $n; } }' | sort -r | head -n 1)
119+ echo "Using device name \"$DESTNAME\""
104120 echo "DESTNAME=$DESTNAME" >> "$GITHUB_ENV"
105121 - name : Unit Tests
106122 run : xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=tvOS Simulator,name=$DESTNAME" | xcbeautify && exit ${PIPESTATUS[0]}
@@ -118,8 +134,15 @@ jobs:
118134 - name : Prepare Destination Device Name
119135 shell : bash
120136 run : |
121- DESTNAME=$(xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" | perl -nle 'if (m/watchOS\sSimulator.*(Apple\sWatch\sSeries\s[\d]{2}.*)\s\}\.*/g) { print $1; }' | sort -r | head -n 1)
122- echo Using device \"$DESTNAME\"
137+ xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" > destinations.txt
138+ SIMPLATFORM="watchOS"
139+ SIMDEVICE="Apple\sWatch\sSeries"
140+ REGEX="m/\{\splatform:(.*\sSimulator),.*OS:(\d{1,2}\.\d),.*name:([a-zA-Z0-9\(\)\s]*)\s\}/g"
141+ SIMPATFORMLIST=$(cat destinations.txt | perl -nle 'if ('$REGEX') { $p = $1; $os = $2; $n = $3; if ($p =~ /'$SIMPLATFORM'/ and $n =~ /'$SIMDEVICE'/) { print "- ${n} (${p}) (${os})"; } }')
142+ echo "Available $SIMPLATFORM simulators:"
143+ echo "$SIMPATFORMLIST"
144+ DESTNAME=$(cat destinations.txt | perl -nle 'if ('$REGEX') { $p = $1; $os = $2; $n = $3; if ($1 =~ /'$SIMPLATFORM'/ and $n =~ /'$SIMDEVICE'/) { print $n; } }' | sort -r | head -n 1)
145+ echo "Using device name \"$DESTNAME\""
123146 echo "DESTNAME=$DESTNAME" >> "$GITHUB_ENV"
124147 - name : Unit Tests
125148 run : xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=watchOS Simulator,name=$DESTNAME" | xcbeautify && exit ${PIPESTATUS[0]}
0 commit comments