35 lines
1.9 KiB
Bash
35 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
fail() { printf 'Error: %s\n' "$*" >&2; exit 1; }
|
|
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
|
repo_dir=$(cd -- "$script_dir/.." && pwd)
|
|
source "$script_dir/installer/services.sh"
|
|
requested=all
|
|
output=
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--output) [[ $# -gt 1 ]] || fail 'Missing output directory.'; output=$2; shift 2;;
|
|
--services) [[ $# -gt 1 ]] || fail 'Missing services.'; requested=$2; shift 2;;
|
|
--help) printf '%s\n' 'Usage: bash deploy/build-release.sh --output NEW_DIRECTORY [--services all|api-gateway,patient-profile,observation,insights,health-overview]' 'Requires .NET 10 SDK. HEALTHAPP_DOTNET may select its executable.'; exit 0;;
|
|
*) fail "Unknown argument: $1";;
|
|
esac
|
|
done
|
|
select_services "$requested"
|
|
[[ -n "$output" && ! -e "$output" ]] || fail 'Provide a new, non-existing output directory.'
|
|
dotnet_command=${HEALTHAPP_DOTNET:-dotnet}
|
|
command -v "$dotnet_command" >/dev/null || fail '.NET 10 SDK is required to build a release.'
|
|
mkdir -p -- "$output/services" "$output/systemd" "$output/examples"
|
|
output=$(cd -- "$output" && pwd)
|
|
cp -- "$script_dir/installer/"*.sh "$output/"
|
|
cp -- "$script_dir/installer/"*.ps1 "$output/"
|
|
cp -- "$script_dir/INSTALLATION.md" "$output/"
|
|
for service in "${selected_services[@]}"; do
|
|
assembly=$(assembly_for "$service")
|
|
"$dotnet_command" publish "$repo_dir/src/$assembly/$assembly.csproj" --configuration Release --self-contained false -p:UseAppHost=false --output "$output/services/$service"
|
|
cp -- "$script_dir/systemd/healthapp-$service.service" "$output/systemd/"
|
|
cp -- "$script_dir/$service.env.example" "$output/examples/"
|
|
done
|
|
"$dotnet_command" publish "$script_dir/HealthApp.Provisioning/HealthApp.Provisioning.csproj" --configuration Release --self-contained false -p:UseAppHost=false --output "$output/provisioner"
|
|
printf '%s\n' "${selected_services[@]}" > "$output/services.list"
|
|
printf 'Release created: %s\n' "$output"
|