-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-release.sh
More file actions
executable file
·112 lines (93 loc) · 3.03 KB
/
Copy pathmake-release.sh
File metadata and controls
executable file
·112 lines (93 loc) · 3.03 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
#!/bin/bash
#
# Copyright 2025 Giuseppe Rocco
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Absolute path to this script.
SCRIPT=$(readlink -f $0)
# Absolute path this script is in.
SCRIPTPATH=`dirname $SCRIPT`
# Exit on error
set -e
# Check if an archive path is provided
if [ "$#" -ne 1 ]; then
echo "❌ Error: No archive path provided."
echo "Usage: $0 <path-to-archive>"
exit 1
fi
ARCHIVE_PATH="$1"
# Check if the given archive exists
if [ ! -d "$ARCHIVE_PATH" ]; then
echo "❌ Error: The archive path '$ARCHIVE_PATH' does not exist."
exit 1
fi
# Fetching environment variables
source "${SCRIPTPATH}/.env"
if [[ -z "${FRAMEWORK_NAME}" || \
-z "${APPLE_ID}" || \
-z "${TEAM_ID}" || \
-z "${DEV_NAME}" || \
-z "${KEYCHAIN_PROFILE}" ]]; then
echo "❌ Error: Some environment variables are not set."
exit 1
fi
# To store credentials in the system keychain
# This should be already done before running the script
# xcrun notarytool store-credentials "notarytool-profile" \
# --apple-id "${APPLE_ID}" \
# --team-id "${TEAM_ID}" \
# --password "${APP_PASSWORD}"
CERTIFICATE_NAME="Developer ID Application: ${DEV_NAME} (${TEAM_ID})"
# Cleanup old builds
rm -rf "${FRAMEWORK_NAME}.xcframework" \
"${FRAMEWORK_NAME}.dmg" \
DMG
echo "🛠 ️ Creating XCFramework..."
xcodebuild -create-xcframework \
-archive "${ARCHIVE_PATH}" \
-framework "${FRAMEWORK_NAME}.framework" \
-output "./${FRAMEWORK_NAME}.xcframework"
echo "🔑 Signing XCFramework..."
find "${FRAMEWORK_NAME}.xcframework" -type f -perm +111 -exec \
codesign --force --strict --options runtime --timestamp \
--sign "$CERTIFICATE_NAME" {} \; > /dev/null 2>&1
codesign --force \
--deep \
--strict \
--options runtime \
--timestamp \
--sign "$CERTIFICATE_NAME" \
"${FRAMEWORK_NAME}.xcframework"
echo "📦 Packaging XCFramework..."
mkdir -p DMG
cp -R "${FRAMEWORK_NAME}.xcframework" DMG/
cp "${SCRIPTPATH}/LICENSE" DMG/
hdiutil create -volname "${FRAMEWORK_NAME}" \
-srcfolder ./DMG \
-format UDZO \
-ov "./${FRAMEWORK_NAME}.dmg"
echo "🔑 Signing DMG Package..."
codesign \
--force \
--sign "$CERTIFICATE_NAME" \
"${FRAMEWORK_NAME}.dmg"
echo "📤 Submitting for Notarization..."
xcrun notarytool submit "${FRAMEWORK_NAME}.dmg" \
--keychain-profile "$KEYCHAIN_PROFILE" \
--wait
echo "📎 Stapling Notarization..."
xcrun stapler staple "${FRAMEWORK_NAME}.dmg"
rm -fr DMG
rm -fr "${FRAMEWORK_NAME}.xcframework"
echo "✅ Done! XCFramework is notarized and ready for distribution."