#!/usr/bin/env bash # Febe for Windows: publishes Febe.exe as a single file and makes the installer and the portable zip from it. # # installer/costruisci.sh [versione] # # Runs on Linux (CI and release) as on Windows with bash: only the .NET SDK 10 is needed. No other program: the # installer is our own (src/Febe.Installer) and the same project, built for the system that builds it, makes the # package, checks it and writes the zip. The version, if not given, is the one in Directory.Build.props (the tag must # match). # Result in out/: # Febe-Setup-.exe per-user installation, without administrator rights # Febe--portabile.zip Febe.exe and LEGGIMI.txt, to copy wherever you like # Each must stay under 100 MB (the Gitea attachment limit). set -euo pipefail radice="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$radice" versione="${1:-$(sed -n 's:.*\(.*\).*:\1:p' Directory.Build.props | head -n 1)}" if [[ ! "$versione" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$ ]]; then echo "Versione non valida: «$versione» (serve x.y.z)." >&2 exit 2 fi command -v dotnet >/dev/null || { echo "Manca il .NET SDK (dotnet)." >&2; exit 2; } uscita="$radice/out" pubblicazione="$uscita/pubblicazione" installatore="$uscita/installatore" strumento="$uscita/strumento-installatore" rm -rf "$pubblicazione" "$installatore" "$strumento" mkdir -p "$pubblicazione" echo "== Pubblicazione di Febe.exe $versione (win-x64, un file solo)" dotnet publish src/Febe.Desktop/Febe.Desktop.csproj -c Release -r win-x64 --self-contained true \ -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true \ -p:Version="$versione" -nologo -o "$pubblicazione" # A single file: nothing next to the executable. solo_un_file() { local cartella="$1" nome="$2" altri altri="$(find "$cartella" -mindepth 1 ! -name "$nome")" if [[ -n "$altri" ]]; then echo "La pubblicazione ha prodotto altri file oltre a $nome:" >&2 echo "$altri" >&2 exit 1 fi } solo_un_file "$pubblicazione" Febe.exe echo "== Programma di installazione (win-x64, un file solo, ridotto)" # The publish properties (self-contained, single file, trimming, compression) are in the project. dotnet publish src/Febe.Installer/Febe.Installer.csproj -c Release -r win-x64 \ -p:Version="$versione" -nologo -o "$installatore" solo_un_file "$installatore" Febe.Installer.exe echo "== Strumento del pacchetto (per questo sistema)" dotnet build src/Febe.Installer/Febe.Installer.csproj -c Release -p:Version="$versione" -nologo -o "$strumento" pacchetto() { dotnet "$strumento/Febe.Installer.dll" "$@"; } setup="$uscita/Febe-Setup-$versione.exe" rm -f "$setup" pacchetto --impacchetta "$installatore/Febe.Installer.exe" "$pubblicazione/Febe.exe" "$versione" "$setup" pacchetto --verifica "$setup" "$pubblicazione/Febe.exe" echo "== Zip portabile" zip_portabile="$uscita/Febe-$versione-portabile.zip" rm -f "$zip_portabile" leggimi="$pubblicazione/LEGGIMI.txt" cat > "$leggimi" <= limite )); then echo "$(basename "$file") supera i 100 MB: Gitea non lo accetta come allegato." >&2 exit 1 fi done