Files
曾志威 245a54057a
continuous-integration/drone/push Build was killed
fix: make Drone pipeline compatible
2026-09-04 00:59:10 +08:00

69 lines
2.3 KiB
Bash

#!/bin/sh
set -eu
repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
artifacts_root="$repo_root/artifacts"
build_root="$repo_root/target/package-macos"
binary_source="$repo_root/target/release/remotedesk-native"
case "$build_root" in
"$repo_root"/target/*) ;;
*) echo "unsafe build directory: $build_root" >&2; exit 1 ;;
esac
case "$(uname -m)" in
x86_64) architecture=x64 ;;
arm64|aarch64) architecture=arm64 ;;
*) echo "unsupported macOS architecture: $(uname -m)" >&2; exit 1 ;;
esac
package_id=$(cargo pkgid -p remotedesk-native-gui --manifest-path "$repo_root/Cargo.toml")
version=${package_id##*@}
case "$version" in
''|*[!0-9A-Za-z._-]*) echo "unsafe package version: $version" >&2; exit 1 ;;
esac
package_name="RemoteDesk-${version}-macos-${architecture}"
package_root="$build_root/$package_name"
archive="$artifacts_root/$package_name.tar.gz"
rm -rf -- "$build_root"
rm -f -- "$archive" "$archive.sha256"
mkdir -p "$package_root" "$artifacts_root"
cargo build --locked --release --manifest-path "$repo_root/Cargo.toml" \
-p remotedesk-native-gui
if [ ! -x "$binary_source" ]; then
echo "macOS native GUI binary was not generated: $binary_source" >&2
exit 1
fi
install -m 0755 "$binary_source" "$package_root/RemoteDesk"
cat > "$package_root/README.txt" <<'EOF'
RemoteDesk macOS native client
This package is an unsigned development build. Run ./RemoteDesk from a macOS
desktop session. macOS screen capture, hardware media validation, signing, and
notarization are separate release requirements.
EOF
printf '{"product":"RemoteDesk","version":"%s","target":"macos-%s","binary":"RemoteDesk","signed":false}\n' \
"$version" "$architecture" > "$package_root/manifest.json"
{
find "$package_root" -type f -print | sort | while IFS= read -r file; do
relative=${file#"$package_root/"}
hash=$(shasum -a 256 "$file" | awk '{print $1}')
printf '%s %s\n' "$hash" "$relative"
done
} > "$package_root/SHA256SUMS.txt"
tar -czf "$archive" -C "$build_root" "$package_name"
archive_hash=$(shasum -a 256 "$archive" | awk '{print $1}')
printf '%s %s\n' "$archive_hash" "$(basename "$archive")" > "$archive.sha256"
(cd "$artifacts_root" && shasum -a 256 -c "$(basename "$archive.sha256")")
printf 'Package: %s\n' "$archive"
printf 'SHA256: %s\n' "$archive_hash"