-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_pkg.sh
More file actions
executable file
·51 lines (40 loc) · 1.33 KB
/
build_pkg.sh
File metadata and controls
executable file
·51 lines (40 loc) · 1.33 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
#!/bin/bash
set -e
# Paths
APP_PATH="/Users/takahashinaoki/Downloads/Tuner.app"
BUILD_DIR="./build"
PKG_TMP="Tuner-tmp.pkg"
PKG_FINAL="Tuner-release.pkg"
PKG_SIGNED="Tuner-release-signed.pkg"
BUNDLE_ID="dev.ensan.tuner-debug.azooKeyMac"
VERSION="1.0"
INSTALL_LOCATION="/Applications"
# Clean previous build
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
# Copy app to build dir
cp -R "$APP_PATH" "$BUILD_DIR/"
# Create component plist (only needed once, or if app structure changes)
pkgbuild --analyze --root "$BUILD_DIR" pkg.plist
# Create temporary package
pkgbuild --root "$BUILD_DIR" \
--component-plist pkg.plist \
--identifier "$BUNDLE_ID" \
--version "$VERSION" \
--install-location "$INSTALL_LOCATION" \
"$PKG_TMP"
# Create distribution XML
productbuild --synthesize --package "$PKG_TMP" distribution.xml
# Build final pkg from distribution file
productbuild --distribution distribution.xml \
--package-path . \
"$PKG_FINAL"
# Clean temporary pkg
rm "$PKG_TMP"
# Sign the final pkg
productsign --sign "Developer ID Installer" "$PKG_FINAL" "$PKG_SIGNED"
rm "$PKG_FINAL"
# Notarize (requires "Notarytool" keychain profile setup in advance)
xcrun notarytool submit "$PKG_SIGNED" --keychain-profile "Notarytool" --wait
# Staple notarization ticket
xcrun stapler staple "$PKG_SIGNED"