Skip to content

Commit

Permalink
Use 7z to create more efficient ZIP archives
Browse files Browse the repository at this point in the history
For a full set of Godot 4.1.1 editor + export template builds, this saves
28 MB without affecting decompression times or archive compatibility.
Any ZIP decompression software can decompress these 7z-created ZIP archives;
they use the standard DEFLATE algorithm.

Creating archives is expected to be about twice as slow as `zip -9`,
but given the bandwidth and download time savings, it's probably worth it.
  • Loading branch information
Calinou committed Oct 25, 2023
1 parent 93d2533 commit e8d5a6f
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export basedir=$(pwd)
# For signing keystore and password.
source ./config.sh

export ZIP="7z a -bso0 -bd -mx9"

can_sign_windows=0
if [ ! -z "${SIGN_KEYSTORE}" ] && [ ! -z "${SIGN_PASSWORD}" ] && [[ $(type -P "osslsigncode") ]]; then
can_sign_windows=1
Expand Down Expand Up @@ -47,7 +49,7 @@ sign_macos() {
codesign --force --timestamp \
--options=runtime --entitlements editor.entitlements \
-s ${OSX_KEY_ID} -v ${_appname} && \
zip -r ${_binname}_signed.zip ${_appname}"
$ZIP -r ${_binname}_signed.zip ${_appname}"

_request_uuid=$(ssh "${OSX_HOST}" "xcrun altool --notarize-app --primary-bundle-id \"${OSX_BUNDLE_ID}\" --username \"${APPLE_ID}\" --password \"${APPLE_ID_PASSWORD}\" --file ${_macos_tmpdir}/${_binname}_signed.zip")
_request_uuid=$(echo ${_request_uuid} | sed -e 's/.*RequestUUID = //')
Expand All @@ -62,7 +64,7 @@ sign_macos() {
ssh "${OSX_HOST}" "
cd ${_macos_tmpdir} && \
xcrun stapler staple ${_appname} && \
zip -r ${_binname}_stapled.zip ${_appname}"
$ZIP -r ${_binname}_stapled.zip ${_appname}"
scp "${OSX_HOST}:${_macos_tmpdir}/${_binname}_stapled.zip" "${_reldir}/${_binname}.zip"
ssh "${OSX_HOST}" "rm -rf ${_macos_tmpdir}"
fi
Expand All @@ -83,7 +85,7 @@ sign_macos_template() {
codesign --force -s - \
--options=linker-signed \
-v macos_template.app/Contents/MacOS/* && \
zip -r macos_signed.zip macos_template.app"
$ZIP macos_signed.zip macos_template.app"

scp "${OSX_HOST}:${_macos_tmpdir}/macos_signed.zip" "${_reldir}/macos.zip"
ssh "${OSX_HOST}" "rm -rf ${_macos_tmpdir}"
Expand Down Expand Up @@ -242,13 +244,13 @@ if [ "${build_classical}" == "1" ]; then
binname="${godot_basename}_linux.x86_64"
cp out/linux/x86_64/tools/godot.linuxbsd.editor.x86_64 ${binname}
strip ${binname}
zip -q -9 "${reldir}/${binname}.zip" ${binname}
$ZIP "${reldir}/${binname}.zip" ${binname}
rm ${binname}

binname="${godot_basename}_linux.x86_32"
cp out/linux/x86_32/tools/godot.linuxbsd.editor.x86_32 ${binname}
strip ${binname}
zip -q -9 "${reldir}/${binname}.zip" ${binname}
$ZIP "${reldir}/${binname}.zip" ${binname}
rm ${binname}

# Templates
Expand All @@ -269,7 +271,7 @@ if [ "${build_classical}" == "1" ]; then
cp out/windows/x86_64/tools/godot.windows.editor.x86_64.console.exe ${wrpname}
strip ${wrpname}
sign_windows ${wrpname}
zip -q -9 "${reldir}/${binname}.zip" ${binname} ${wrpname}
$ZIP "${reldir}/${binname}.zip" ${binname} ${wrpname}
rm ${binname} ${wrpname}

binname="${godot_basename}_win32.exe"
Expand All @@ -280,7 +282,7 @@ if [ "${build_classical}" == "1" ]; then
cp out/windows/x86_32/tools/godot.windows.editor.x86_32.console.exe ${wrpname}
strip ${wrpname}
sign_windows ${wrpname}
zip -q -9 "${reldir}/${binname}.zip" ${binname} ${wrpname}
$ZIP "${reldir}/${binname}.zip" ${binname} ${wrpname}
rm ${binname} ${wrpname}

# Templates
Expand All @@ -303,7 +305,7 @@ if [ "${build_classical}" == "1" ]; then
mkdir -p Godot.app/Contents/MacOS
cp out/macos/tools/godot.macos.editor.universal Godot.app/Contents/MacOS/Godot
chmod +x Godot.app/Contents/MacOS/Godot
zip -q -9 -r "${reldir}/${binname}.zip" Godot.app
$ZIP -r "${reldir}/${binname}.zip" Godot.app
rm -rf Godot.app
sign_macos ${reldir} ${binname} 0

Expand All @@ -315,7 +317,7 @@ if [ "${build_classical}" == "1" ]; then
cp out/macos/templates/godot.macos.template_release.universal macos_template.app/Contents/MacOS/godot_macos_release.universal
cp out/macos/templates/godot.macos.template_debug.universal macos_template.app/Contents/MacOS/godot_macos_debug.universal
chmod +x macos_template.app/Contents/MacOS/godot_macos*
zip -q -9 -r "${templatesdir}/macos.zip" macos_template.app
$ZIP -r "${templatesdir}/macos.zip" macos_template.app
rm -rf macos_template.app
sign_macos_template ${templatesdir} 0

Expand Down Expand Up @@ -360,15 +362,15 @@ if [ "${build_classical}" == "1" ]; then
cp -r deps/vulkansdk-macos/MoltenVK/MoltenVK.xcframework ios_xcode/
rm -rf ios_xcode/MoltenVK.xcframework/{macos,tvos}*
cd ios_xcode
zip -q -9 -r "${templatesdir}/ios.zip" *
$ZIP -r "${templatesdir}/ios.zip" *
cd ..
rm -rf ios_xcode

## Templates TPZ (Classical) ##

echo "${templates_version}" > ${templatesdir}/version.txt
pushd ${templatesdir}/..
zip -q -9 -r -D "${reldir}/${godot_basename}_export_templates.tpz" templates/*
$ZIP -r "${reldir}/${godot_basename}_export_templates.tpz" templates/*
popd

## SHA-512 sums (Classical) ##
Expand All @@ -393,15 +395,15 @@ if [ "${build_mono}" == "1" ]; then
cp out/linux/x86_64/tools-mono/godot.linuxbsd.editor.x86_64.mono ${binbasename}_x86_64/${binbasename}.x86_64
strip ${binbasename}_x86_64/${binbasename}.x86_64
cp -rp out/linux/x86_64/tools-mono/GodotSharp ${binbasename}_x86_64/
zip -r -q -9 "${reldir_mono}/${binbasename}_x86_64.zip" ${binbasename}_x86_64
$ZIP -r "${reldir_mono}/${binbasename}_x86_64.zip" ${binbasename}_x86_64
rm -rf ${binbasename}_x86_64

binbasename="${godot_basename}_mono_linux"
mkdir -p ${binbasename}_x86_32
cp out/linux/x86_32/tools-mono/godot.linuxbsd.editor.x86_32.mono ${binbasename}_x86_32/${binbasename}.x86_32
strip ${binbasename}_x86_32/${binbasename}.x86_32
cp -rp out/linux/x86_32/tools-mono/GodotSharp/ ${binbasename}_x86_32/
zip -r -q -9 "${reldir_mono}/${binbasename}_x86_32.zip" ${binbasename}_x86_32
$ZIP -r "${reldir_mono}/${binbasename}_x86_32.zip" ${binbasename}_x86_32
rm -rf ${binbasename}_x86_32

# Templates
Expand All @@ -424,7 +426,7 @@ if [ "${build_mono}" == "1" ]; then
cp out/windows/x86_64/tools-mono/godot.windows.editor.x86_64.mono.console.exe ${binname}/${wrpname}.exe
strip ${binname}/${wrpname}.exe
sign_windows ${binname}/${wrpname}.exe
zip -r -q -9 "${reldir_mono}/${binname}.zip" ${binname}
$ZIP -r "${reldir_mono}/${binname}.zip" ${binname}
rm -rf ${binname}

binname="${godot_basename}_mono_win32"
Expand All @@ -437,7 +439,7 @@ if [ "${build_mono}" == "1" ]; then
cp out/windows/x86_32/tools-mono/godot.windows.editor.x86_32.mono.console.exe ${binname}/${wrpname}.exe
strip ${binname}/${wrpname}.exe
sign_windows ${binname}/${wrpname}.exe
zip -r -q -9 "${reldir_mono}/${binname}.zip" ${binname}
$ZIP "${reldir_mono}/${binname}.zip" ${binname}
rm -rf ${binname}

# Templates
Expand All @@ -461,7 +463,7 @@ if [ "${build_mono}" == "1" ]; then
cp out/macos/tools-mono/godot.macos.editor.universal.mono Godot_mono.app/Contents/MacOS/Godot
cp -rp out/macos/tools-mono/GodotSharp Godot_mono.app/Contents/Resources/GodotSharp
chmod +x Godot_mono.app/Contents/MacOS/Godot
zip -q -9 -r "${reldir_mono}/${binname}.zip" Godot_mono.app
$ZIP -r "${reldir_mono}/${binname}.zip" Godot_mono.app
rm -rf Godot_mono.app
sign_macos ${reldir_mono} ${binname} 1

Expand All @@ -472,7 +474,7 @@ if [ "${build_mono}" == "1" ]; then
cp out/macos/templates-mono/godot.macos.template_debug.universal.mono macos_template.app/Contents/MacOS/godot_macos_debug.universal
cp out/macos/templates-mono/godot.macos.template_release.universal.mono macos_template.app/Contents/MacOS/godot_macos_release.universal
chmod +x macos_template.app/Contents/MacOS/godot_macos*
zip -q -9 -r "${templatesdir_mono}/macos.zip" macos_template.app
$ZIP -r "${templatesdir_mono}/macos.zip" macos_template.app
rm -rf macos_template.app
sign_macos_template ${templatesdir_mono} 1

Expand All @@ -496,7 +498,7 @@ if [ "${build_mono}" == "1" ]; then
cp -r deps/vulkansdk-macos/MoltenVK/MoltenVK.xcframework ios_xcode/
rm -rf ios_xcode/MoltenVK.xcframework/{macos,tvos}*
cd ios_xcode
zip -q -9 -r "${templatesdir_mono}/ios.zip" *
$ZIP -r "${templatesdir_mono}/ios.zip" *
cd ..
rm -rf ios_xcode

Expand All @@ -516,7 +518,7 @@ if [ "${build_mono}" == "1" ]; then

echo "${templates_version}.mono" > ${templatesdir_mono}/version.txt
pushd ${templatesdir_mono}/..
zip -q -9 -r -D "${reldir_mono}/${godot_basename}_mono_export_templates.tpz" templates/*
$ZIP -r "${reldir_mono}/${godot_basename}_mono_export_templates.tpz" templates/*
popd

## SHA-512 sums (Mono) ##
Expand Down

0 comments on commit e8d5a6f

Please sign in to comment.