#!/usr/bin/env sh set -eu repo_root="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)" cd "$repo_root" version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | sed -n '1p')" out_dir="${DOSH_PACKAGE_DIR:-target/dosh-release}" artifact_version() { artifact="$1" case "$artifact" in *.tar.gz) tar -xOf "$artifact" dosh/VERSION 2>/dev/null | tr -d '\r\n' ;; *.zip) unzip -p "$artifact" dosh/VERSION 2>/dev/null | tr -d '\r\n' ;; *) return 1 ;; esac } if [ "$#" -gt 0 ]; then artifacts="$*" else artifacts="$out_dir/dosh-linux-x86_64.tar.gz $out_dir/dosh-macos-aarch64.tar.gz $out_dir/dosh-windows-x86_64.zip" fi failed=0 for artifact in $artifacts; do if [ ! -f "$artifact" ]; then echo "missing release artifact: $artifact" >&2 failed=1 continue fi if [ ! -f "$artifact.sha256" ]; then echo "missing release checksum: $artifact.sha256" >&2 failed=1 fi actual="$(artifact_version "$artifact" || true)" if [ "$actual" != "$version" ]; then echo "artifact version mismatch: $artifact has ${actual:-unknown}, expected $version" >&2 failed=1 fi done exit "$failed"