Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 114 additions & 48 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ FG_GREEN=$(tput setaf 46)
BG_GREEN=$(tput setab 46)
RESET=$(tput sgr0)


# 1. Get the version from the first command-line argument
if [ -z "$1" ]; then
echo "Error: Please provide the version as the first argument."
Expand All @@ -27,54 +26,121 @@ echo "=== Building Object Editor v${FG_BLUE}$version${RESET} for ${FG_BLUE}$fram
# read .net version from csproj file
framework=$(grep '<TargetFramework>' Gui/Gui.csproj | sed 's/.*<TargetFramework>\(.*\)<\/TargetFramework>.*/\1/')



build_windows() {
echo "Building the ${FG_BLUE}Editor${RESET} (win-x64)"
dotnet publish Gui/Gui.csproj -c Release -p:WarningLevel=0 -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime win-x64

echo "Building the ${FG_BLUE}Updater${RESET} (win-x64)"
dotnet publish GuiUpdater/GuiUpdater.csproj -c Release -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime win-x64

echo "Copying ${FG_BLUE}Updater${RESET} files into ${FG_BLUE}Gui${RESET} folders (win-x64)"
cp GuiUpdater/bin/Release/$framework/win-x64/publish/* Gui/bin/Release/$framework/win-x64/publish

echo "Zipping ${FG_BLUE}win-x64${RESET}"
pushd "Gui/bin/Release/$framework/win-x64/publish"
zip -r "object-editor-$version-win-x64.zip" .
mv "object-editor-$version-win-x64.zip" ../../..
popd
}

build_linux() {
echo "Building the ${FG_BLUE}Editor${RESET} (linux-x64)"
dotnet publish Gui/Gui.csproj -c Release -p:WarningLevel=0 -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime linux-x64

echo "Building the ${FG_BLUE}Updater${RESET} (linux-x64)"
dotnet publish GuiUpdater/GuiUpdater.csproj -c Release -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime linux-x64

echo "Copying ${FG_BLUE}Updater${RESET} files into ${FG_BLUE}Gui${RESET} folders (linux-x64)"
cp GuiUpdater/bin/Release/$framework/linux-x64/publish/* Gui/bin/Release/$framework/linux-x64/publish

echo "Zipping ${FG_BLUE}linux-x64${RESET}"
pushd "Gui/bin/Release/$framework/linux-x64/publish"
chmod +x "./ObjectEditor"
chmod +x "./ObjectEditorUpdater"
touch "object-editor-$version-linux-x64.tar"
tar --exclude="object-editor-$version-linux-x64.tar" -jcf "object-editor-$version-linux-x64.tar" .
mv "object-editor-$version-linux-x64.tar" ../../..
Comment on lines +58 to +64
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Linux artifact is created with tar -j (bzip2 compression) but is named *.tar and the log says "Zipping". This produces a misleading filename/content-type for consumers of the build output. Rename the output to *.tar.bz2 (or drop -j if you intend an uncompressed tar) and adjust the log message accordingly.

Suggested change
echo "Zipping ${FG_BLUE}linux-x64${RESET}"
pushd "Gui/bin/Release/$framework/linux-x64/publish"
chmod +x "./ObjectEditor"
chmod +x "./ObjectEditorUpdater"
touch "object-editor-$version-linux-x64.tar"
tar --exclude="object-editor-$version-linux-x64.tar" -jcf "object-editor-$version-linux-x64.tar" .
mv "object-editor-$version-linux-x64.tar" ../../..
echo "Creating bzip2 tarball for ${FG_BLUE}linux-x64${RESET}"
pushd "Gui/bin/Release/$framework/linux-x64/publish"
chmod +x "./ObjectEditor"
chmod +x "./ObjectEditorUpdater"
touch "object-editor-$version-linux-x64.tar.bz2"
tar --exclude="object-editor-$version-linux-x64.tar.bz2" -jcf "object-editor-$version-linux-x64.tar.bz2" .
mv "object-editor-$version-linux-x64.tar.bz2" ../../..

Copilot uses AI. Check for mistakes.
popd
}

build_macos() {
# macOS bundle settings
app_name="ObjectEditor"
mac_bundle_id="com.openloco.objecteditor"
macos_publish_dir="Gui/bin/Release/$framework/osx-x64/publish"
macos_bundle_dir="$macos_publish_dir/$app_name.app"
macos_plist_template="Gui/Packaging/macOS/Info.plist"
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macos_plist_template points to Gui/Packaging/macOS/Info.plist, but that directory doesn’t exist in the repo and the variable is never used. Remove it or implement template-based plist generation to avoid dead/incorrect config.

Suggested change
macos_plist_template="Gui/Packaging/macOS/Info.plist"

Copilot uses AI. Check for mistakes.

echo "Building the ${FG_BLUE}Editor${RESET} (osx-x64)"
dotnet publish Gui/Gui.csproj -c Release -p:WarningLevel=0 -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime osx-x64

echo "Building the ${FG_BLUE}Updater${RESET} (osx-x64)"
dotnet publish GuiUpdater/GuiUpdater.csproj -c Release -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime osx-x64

echo "Copying ${FG_BLUE}Updater${RESET} files into ${FG_BLUE}Gui${RESET} folders (osx-x64)"
cp GuiUpdater/bin/Release/$framework/osx-x64/publish/* Gui/bin/Release/$framework/osx-x64/publish

echo "Creating ${FG_BLUE}macOS .app bundle${RESET}"
rm -rf "$macos_bundle_dir"
mkdir -p "$macos_bundle_dir/Contents/MacOS" "$macos_bundle_dir/Contents/Resources"
find "$macos_bundle_dir/Contents/MacOS" -mindepth 1 -exec rm -rf {} +
find "$macos_publish_dir" -mindepth 1 -maxdepth 1 \( -name "$app_name.app" -o -name "." \) -prune -o -exec cp -R {} "$macos_bundle_dir/Contents/MacOS/" \;
chmod +x "$macos_bundle_dir/Contents/MacOS/$app_name"
chmod +x "$macos_bundle_dir/Contents/MacOS/ObjectEditorUpdater"

cat > "$macos_bundle_dir/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>$app_name</string>
<key>CFBundleDisplayName</key>
<string>$app_name</string>
<key>CFBundleExecutable</key>
<string>$app_name</string>
<key>CFBundleIdentifier</key>
<string>$mac_bundle_id</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$version</string>
<key>CFBundleVersion</key>
<string>$version</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>CFBundleIconFile</key>
<string>loco_icon.icns</string>
</dict>
</plist>
EOF

if [ -f "Gui/Assets/loco_icon.icns" ]; then
cp "Gui/Assets/loco_icon.icns" "$macos_bundle_dir/Contents/Resources/"
Comment on lines +117 to +123
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated Info.plist declares CFBundleIconFile as loco_icon.icns, but the repo doesn't contain Gui/Assets/loco_icon.icns (only .ico/.png). As written, the bundle will never include the icon you declare. Either add/generate an .icns during the build (e.g., from the PNG) or update the plist/icon copy logic to match an actual bundled icon file.

Suggested change
<string>loco_icon.icns</string>
</dict>
</plist>
EOF
if [ -f "Gui/Assets/loco_icon.icns" ]; then
cp "Gui/Assets/loco_icon.icns" "$macos_bundle_dir/Contents/Resources/"
<string>loco_icon.png</string>
</dict>
</plist>
EOF
if [ -f "Gui/Assets/loco_icon.png" ]; then
cp "Gui/Assets/loco_icon.png" "$macos_bundle_dir/Contents/Resources/"

Copilot uses AI. Check for mistakes.
fi

echo "Zipping ${FG_BLUE}osx-x64${RESET}"
pushd "Gui/bin/Release/$framework/osx-x64/publish"
zip -r "object-editor-$version-osx-x64.zip" "$app_name.app"
mv "object-editor-$version-osx-x64.zip" ../../..
popd
}

# 2. Write the version to version.txt. This is read by the UI to know the current version.
echo "$version" > Gui/version.txt

# 3. Build the editor for different platforms
echo "Building the ${FG_BLUE}Editor${RESET}"
dotnet publish Gui/Gui.csproj -c Release -p:WarningLevel=0 -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime win-x64
dotnet publish Gui/Gui.csproj -c Release -p:WarningLevel=0 -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime linux-x64
dotnet publish Gui/Gui.csproj -c Release -p:WarningLevel=0 -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime osx-x64

echo "Building the ${FG_BLUE}Updater${RESET}"
dotnet publish GuiUpdater/GuiUpdater.csproj -c Release -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime win-x64
dotnet publish GuiUpdater/GuiUpdater.csproj -c Release -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime linux-x64
dotnet publish GuiUpdater/GuiUpdater.csproj -c Release -p:PublishSingleFile=true -p:Version=$version --self-contained --runtime osx-x64

# 4. Copy updater into release folders
echo "Copying ${FG_BLUE}Updater${RESET} files into ${FG_BLUE}Gui${RESET} folders"
cp GuiUpdater/bin/Release/$framework/win-x64/publish/* Gui/bin/Release/$framework/win-x64/publish
cp GuiUpdater/bin/Release/$framework/linux-x64/publish/* Gui/bin/Release/$framework/linux-x64/publish
cp GuiUpdater/bin/Release/$framework/osx-x64/publish/* Gui/bin/Release/$framework/osx-x64/publish

# 5. Create the zip and tar archives
pushd "Gui/bin/Release/$framework/"

echo "Zipping ${FG_BLUE}win-x64${RESET}"
pushd "win-x64/publish"
zip -r "object-editor-$version-win-x64.zip" .
mv "object-editor-$version-win-x64.zip" ../../..
popd

echo "Zipping ${FG_BLUE}linux-x64${RESET}"
pushd "linux-x64/publish"
chmod +x "./ObjectEditor"
chmod +x "./ObjectEditorUpdater"
# error happens if you make tar file inside the dir its zipping. hack is to touch it first then exclude it
touch "object-editor-$version-linux-x64.tar"
tar --exclude="object-editor-$version-linux-x64.tar" -jcf "object-editor-$version-linux-x64.tar" .
mv "object-editor-$version-linux-x64.tar" ../../..
popd

echo "Zipping ${FG_BLUE}osx-x64${RESET}"
pushd "osx-x64/publish"
chmod +x "./ObjectEditor"
chmod +x "./ObjectEditorUpdater"
# error happens if you make tar file inside the dir its zipping. hack is to touch it first then exclude it
touch "object-editor-$version-osx-x64.tar"
tar --exclude="object-editor-$version-osx-x64.tar" -jcf "object-editor-$version-osx-x64.tar" .
mv "object-editor-$version-osx-x64.tar" ../../..
popd

popd
# Restore dependencies first to avoid race conditions during parallel builds
dotnet restore Gui/Gui.csproj
dotnet restore GuiUpdater/GuiUpdater.csproj

# 3. Build the editor for different platforms in parallel
build_windows
build_linux
build_macos
Comment on lines +136 to +143
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet restore is run explicitly, but dotnet publish will restore again unless --no-restore is passed. This adds unnecessary work and can significantly slow CI packaging. Add --no-restore to the publishes (or remove the explicit restores if you prefer publish-driven restores).

Copilot uses AI. Check for mistakes.


echo "=== Build and packaging ${FG_GREEN}complete${RESET}! ==="