summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/m6c-package.sh75
-rwxr-xr-xscripts/m6c-run.sh29
2 files changed, 104 insertions, 0 deletions
diff --git a/scripts/m6c-package.sh b/scripts/m6c-package.sh
new file mode 100755
index 0000000..d887ea6
--- /dev/null
+++ b/scripts/m6c-package.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)"
+PROJECT="$REPO_ROOT/src/LivingVillage.Desktop/LivingVillage.Desktop.fsproj"
+STAMP="${M6C_TIMESTAMP:-$(date -u +%Y%m%dT%H%M%SZ)}"
+PACKAGE_ROOT="$REPO_ROOT/artifacts/m6c-release/$STAMP"
+APP_DIR="$PACKAGE_ROOT/app"
+PUBLISH_LOG="$PACKAGE_ROOT/publish.log"
+
+if [[ -e "$PACKAGE_ROOT" ]]; then
+ printf 'Refusing to overwrite existing package directory: %s\n' "$PACKAGE_ROOT" >&2
+ exit 2
+fi
+
+if ! command -v dotnet >/dev/null 2>&1; then
+ printf 'dotnet SDK is required to build the Linux package.\n' >&2
+ exit 127
+fi
+
+mkdir -p "$APP_DIR"
+
+publish_args=(
+ "$PROJECT"
+ --configuration Release
+ --runtime linux-x64
+ --output "$APP_DIR"
+ --nologo
+ -p:DebugType=None
+ -p:DebugSymbols=false
+)
+
+runtime_mode="self-contained"
+self_contained_exit=0
+if dotnet publish "${publish_args[@]}" --self-contained true >"$PUBLISH_LOG" 2>&1; then
+ :
+else
+ self_contained_exit=$?
+ runtime_mode="framework-dependent"
+ rm -rf "$APP_DIR"
+ mkdir -p "$APP_DIR"
+ if ! dotnet publish "${publish_args[@]}" --self-contained false >>"$PUBLISH_LOG" 2>&1; then
+ printf 'Both self-contained and framework-dependent publish failed. See %s\n' "$PUBLISH_LOG" >&2
+ exit 1
+ fi
+fi
+
+cp "$SCRIPT_DIR/m6c-run.sh" "$PACKAGE_ROOT/run-living-village.sh"
+chmod +x "$PACKAGE_ROOT/run-living-village.sh"
+cp "$REPO_ROOT/README.md" "$PACKAGE_ROOT/README.md"
+cp "$REPO_ROOT/docs/release-notes-m6c.md" "$PACKAGE_ROOT/RELEASE-NOTES-M6C.md"
+cp "$REPO_ROOT/docs/assets-and-licenses.md" "$PACKAGE_ROOT/ASSETS-AND-LICENSES.md"
+
+source_commit="unknown"
+if git -C "$REPO_ROOT" rev-parse HEAD >/dev/null 2>&1; then
+ source_commit="$(git -C "$REPO_ROOT" rev-parse HEAD)"
+fi
+
+{
+ printf 'package=M6c Linux x64\n'
+ printf 'created_utc=%s\n' "$STAMP"
+ printf 'source_commit=%s\n' "$source_commit"
+ printf 'runtime_mode=%s\n' "$runtime_mode"
+ printf 'rid=linux-x64\n'
+ printf 'entrypoint=run-living-village.sh\n'
+ printf 'native_desktopgl_dependencies=system-provided\n'
+ if [[ "$runtime_mode" == "framework-dependent" ]]; then
+ printf 'self_contained_publish_exit=%s\n' "$self_contained_exit"
+ printf 'framework_dependent_requirement=.NET 8 runtime\n'
+ fi
+} > "$PACKAGE_ROOT/PACKAGE-INFO.txt"
+
+printf 'M6C_PACKAGE_DIR=%s\n' "$PACKAGE_ROOT"
+printf 'M6C_RUNTIME_MODE=%s\n' "$runtime_mode"
diff --git a/scripts/m6c-run.sh b/scripts/m6c-run.sh
new file mode 100755
index 0000000..5b73c6f
--- /dev/null
+++ b/scripts/m6c-run.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
+APP_DIR="$SCRIPT_DIR/app"
+
+if [[ ! -d "$APP_DIR" ]]; then
+ printf 'M6c package app directory not found: %s\n' "$APP_DIR" >&2
+ exit 2
+fi
+
+if [[ -z "${LV_SAVE_PATH:-}" ]]; then
+ export LV_SAVE_PATH="$SCRIPT_DIR/living-village.save"
+elif [[ "$LV_SAVE_PATH" != /* ]]; then
+ export LV_SAVE_PATH="$SCRIPT_DIR/$LV_SAVE_PATH"
+fi
+
+cd "$SCRIPT_DIR"
+
+if [[ -x "$APP_DIR/LivingVillage.Desktop" ]]; then
+ exec "$APP_DIR/LivingVillage.Desktop" "$@"
+fi
+
+if [[ -f "$APP_DIR/LivingVillage.Desktop.dll" ]] && command -v dotnet >/dev/null 2>&1; then
+ exec dotnet "$APP_DIR/LivingVillage.Desktop.dll" "$@"
+fi
+
+printf 'Living Village executable not found or framework-dependent dotnet is unavailable.\n' >&2
+exit 127