-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·47 lines (44 loc) · 2.36 KB
/
Copy pathpublish.sh
File metadata and controls
executable file
·47 lines (44 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
# Builds self-contained, dependency-free executables locally for one or more runtimes.
# Usage: ./scripts/publish.sh [rid ...]
# e.g. ./scripts/publish.sh linux-x64 win-x64 osx-arm64 osx-x64
# Output: dist/<rid>/ (and a .zip/.tar.gz next to it). No .NET needed on the target machine.
set -euo pipefail
cd "$(dirname "$0")/.."
PROJ="src/Downloader.Desktop/Downloader.Desktop.csproj"
RIDS=("$@")
[ ${#RIDS[@]} -eq 0 ] && RIDS=("linux-x64")
# Version stamped into the macOS .app bundle; override with VERSION=1.2.3 ./scripts/publish.sh ...
VERSION="${VERSION:-0.0.0-dev}"
mkdir -p dist
for RID in "${RIDS[@]}"; do
echo ">> Publishing $RID ..."
OUT="dist/$RID"
rm -rf "$OUT"
# macOS must NOT be single-file/compressed: the compressed bundle crashes on Apple Silicon when a
# managed assembly is first inflated (SIGABRT on download start). Ship loose files in the .app.
PKG_ARGS=(-p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true)
[[ "$RID" == osx-* ]] && PKG_ARGS=()
dotnet publish "$PROJ" -c Release -r "$RID" --self-contained true \
"${PKG_ARGS[@]}" \
-p:DebugType=None -p:DebugSymbols=false \
-o "$OUT"
# Nicer end-user executable name (avares URIs use the embedded assembly name, so renaming the file is safe).
if [[ "$RID" == win-* ]]; then
[ -f "$OUT/Downloader.Desktop.exe" ] && mv -f "$OUT/Downloader.Desktop.exe" "$OUT/Downloader.exe"
(cd "$OUT" && zip -qr "../Downloader-$RID.zip" ./*)
elif [[ "$RID" == osx-* ]]; then
# macOS ships a proper .app bundle (Spotlight-visible, launches detached), not a bare binary.
[ -f "$OUT/Downloader.Desktop" ] && mv -f "$OUT/Downloader.Desktop" "$OUT/Downloader"
"$(dirname "$0")/make-macos-app.sh" "$OUT" "$OUT-app" "$VERSION"
tar -czf "dist/Downloader-$RID.tar.gz" -C "$OUT-app" Downloader.app
else
[ -f "$OUT/Downloader.Desktop" ] && mv -f "$OUT/Downloader.Desktop" "$OUT/Downloader"
chmod +x "$OUT/Downloader" 2>/dev/null || true
# Ship the app icon alongside the binary so the Linux installer can register it for the
# app menu / taskbar (a raw ELF can't carry one). install.sh picks it up from here.
cp -f "src/Downloader.Desktop/Assets/downloader.png" "$OUT/downloader.png" 2>/dev/null || true
tar -czf "dist/Downloader-$RID.tar.gz" -C "$OUT" .
fi
echo ">> Done: dist/Downloader-$RID.*"
done