forked from eduvpn/macos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·140 lines (105 loc) · 3.71 KB
/
build.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
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
#!/bin/bash
echo "Build Script for eduVPN (and derivatives)"
#Check if HomeBrew Installed
if ! [ -x "$(command -v brew)" ]; then
echo 'Error: Homebrew is not installed. Install Homebrew Manually please ' >&2
python -mwebbrowser https://brew.sh
exit 1
fi
# Check if the Carthage is installed
if ! [ -x "$(command -v carthage)" ]; then
echo 'Carthage is not installed. Installing Carthage' >&2
brew install carthage
fi
# Install create dmg
if ! [ -x "$(command -v create-dmg)" ]; then
brew install create-dmg
fi
echo "Which target do you want to build?"
echo "1. eduVPN"
echo "2. Let's Connect!"
read -p "1-2?" choice
case "$choice" in
1 ) TARGET="eduVPN"; PRODUCT="eduVPN.app";;
2 ) TARGET="LetsConnect"; PRODUCT="Let's Connect!.app";;
* ) echo "Invalid response."; exit 0;;
esac
echo ""
echo "Which signing identity do you want to use?"
echo "1. SURFnet B.V. (ZYJ4TZX4UU)"
echo "2. Egeniq (E85CT7ZDJC)"
echo "3. Enter own Team(This isn't just a random name, but it must be exact as in their signing identity): "
read -p "1-3?" choice
# Enter custom Team ID and Team Name.
if [ "$choice" == 3 ]
then
read -p "Enter Team ID: " CUSTOMTEAMID
read -p "Enter Team Name: " CUSTOMTEAMNAME
fi
#Simple TeamID Validation. Apple Team ID always consists of 10 Characters
if ! [ "${#CUSTOMTEAMID}" == 10 ]
then
echo "Error: Team ID is not valid"
exit 1
fi
case "$choice" in
1 ) TEAMID="ZYJ4TZX4UU"; SIGNINGIDENTITY="Developer ID Application: SURFnet B.V. ($TEAMID)";;
2 ) TEAMID="E85CT7ZDJC"; SIGNINGIDENTITY="Developer ID Application: Egeniq ($TEAMID)";;
3 ) TEAMID="$CUSTOMTEAMID"; SIGNINGIDENTITY="Developer ID Application: $CUSTOMTEAMNAME ($TEAMID)";;
* ) echo "Invalid response."; exit 0;;
esac
BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo ""
echo "You are currently on branch $BRANCH."
if [[ $BRANCH != "release/"* ]]
then
echo ""
echo "You must always build from a release branch. Switch to the correct branch or ask the developer to create it for you."
exit
fi
VERSION=$(git rev-parse --abbrev-ref HEAD | cut -d "/" -f 2)
echo ""
read -p "Continue building $PRODUCT version $VERSION (using $SIGNINGIDENTITY) (y/n)?" choice
case "$choice" in
y|Y ) ;;
n|N ) exit 0;;
* ) echo "Invalid response."; exit 0;;
esac
FILENAME="$TARGET-$VERSION"
echo ""
echo "Bootstrapping dependencies using carthage"
# This is a workaround for getting Carthage to work with Xcode 10
tee ${PWD}/Carthage/64bit.xcconfig <<-'EOF'
ARCHS = $(ARCHS_STANDARD_64_BIT)
EOF
XCODE_XCCONFIG_FILE="${PWD}/Carthage/64bit.xcconfig" carthage bootstrap --cache-builds --platform macOS
echo ""
echo "Building and archiving"
xcodebuild archive -project eduVPN.xcodeproj -scheme $TARGET -archivePath $FILENAME.xcarchive DEVELOPMENT_TEAM=$TEAMID
echo ""
echo "Exporting"
/usr/libexec/PlistBuddy -c "Set :teamID \"$TEAMID\"" ExportOptions.plist
xcodebuild -exportArchive -archivePath $FILENAME.xcarchive -exportPath $FILENAME -exportOptionsPlist ExportOptions.plist
echo ""
echo "Re-signing up and down scripts"
DOWN=$(find $FILENAME -name "*.down.*.sh" -print)
codesign -f -s "$SIGNINGIDENTITY" "$DOWN"
UP=$(find $FILENAME -name "*.up.*.sh" -print)
codesign -f -s "$SIGNINGIDENTITY" "$UP"
echo ""
INSTALLERFILENAME="eduVPN-Installer$(date +"%Y-%m-%d-%H:%M:%S.")dmg"
create-dmg \
--volname "eduVPN" \
--volicon "icon.icns" \
--background "background.png" \
--window-pos 475 350 \
--window-size 475 350 \
--icon-size 100 \
--icon "eduVPN.app" 100 155 \
--hide-extension "eduVPN.app" \
--app-drop-link 370 155 \
$INSTALLERFILENAME \
$FILENAME"/eduVPN.app"
codesign -f -s "$SIGNINGIDENTITY" $INSTALLERFILENAME
echo ""
echo "Done! You can now upload the files in the updates folders to your file server. Also remember to merge the release branch into master and tag it."