Skip to content

Instantly share code, notes, and snippets.

@anthonylavado
Last active November 3, 2021 07:21
Show Gist options
  • Save anthonylavado/e51db1e67e5c4ae047877ab4b2261cd3 to your computer and use it in GitHub Desktop.
Save anthonylavado/e51db1e67e5c4ae047877ab4b2261cd3 to your computer and use it in GitHub Desktop.
To quickly build and upload Jellyfin.app for macOS
#!/bin/bash
# Clear the destination bundle and files if they already exist
echo "[INFO] Clearing existing files..."
rm -Rf "../Jellyfin.app"
rm -Rf "../Jellyfin.dmg"
rm -Rf "Jellyfin.app"
rm -Rf "Jellyfin.dmg"
# Create the bundle and folders we need
echo "[INFO] Creating the new bundle..."
mkdir "Jellyfin.app"
# Copy the bundle support files in place
echo "[INFO] Moving support files..."
cp -Rfv "Contents" "Jellyfin.app/"
# Update the version number in the plist to be accurate
dir_name="$( find . -type d -name "jellyfin_*" -exec basename {} \; )"
version="$(awk -F'_' '{ print $NF }' <<<"${dir_name}")"
echo "[INFO] Updating .plist for version $version"
plutil -replace CFBundleVersion -string "$version" "Jellyfin.app/Contents/Info.plist"
plutil -replace CFBundleShortVersionString -string "$version" "Jellyfin.app/Contents/Info.plist"
# Copy the latest Jellyfin binary in to the correct folder
echo "[INFO] Copying Jellyfin Server..."
cp -R "$dir_name/." "Jellyfin.app/Contents/MacOS/"
# Move the web files to the resource folder
echo "[INFO] Moving jellyfin-web..."
mv "Jellyfin.app/Contents/MacOS/jellyfin-web" "Jellyfin.app/Contents/Resources/"
# Go in to the bundle and make a symlink for the resources
#echo "[INFO] Creating symlink for jellyfin-web..."
cd "Jellyfin.app/Contents/MacOS"
#ln -s "../Resources/jellyfin-web" "jellyfin-web"
cd "../../../"
# Setup some variables
APP_NAME="Jellyfin.app"
ENTITLEMENTS="Jellyfin_Server.entitlements"
SIGNING_IDENTITY="foobar" # matches Keychain Access certificate name
# # Iterate through contents that should be signed, and sign them
find "$APP_NAME/Contents/MacOS" -type f | while read fname; do
echo "[INFO] Signing $fname"
codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign $SIGNING_IDENTITY "$fname"
done
find "$APP_NAME/Contents/Frameworks" -type f | while read fname; do
echo "[INFO] Signing $fname"
codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign $SIGNING_IDENTITY "$fname"
done
echo "[INFO] Signing app file..."
codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign $SIGNING_IDENTITY "$APP_NAME"
echo "[INFO] Creating DMG..."
#appdmg jfdmg.json "Jellyfin.dmg"
create-dmg Jellyfin.app
echo "[INFO] Moving bundle and DMG..."
mv "Jellyfin.app" "../"
mv Jellyfin*.dmg "../Jellyfin.dmg"
echo "[INFO] Uploading for notarization..."
xcrun altool --notarize-app --primary-bundle-id "jellyfin-server-macos" --username "user@example.com" --password "@keychain:AC_PASSWORD" --file "../Jellyfin.dmg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment