Repository navigation
138 lines (138 loc) · 7.1 KB
/
Copy pathios.yml
File metadata and controls
138 lines (138 loc) · 7.1 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Native iPhone
on:
workflow_dispatch:
inputs:
signed:
description: Build a signed iPhone IPA (requires Apple signing secrets)
type: boolean
default: false
push:
branches: [main]
paths: ['src/**', '.github/workflows/ios.yml', 'global.json', 'Directory.Build.props']
permissions:
contents: read
concurrency:
group: ios-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: macos-26
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.302'
- name: Select compatible Xcode and iOS workload
run: |
sudo xcode-select --switch /Applications/Xcode_26.6.app
dotnet workload install ios --version 10.0.302.1
xcodebuild -version
- name: Validate Apple manifests
run: plutil -lint src/StarfleetLibrary.Mobile/Platforms/iOS/Info.plist src/StarfleetLibrary.Mobile/Platforms/iOS/PrivacyInfo.xcprivacy
- name: Build native simulator app
if: ${{ !inputs.signed }}
# Keep Release/AOT compilation; skip expensive LLVM optimization for simulator testing only.
run: dotnet build src/StarfleetLibrary.Mobile/StarfleetLibrary.Mobile.csproj -c Release -f net10.0-ios -r iossimulator-arm64 -p:EnableCodeSigning=true -p:CodesignKey=- -p:CodesignRequireProvisioningProfile=false -p:MtouchUseLlvm=false
- name: Verify simulator code signature
if: ${{ !inputs.signed }}
run: |
APP=$(find src/StarfleetLibrary.Mobile/bin/Release/net10.0-ios/iossimulator-arm64 -maxdepth 1 -name '*.app' -print -quit)
test -n "$APP"
codesign --verify --deep --strict --verbose=2 "$APP"
- name: Install signing identity
if: ${{ inputs.signed }}
env:
CERTIFICATE: ${{ secrets.IOS_CERTIFICATE_P12_BASE64 }}
CERTIFICATE_PASSWORD: ${{ secrets.IOS_CERTIFICATE_PASSWORD }}
PROFILE: ${{ secrets.IOS_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }}
run: |
test -n "$CERTIFICATE" && test -n "$PROFILE" && test -n "$KEYCHAIN_PASSWORD"
printf '%s' "$CERTIFICATE" | base64 --decode > "$RUNNER_TEMP/signing.p12"
printf '%s' "$PROFILE" | base64 --decode > "$RUNNER_TEMP/profile.mobileprovision"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$RUNNER_TEMP/build.keychain-db"
security set-keychain-settings -lut 21600 "$RUNNER_TEMP/build.keychain-db"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$RUNNER_TEMP/build.keychain-db"
security import "$RUNNER_TEMP/signing.p12" -P "$CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k "$RUNNER_TEMP/build.keychain-db"
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" "$RUNNER_TEMP/build.keychain-db"
security list-keychains -d user -s "$RUNNER_TEMP/build.keychain-db"
mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"
cp "$RUNNER_TEMP/profile.mobileprovision" "$HOME/Library/MobileDevice/Provisioning Profiles/build.mobileprovision"
- name: Build signed iPhone app
if: ${{ inputs.signed }}
env:
SIGNING_IDENTITY: ${{ secrets.IOS_SIGNING_IDENTITY }}
PROFILE_NAME: ${{ secrets.IOS_PROFILE_NAME }}
run: dotnet publish src/StarfleetLibrary.Mobile/StarfleetLibrary.Mobile.csproj -c Release -f net10.0-ios -r ios-arm64 -p:BuildIpa=true -p:ArchiveOnBuild=true -p:CodesignKey="$SIGNING_IDENTITY" -p:CodesignProvision="$PROFILE_NAME"
- name: Package simulator application
if: ${{ !inputs.signed }}
run: |
mkdir -p artifacts
APP=$(find src/StarfleetLibrary.Mobile/bin/Release/net10.0-ios/iossimulator-arm64 -maxdepth 1 -name '*.app' -print -quit)
test -n "$APP"
ditto -c -k --sequesterRsrc --keepParent "$APP" artifacts/StarfleetLibrary-Simulator.zip
- uses: actions/upload-artifact@v4
with:
name: native-iphone-build
path: |
artifacts/*.zip
src/StarfleetLibrary.Mobile/bin/Release/net10.0-ios/ios-arm64/publish/*.ipa
src/StarfleetLibrary.Mobile/bin/Release/net10.0-ios/ios-arm64/*.ipa
if-no-files-found: error
retention-days: 14
- name: Launch in iPhone simulator
if: ${{ !inputs.signed }}
timeout-minutes: 15
run: |
DEVICE=$(xcrun simctl list devices available --json | python3 -c 'import sys,json; print(next(d["udid"] for devices in json.load(sys.stdin)["devices"].values() for d in devices if d["isAvailable"] and "iPhone" in d["name"]))')
xcrun simctl boot "$DEVICE"
xcrun simctl bootstatus "$DEVICE" -b
mkdir -p artifacts/simulator
collect_diagnostics() {
RESULT=$?
set +e
cat artifacts/simulator/app-stdout.log artifacts/simulator/app-stderr.log 2>/dev/null
xcrun simctl io "$DEVICE" screenshot artifacts/iPhone-simulator.png
if [ "$RESULT" -ne 0 ]; then
xcrun simctl spawn "$DEVICE" log show --last 5m --style compact --predicate 'process == "StarfleetLibrary.Mobile" OR eventMessage CONTAINS "StarfleetLibrary.Mobile"' > artifacts/simulator/system.log 2>&1
find "$HOME/Library/Logs/DiagnosticReports" -maxdepth 1 -name 'StarfleetLibrary.Mobile*.ips' -exec cp {} artifacts/simulator/ \;
fi
exit "$RESULT"
}
trap collect_diagnostics EXIT
APP=$(find src/StarfleetLibrary.Mobile/bin/Release/net10.0-ios/iossimulator-arm64 -maxdepth 1 -name '*.app' -print -quit)
xcrun simctl install "$DEVICE" "$APP"
LAUNCH=$(SIMCTL_CHILD_STARFLEET_CI_SMOKE=1 xcrun simctl launch --stdout="$PWD/artifacts/simulator/app-stdout.log" --stderr="$PWD/artifacts/simulator/app-stderr.log" "$DEVICE" com.calvin.starfleetlibrary.mobile)
echo "$LAUNCH"
APP_PID="${LAUNCH##*: }"
UI_READY=false
for attempt in {1..60}; do
kill -0 "$APP_PID"
# .NET iOS can route Console.WriteLine through NSLog/stderr.
if grep -q 'STARFLEET_UI_READY' artifacts/simulator/app-stdout.log artifacts/simulator/app-stderr.log; then
UI_READY=true
break
fi
sleep 2
done
if [ "$UI_READY" != true ]; then
echo 'The collection page did not finish loading.' >&2
exit 1
fi
sleep 5
kill -0 "$APP_PID"
- uses: actions/upload-artifact@v4
if: ${{ always() && !inputs.signed }}
with:
name: iphone-simulator-preview
path: |
artifacts/iPhone-simulator.png
artifacts/simulator/
if-no-files-found: error
retention-days: 14
- name: Remove temporary signing material
if: ${{ always() && inputs.signed }}
run: |
security delete-keychain "$RUNNER_TEMP/build.keychain-db" || true
rm -f "$RUNNER_TEMP/signing.p12" "$RUNNER_TEMP/profile.mobileprovision" "$HOME/Library/MobileDevice/Provisioning Profiles/build.mobileprovision"