-
Notifications
You must be signed in to change notification settings - Fork 63
/
build_pkg_automated.zsh
executable file
·120 lines (90 loc) · 3.85 KB
/
build_pkg_automated.zsh
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
#!/bin/zsh --no-rcs
# Build Support App Package
#
#
# Copyright 2024 Root3 B.V. All rights reserved.
#
# This script will build the Support App package
#
# USAGE:
# - GitHub Actions
#
# THE SOFTWARE IS PROVIDED BY ROOT3 B.V. "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
# EVENT SHALL ROOT3 B.V. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ------------------ edit the variables below this line ------------------
# Exit on error
set -e
# Current directory
current_directory=$(dirname $0)
# App Version
version=$1
# Apple ID used to notarize the package
apple_id=$2
# Apple ID password
apple_id_app_specific_password=$3
# App Name
app_name="Support"
# App Bundle Identifier
bundle_identifier="nl.root3.support"
# Path to folder with payload
payload="${current_directory}/pkgbuild/payload"
# Path to folder with scripts
scripts="${current_directory}/pkgbuild/scripts"
# Path to Component plist
component_plist="${current_directory}/pkgbuild/Support-component.plist"
# Requirements plist
requirements_plist="${current_directory}/pkgbuild/requirements.plist"
# Distribution xml
distribution_xml="${current_directory}/pkgbuild/distribution.xml"
# Install location
install_location="/Applications"
# Developer ID Installer certificate from Keychain
signing_identity="Developer ID Installer: Root3 B.V. (98LJ4XBGYK)"
# Name of the Keychain profile used for notarytool
keychain_profile="Root3"
# --------------------- do not edit below this line ----------------------
# Set Xcode version to latest version available
# xcode_version=$(ls -d /Applications/Xcode*.app 2>/dev/null | sort -V | tail -n 1)
# echo "Path to latest Xcode version: ${xcode_version}"
xcode_version="/Applications/Xcode_15.3.app"
# Create directory
mkdir -p "${current_directory}/${app_name}"
# Create directory
if [[ ! -d "${payload}" ]]; then
echo "Creating ${payload}"
mkdir "${payload}"
fi
# Move app bundle to payload folder
cp -r "${current_directory}/build/${app_name}.app" "${payload}"
# Set credentials for notarization
"${xcode_version}/Contents/Developer/usr/bin/notarytool" store-credentials --apple-id "${apple_id}" --team-id "98LJ4XBGYK" --password "${apple_id_app_specific_password}" "${keychain_profile}"
# Build and sign pkg
pkgbuild --component-plist "${component_plist}" \
--root "${payload}" \
--scripts "${scripts}" \
--install-location "${install_location}" \
--identifier "${bundle_identifier}" \
--version "${version}" \
"${current_directory}/${app_name}/${app_name}_component.pkg"
# Create distribution package to support InstallApplication MDM command
productbuild --distribution "${distribution_xml}" \
--package-path "${current_directory}/${app_name}/" \
"${current_directory}/${app_name}/${app_name} ${version}_dist.pkg"
# Sign package
productsign --sign "${signing_identity}" \
"${current_directory}/${app_name}/${app_name} ${version}_dist.pkg" \
"${current_directory}/${app_name}/${app_name} ${version}.pkg"
# Submit pkg to notarytool
"${xcode_version}/Contents/Developer/usr/bin/notarytool" submit "${current_directory}/${app_name}/${app_name} ${version}.pkg" \
--keychain-profile "${keychain_profile}" \
--wait
# Staple the notarization ticket to the pkg
"${xcode_version}/Contents/Developer/usr/bin/stapler" staple "${current_directory}/${app_name}/${app_name} ${version}.pkg"
# Check the notarization ticket validity
spctl --assess -vv --type install "${current_directory}/${app_name}/${app_name} ${version}.pkg"
# Move package to build folder
mv "${current_directory}/${app_name}/${app_name} ${version}.pkg" "${current_directory}/build"