diff --git a/scripts/package-release.sh b/scripts/package-release.sh index 443c9dd..421b8cf 100755 --- a/scripts/package-release.sh +++ b/scripts/package-release.sh @@ -125,6 +125,16 @@ strip_bin() { esac } +powershell_compress_archive() { + for ps in powershell.exe powershell pwsh.exe pwsh; do + if command -v "$ps" >/dev/null 2>&1; then + "$ps" -NoProfile -Command "Compress-Archive -Force -Path '$stage' -DestinationPath '$out_dir/$artifact'" + return 0 + fi + done + return 1 +} + for bin in "$stage"/bin/*; do strip_bin "$bin" done @@ -132,12 +142,12 @@ done printf '%s\n' "$version" >"$stage/VERSION" if [ "$os" = "windows" ]; then - if command -v powershell.exe >/dev/null 2>&1; then - powershell.exe -NoProfile -Command "Compress-Archive -Force -Path '$stage' -DestinationPath '$out_dir/$artifact'" + if powershell_compress_archive; then + : elif command -v zip >/dev/null 2>&1; then (cd "$out_dir/stage" && zip -qr "../$artifact" dosh) else - echo "windows packaging requires powershell.exe or zip" >&2 + echo "windows packaging requires PowerShell or zip" >&2 exit 1 fi else diff --git a/tests/release_scripts.rs b/tests/release_scripts.rs index 3a80a07..7061b5f 100644 --- a/tests/release_scripts.rs +++ b/tests/release_scripts.rs @@ -391,6 +391,15 @@ fn package_release_maps_windows_cross_arch_targets() { assert!(package.contains("aarch64-pc-windows-msvc")); } +#[test] +fn package_release_windows_zip_tries_classic_and_core_powershell() { + let package = include_str!("../scripts/package-release.sh"); + assert!(package.contains("powershell_compress_archive()")); + assert!(package.contains("for ps in powershell.exe powershell pwsh.exe pwsh; do")); + assert!(package.contains("\"$ps\" -NoProfile -Command")); + assert!(package.contains("windows packaging requires PowerShell or zip")); +} + #[test] fn systemd_service_does_not_sandbox_remote_shells() { let service = include_str!("../packaging/systemd/dosh-server.service");