ci / test (push) Has been cancelled
ci / fuzz-smoke (push) Has been cancelled
ci / windows-client (push) Has been cancelled
ci / package-release (linux-x86_64, ubuntu-latest) (push) Has been cancelled
ci / package-release (macos-aarch64, macos-14) (push) Has been cancelled
ci / package-release (macos-x86_64, macos-13) (push) Has been cancelled
ci / package-release (windows-x86_64, windows-latest) (push) Has been cancelled
ci / remote-bench (push) Has been cancelled
97 lines
2.7 KiB
Bash
Executable File
97 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
set -eu
|
|
|
|
repo_root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
|
|
cd "$repo_root"
|
|
|
|
out_dir="${DOSH_PACKAGE_DIR:-target/dosh-release}"
|
|
version="${DOSH_VERSION:-$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | sed -n '1p')}"
|
|
|
|
normalize_os() {
|
|
case "$(uname -s)" in
|
|
Darwin) printf '%s\n' macos ;;
|
|
Linux) printf '%s\n' linux ;;
|
|
FreeBSD) printf '%s\n' freebsd ;;
|
|
MINGW*|MSYS*|CYGWIN*) printf '%s\n' windows ;;
|
|
*) uname -s | tr '[:upper:]' '[:lower:]' ;;
|
|
esac
|
|
}
|
|
|
|
normalize_arch() {
|
|
case "$(uname -m)" in
|
|
x86_64|amd64) printf '%s\n' x86_64 ;;
|
|
arm64|aarch64) printf '%s\n' aarch64 ;;
|
|
armv7l) printf '%s\n' armv7 ;;
|
|
*) uname -m | tr '[:upper:]' '[:lower:]' ;;
|
|
esac
|
|
}
|
|
|
|
os="$(normalize_os)"
|
|
arch="$(normalize_arch)"
|
|
if [ "$os" = "windows" ]; then
|
|
artifact="dosh-$os-$arch.zip"
|
|
versioned_artifact="dosh-$version-$os-$arch.zip"
|
|
else
|
|
artifact="dosh-$os-$arch.tar.gz"
|
|
versioned_artifact="dosh-$version-$os-$arch.tar.gz"
|
|
fi
|
|
stage="$out_dir/stage/dosh"
|
|
|
|
if [ "$os" = "windows" ]; then
|
|
cargo build --release --bin dosh-client --bin dosh-bench
|
|
else
|
|
cargo build --release
|
|
fi
|
|
|
|
rm -rf "$stage"
|
|
mkdir -p "$stage/bin" "$out_dir"
|
|
for bin in dosh-client dosh-server dosh-auth dosh-bench; do
|
|
if [ -f "target/release/$bin" ]; then
|
|
install -m 0755 "target/release/$bin" "$stage/bin/$bin"
|
|
elif [ -f "target/release/$bin.exe" ]; then
|
|
install -m 0755 "target/release/$bin.exe" "$stage/bin/$bin.exe"
|
|
fi
|
|
done
|
|
if [ -f "$stage/bin/dosh-client.exe" ]; then
|
|
cp "$stage/bin/dosh-client.exe" "$stage/bin/dosh.exe"
|
|
elif [ -f "$stage/bin/dosh-client" ]; then
|
|
cp "$stage/bin/dosh-client" "$stage/bin/dosh"
|
|
fi
|
|
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'"
|
|
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
|
|
exit 1
|
|
fi
|
|
else
|
|
tar -C "$out_dir/stage" -czf "$out_dir/$artifact" dosh
|
|
fi
|
|
cp "$out_dir/$artifact" "$out_dir/$versioned_artifact"
|
|
|
|
write_sha256() {
|
|
file="$1"
|
|
if command -v sha256sum >/dev/null 2>&1; then
|
|
sha256sum "$file" >"$file.sha256"
|
|
elif command -v shasum >/dev/null 2>&1; then
|
|
shasum -a 256 "$file" >"$file.sha256"
|
|
else
|
|
echo "warning: sha256sum/shasum not found; skipping checksum for $file" >&2
|
|
fi
|
|
}
|
|
|
|
write_sha256 "$out_dir/$artifact"
|
|
write_sha256 "$out_dir/$versioned_artifact"
|
|
|
|
cat <<EOF
|
|
Wrote:
|
|
$out_dir/$artifact
|
|
$out_dir/$artifact.sha256
|
|
$out_dir/$versioned_artifact
|
|
$out_dir/$versioned_artifact.sha256
|
|
EOF
|