forked from reflex-frp/reflex-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ios-deploy-todomvc.sh
executable file
·38 lines (32 loc) · 1.3 KB
/
ios-deploy-todomvc.sh
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
#!/usr/bin/env bash
set -euo pipefail
function cleanup {
if [ -n "$tmpdir" -a -d "$tmpdir" ]; then
echo "Cleaning up tmpdir" >&2
rm -fR $tmpdir
fi
}
trap cleanup EXIT
if [ -z "$1" ]; then
echo "Usage: ./ios-deploy-todomvc.sh [TEAM_ID]" >&2
exit 1
fi
tmpdir=$(mktemp -d)
# Find the signer given the OU
signer=$(security find-certificate -c "iPhone Developer" -a \
| grep '^ "alis"<blob>="' \
| sed 's| "alis"<blob>="\(.*\)"$|\1|' \
| while read c; do security find-certificate -c "$c" -p \
| openssl x509 -subject -noout; done \
| grep "OU=$1/" \
| sed 's|subject= /UID=[^/]*/CN=\([^/]*\).*|\1|' \
| head -n 1)
if [ -z "$signer" ]; then
echo "Error: No iPhone Developer certificate found for team id $1" >&2
exit 1
fi
mkdir -p $tmpdir/reflex-todomvc.app
cp -r `nix-build --no-out-link -A ghcIosArm64.reflex-todomvc`/reflex-todomvc.app/* $tmpdir/reflex-todomvc.app
sed "s|<team-id/>|$1|" < "$(eval "echo $(nix-instantiate --eval -E '(import ./. {}).ghcIosArm64.reflex-todomvc.src')")/reflex-todomvc.app.xcent" > $tmpdir/reflex-todomvc.app.xcent
/usr/bin/codesign --force --sign "$signer" --entitlements $tmpdir/reflex-todomvc.app.xcent --timestamp=none $tmpdir/reflex-todomvc.app
"$(nix-build --no-out-link -A nixpkgs.nodePackages.ios-deploy)/bin/ios-deploy" -W -b $tmpdir/reflex-todomvc.app