-
Notifications
You must be signed in to change notification settings - Fork 12
/
make_zips_and_appcast.sh
executable file
·82 lines (70 loc) · 2.3 KB
/
make_zips_and_appcast.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
#!/bin/sh
# If Snk.app is not found on the Desktop, quit.
APP_PATH="$HOME/Desktop/Snk.app"
if [ ! -d "$APP_PATH" ]
then
echo "\n"
echo " \033[0;31mNOT FOUND:\033[0m $APP_PATH"
echo " Export notarized Snk.app to Desktop."
echo "\n"
exit 1
fi
# Get the bundle version from the plist.
PLIST_FILE="$APP_PATH/Contents/Info.plist"
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $PLIST_FILE)
SHORT_VERSION_STRING=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $PLIST_FILE)
# Set up file names and paths.
ZIP_NAME="Snk-$SHORT_VERSION_STRING.zip"
ZIP_NAME=${ZIP_NAME// /-}
DEST_DIR="$HOME/Desktop/Snk-$SHORT_VERSION_STRING"
XML_PATH="$DEST_DIR/snk.xml"
ZIP_PATH1="$DEST_DIR/$ZIP_NAME"
ZIP_PATH2="$DEST_DIR/Snk.zip"
# Run some diagnostics so we can see all is ok."
echo ""
( set -x; spctl -vvv --assess --type exec $APP_PATH )
echo ""
( set -x; codesign -vvv --deep --strict $APP_PATH )
echo ""
( set -x; codesign -dvv $APP_PATH )
echo ""
echo "Making zips and appcast for \033[0;32m$SHORT_VERSION_STRING ($VERSION)\033[0m..."
# Make output dir (if necessary) and clear its contents.
rm -frd "$DEST_DIR"
mkdir -p "$DEST_DIR"
# Compress Snk.app and make a copy without version suffix.
ditto -c -k --rsrc --keepParent "$APP_PATH" "$ZIP_PATH1"
cp "$ZIP_PATH1" "$ZIP_PATH2"
# Get the date and zip file size for the Sparkle XML.
DATE=$(TZ=GMT date)
FILESIZE=$(stat -f "%z" "$ZIP_PATH1")
# Make the Sparkle appcast XML file.
cat > "$XML_PATH" <<EOF
<?xml version="1.0" encoding="utf-8"?>
<rss
version="2.0"
xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"
xmlns:dc="http://purl.org/dc/elements/1.1/" >
<channel>
<title>Snk Changelog</title>
<link>https://s3.amazonaws.com/mowglii/snk.xml</link>
<description>Most recent changes</description>
<language>en</language>
<item>
<title>Version $SHORT_VERSION_STRING</title>
<sparkle:minimumSystemVersion>10.16</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>https://mowglii.com/snk/changelog.html</sparkle:releaseNotesLink>
<pubDate>$DATE 0000</pubDate>
<enclosure
url="https://s3.amazonaws.com/mowglii/$ZIP_NAME"
sparkle:version="$VERSION"
sparkle:shortVersionString="$SHORT_VERSION_STRING"
length="$FILESIZE"
type="application/octet-stream" />
</item>
</channel>
</rss>
EOF
echo "Done!"
echo ""
open -R "$XML_PATH"