refactor: move plist gen into setup.py
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@@ -76,22 +76,17 @@ jobs:
|
||||
- name: Build (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
./macos/build.sh
|
||||
./setup/macos/build.sh
|
||||
|
||||
##
|
||||
# UPLOAD BUILDS
|
||||
##
|
||||
|
||||
- name: Upload binary zip (macOS)
|
||||
- name: Upload binary zip / dmg (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: novelWriter-${{ matrix.name }}-${{ env.VERSION }}.app.zip
|
||||
path: novelWriter.app.zip
|
||||
|
||||
- name: Upload dmg (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: novelWriter-${{ matrix.name }}-${{ env.VERSION }}.dmg
|
||||
path: novelWriter-${{ env.VERSION }}.dmg
|
||||
path: |
|
||||
dist_macos/novelWriter-${{ env.VERSION }}.zip
|
||||
dist_macos/novelWriter-${{ env.VERSION }}.dmg
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>True</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>novelwriter</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>novelWriter: A markdown-like text editor for planning and writing novels.</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>novelwriter.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.novelwriter.novelWriter</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>novelWriter</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.0.1</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>© 2018–2022, Veronica Berglyd Olsen <code@vkbo.net></string>
|
||||
<key>IFMajorVersion</key>
|
||||
<integer>0</integer>
|
||||
<key>IFMinorVersion</key>
|
||||
<integer>1</integer>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>nwx</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>novelWriter Project</string>
|
||||
<key>CFBundleTypeOSTypes</key>
|
||||
<array>
|
||||
<string>TEXT</string>
|
||||
<string>utxt</string>
|
||||
<string>TUTX</string>
|
||||
<string>****</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Alternate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>True</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{MACOSX_BUNDLE_EXACUTABLE_NAME}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>{MACOSX_BUNDLE_INFO_STRING}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>{MACOSX_BUNDLE_ICON_FILE}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>{MACOSX_BUNDLE_IDENTIFIER}</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>{MACOSX_BUNDLE_NAME}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{MACOSX_BUNDLE_SHORT_VERSION}</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{MACOSX_BUNDLE_VERSION}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>{MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||
<key>IFMajorVersion</key>
|
||||
<integer>0</integer>
|
||||
<key>IFMinorVersion</key>
|
||||
<integer>1</integer>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>nwx</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>novelWriter Project</string>
|
||||
<key>CFBundleTypeOSTypes</key>
|
||||
<array>
|
||||
<string>TEXT</string>
|
||||
<string>utxt</string>
|
||||
<string>TUTX</string>
|
||||
<string>****</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSHandlerRank</key>
|
||||
<string>Alternate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,26 +0,0 @@
|
||||
import os
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
SETTINGS = {
|
||||
"MACOSX_BUNDLE_COPYRIGHT": "© 2018–2022, Veronica Berglyd Olsen <code@vkbo.net>",
|
||||
"MACOSX_BUNDLE_IDENTIFIER": "io.novelwriter.novelWriter",
|
||||
"MACOSX_BUNDLE_NAME": "novelWriter",
|
||||
"MACOSX_BUNDLE_EXACUTABLE_NAME": "novelwriter",
|
||||
"MACOSX_BUNDLE_ICON_FILE": "novelwriter.icns",
|
||||
"MACOSX_BUNDLE_INFO_STRING": "novelWriter: A markdown-like text editor for planning and writing novels.",
|
||||
"MACOSX_BUNDLE_SHORT_VERSION": "2.0.1", # Must be purely numerical
|
||||
"MACOSX_BUNDLE_VERSION": "2.0.1", # Must be purely numerical
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
template_filename = os.path.join(SCRIPT_DIR, "Info.plist.in")
|
||||
with open(template_filename, "r") as tmfile:
|
||||
template = tmfile.read()
|
||||
|
||||
plist = template.format(**SETTINGS)
|
||||
|
||||
plist_filename = os.path.join(SCRIPT_DIR, "Info.plist")
|
||||
with open(plist_filename, "w") as plistfile:
|
||||
plistfile.write(plist)
|
||||
@@ -71,6 +71,25 @@ def extractVersion():
|
||||
|
||||
return numVers, hexVers, relDate
|
||||
|
||||
def extractCopyright():
|
||||
"""Extract the novelWriter copyright notice without having to import
|
||||
anything else from the main package.
|
||||
"""
|
||||
copyright = "Unknown"
|
||||
initFile = os.path.join("novelwriter", "__init__.py")
|
||||
try:
|
||||
with open(initFile, mode="r", encoding="utf-8") as inFile:
|
||||
for aLine in inFile:
|
||||
if aLine.startswith("__copyright__"):
|
||||
copyright = (aLine).partition("=")[2].strip().strip('"')
|
||||
except Exception as exc:
|
||||
print("Could not read file: %s" % initFile)
|
||||
print(str(exc))
|
||||
|
||||
print("novelWriter copyright: %s " % (copyright))
|
||||
|
||||
return copyright
|
||||
|
||||
|
||||
def compactVersion(numVers):
|
||||
"""Make the version number more compact."""
|
||||
@@ -395,6 +414,98 @@ def buildQtI18nTS(sysArgs):
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
# Generage MacOS PList
|
||||
##
|
||||
|
||||
def genMacOSPlist():
|
||||
|
||||
# Set Up Folder
|
||||
# =============
|
||||
|
||||
numVers, _, _ = extractVersion()
|
||||
pkgVers = compactVersion(numVers)
|
||||
|
||||
outDir = "setup/macos"
|
||||
|
||||
macosBundleName = "novelWriter"
|
||||
macosBundleExeName = "novelWriter"
|
||||
macosBundleInfo = "novelWriter: A markdown-like text editor for planning and writing novels."
|
||||
macosBundleIcon = "novelwriter.icns"
|
||||
macosBundleIdent = "io.novelwriter.novelWriter"
|
||||
macosBundleSVers = pkgVers
|
||||
macosBundleVers = numVers
|
||||
macosBundleCopyright = extractCopyright()
|
||||
|
||||
# These keys are no longer used but are present for compatability
|
||||
macosBundleVersMajor, macosBundleVersMinor, _ = pkgVers.split(".")
|
||||
|
||||
|
||||
plistXML = (
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
"<plist version=\"1.0\">\n"
|
||||
"<dict>\n"
|
||||
"<key>NSPrincipalClass</key>\n"
|
||||
"<string>NSApplication</string>\n"
|
||||
"<key>NSHighResolutionCapable</key>\n"
|
||||
"<string>True</string>\n"
|
||||
"<key>CFBundleDevelopmentRegion</key>\n"
|
||||
"<string>English</string>\n"
|
||||
"<key>CFBundleExecutable</key>\n"
|
||||
f"<string>{macosBundleExeName}</string>\n"
|
||||
"<key>CFBundleGetInfoString</key>\n"
|
||||
f"<string>{macosBundleInfo}</string>\n"
|
||||
"<key>CFBundleIconFile</key>\n"
|
||||
f"<string>{macosBundleIcon}</string>\n"
|
||||
"<key>CFBundleIdentifier</key>\n"
|
||||
f"<string>{macosBundleIdent}</string>\n"
|
||||
"<key>CFBundleName</key>\n"
|
||||
f"<string>{macosBundleName}</string>\n"
|
||||
"<key>CFBundleInfoDictionaryVersion</key>\n"
|
||||
"<string>6.0</string>\n"
|
||||
"<key>CFBundleShortVersionString</key>\n"
|
||||
f"<string>{macosBundleSVers}</string>\n"
|
||||
"<key>CFBundleSignature</key>\n"
|
||||
"<string>????</string>\n"
|
||||
"<key>CFBundleVersion</key>\n"
|
||||
f"<string>{macosBundleVers}</string>\n"
|
||||
"<key>CFBundlePackageType</key>\n"
|
||||
"<string>APPL</string>\n"
|
||||
"<key>NSHumanReadableCopyright</key>\n"
|
||||
f"<string>{macosBundleCopyright}</string>\n"
|
||||
"<key>IFMajorVersion</key>\n"
|
||||
f"<integer>{macosBundleVersMajor}</integer>\n"
|
||||
"<key>IFMinorVersion</key>\n"
|
||||
f"<integer>{macosBundleVersMinor}</integer>\n"
|
||||
"<key>CFBundleDocumentTypes</key>\n"
|
||||
" <array>\n"
|
||||
" <dict>\n"
|
||||
" <key>CFBundleTypeExtensions</key>\n"
|
||||
" <array>\n"
|
||||
" <string>nwx</string>\n"
|
||||
" </array>\n"
|
||||
" <key>CFBundleTypeName</key>\n"
|
||||
" <string>novelWriter Project</string>\n"
|
||||
" <key>CFBundleTypeOSTypes</key>\n"
|
||||
" <array>\n"
|
||||
" <string>TEXT</string>\n"
|
||||
" <string>utxt</string>\n"
|
||||
" <string>TUTX</string>\n"
|
||||
" <string>****</string>\n"
|
||||
" </array>\n"
|
||||
" <key>CFBundleTypeRole</key>\n"
|
||||
" <string>Viewer</string>\n"
|
||||
" <key>LSHandlerRank</key>\n"
|
||||
" <string>Alternate</string>\n"
|
||||
" </dict>\n"
|
||||
" </array>\n"
|
||||
"</dict>\n"
|
||||
"</plist>\n"
|
||||
)
|
||||
|
||||
writeFile(f"{outDir}/Info.plist", plistXML)
|
||||
|
||||
|
||||
##
|
||||
# Sample Project ZIP File Builder (sample)
|
||||
@@ -1862,6 +1973,7 @@ if __name__ == "__main__":
|
||||
" The files to be updated must be provided as arguments.",
|
||||
" qtlrelease Build the language files for internationalisation.",
|
||||
" clean-assets Delete assets built by manual, sample and qtlrelease.",
|
||||
" gen-plist Generates an Info.plist for use in a MacOS Bundle",
|
||||
"",
|
||||
"Python Packaging:",
|
||||
"",
|
||||
@@ -1943,6 +2055,10 @@ if __name__ == "__main__":
|
||||
if "clean-assets" in sys.argv:
|
||||
sys.argv.remove("clean-assets")
|
||||
cleanBuiltAssets()
|
||||
|
||||
if "gen-plist" in sys.argv:
|
||||
sys.argv.remove("gen-plist")
|
||||
genMacOSPlist()
|
||||
|
||||
# Python Packaging
|
||||
# ================
|
||||
|
||||
@@ -11,6 +11,10 @@ BUILD_DIR=$(mktemp -d "$TEMP_BASE/novelWriter-build-XXXXXX")
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
SRC_DIR="$SCRIPT_DIR/../.."
|
||||
|
||||
RLS_DIR="$SRC_DIR/dist_macos"
|
||||
|
||||
cleanup () {
|
||||
if [ -d "$BUILD_DIR" ]; then
|
||||
rm -rf "$BUILD_DIR"
|
||||
@@ -23,11 +27,11 @@ echo "Building in: $BUILD_DIR"
|
||||
|
||||
OLD_CWD="$(pwd)"
|
||||
|
||||
VERSION="$(awk '/^__version__/{print substr($NF,2,length($NF)-2)}' $SCRIPT_DIR/../novelwriter/__init__.py)"
|
||||
VERSION="$(awk '/^__version__/{print substr($NF,2,length($NF)-2)}' $SRC_DIR/novelwriter/__init__.py)"
|
||||
|
||||
pushd "$SCRIPT_DIR/../" || exit 1
|
||||
pushd "$SRC_DIR" || exit 1
|
||||
|
||||
python3 setup.py manual qtlrelease sample
|
||||
python3 setup.py manual qtlrelease sample gen-plist
|
||||
|
||||
ls -lah .
|
||||
|
||||
@@ -52,7 +56,7 @@ conda install -c conda-forge enchant hunspell-en --yes
|
||||
|
||||
echo "installing python deps ..."
|
||||
# install dependencies
|
||||
pip install -r "$SCRIPT_DIR/../requirements.txt"
|
||||
pip install -r "$SRC_DIR/requirements.txt"
|
||||
|
||||
# leave conda env
|
||||
conda deactivate
|
||||
@@ -61,7 +65,7 @@ echo "Building app bundle ..."
|
||||
# create .app Framework
|
||||
mkdir -p novelWriter.app/Contents/
|
||||
mkdir novelWriter.app/Contents/MacOS novelWriter.app/Contents/Resources novelWriter.app/Contents/Resources/novelWriter
|
||||
cp $SCRIPT_DIR/../macos/Info.plist novelWriter.app/Contents/Info.plist
|
||||
cp $SRC_DIR/setup/macos/Info.plist novelWriter.app/Contents/Info.plist
|
||||
|
||||
echo "Copying miniconda env to bundle ..."
|
||||
# copy Miniconda env
|
||||
@@ -77,13 +81,11 @@ FILES_COPY=(
|
||||
)
|
||||
|
||||
for file in "${FILES_COPY[@]}"; do
|
||||
echo "Copying $SCRIPT_DIR/../$file ..."
|
||||
cp -R $SCRIPT_DIR/../$file novelWriter.app/Contents/Resources/novelWriter/
|
||||
echo "Copying $SRC_DIR/$file ..."
|
||||
cp -R $SRC_DIR/$file novelWriter.app/Contents/Resources/novelWriter/
|
||||
done
|
||||
|
||||
cp $SCRIPT_DIR/../macos/novelwriter.icns novelWriter.app/Contents/Resources/
|
||||
#cp -R $SCRIPT_DIR/../* novelWriter.app/Contents/Resources/novelWriter/
|
||||
|
||||
cp $SRC_DIR/setup/macos/novelwriter.icns novelWriter.app/Contents/Resources/
|
||||
|
||||
# create entry script
|
||||
cat > novelWriter.app/Contents/MacOS/novelWriter <<\EOF
|
||||
@@ -123,16 +125,18 @@ popd || exit 1
|
||||
|
||||
echo "Packageing App ..."
|
||||
|
||||
mkdir -p $RLS_DIR
|
||||
|
||||
# generate .dmg
|
||||
|
||||
brew install create-dmg
|
||||
# "--skip-jenkins" is a temporary workaround for https://github.com/create-dmg/create-dmg/issues/72
|
||||
create-dmg --volname "novelWriter $VERSION" --volicon $SCRIPT_DIR/../macos/novelwriter.icns \
|
||||
create-dmg --volname "novelWriter $VERSION" --volicon $SCR_DIR/setup/macos/novelwriter.icns \
|
||||
--window-pos 200 120 --window-size 800 400 --icon-size 100 --icon novelWriter.app 200 190 --hide-extension novelWriter.app \
|
||||
--app-drop-link 600 185 novelWriter-"${VERSION}".dmg "$BUILD_DIR"/
|
||||
--app-drop-link 600 185 $RLS_DIR/novelWriter-"${VERSION}"-macos.dmg "$BUILD_DIR"/
|
||||
|
||||
pushd $BUILD_DIR || exit 1
|
||||
zip -qr novelWriter.app.zip novelWriter.app
|
||||
popd || exit 1
|
||||
|
||||
mv $BUILD_DIR/novelWriter.app.zip novelWriter.app.zip
|
||||
mv $BUILD_DIR/novelWriter.app.zip $RLS_DIR/novelWriter-"${VERSION}"-macos.zip
|
||||
@@ -16,4 +16,4 @@ done
|
||||
|
||||
png2icns $SCRIPT_DIR/novelwriter.icns $SCRIPT_DIR/icons/icon_*px.png
|
||||
|
||||
rm -r $SCRIPT_DIR/icons
|
||||
rm -r $SCRIPT_DIR/icons
|
||||
Reference in New Issue
Block a user