返回 DeepSeek-TUI-2026
check-published.sh
根目录 / scripts / release / check-published.sh
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5 repo_root="$(cd "${script_dir}/../.." && pwd)"
6 # shellcheck source=scripts/release/crates.sh
7 source "${script_dir}/crates.sh"
8
9 usage() {
10 cat <<'EOF'
11 usage: scripts/release/check-published.sh [--allow-npm-binary-mismatch] [VERSION]
12
13 Verifies that a release version is visible on both npm and crates.io.
14 Defaults VERSION to the workspace version in Cargo.toml.
15
16 Use --allow-npm-binary-mismatch only for npm packaging-only releases where
17 the npm package intentionally points at an older GitHub binary release.
18 EOF
19 }
20
21 allow_npm_binary_mismatch=0
22 version=""
23
24 while (($# > 0)); do
25 case "$1" in
26 --allow-npm-binary-mismatch)
27 allow_npm_binary_mismatch=1
28 ;;
29 -h|--help)
30 usage
31 exit 0
32 ;;
33 *)
34 if [[ -n "${version}" ]]; then
35 usage >&2
36 exit 2
37 fi
38 version="$1"
39 ;;
40 esac
41 shift
42 done
43
44 cd "${repo_root}"
45
46 if [[ -z "${version}" ]]; then
47 version="$(grep -E '^version = "' Cargo.toml | head -n1 | sed -E 's/^version = "([^"]+)".*/\1/')"
48 fi
49
50 if [[ -z "${version}" ]]; then
51 echo "Could not determine release version." >&2
52 exit 1
53 fi
54
55 fail=0
56
57 echo "Checking published release ${version}..."
58
59 if npm_version="$(npm view "deepseek-tui@${version}" version 2>/dev/null)"; then
60 echo "npm deepseek-tui@${npm_version} is published."
61 else
62 echo "npm deepseek-tui@${version} is not published." >&2
63 fail=1
64 fi
65
66 if npm_binary_version="$(npm view "deepseek-tui@${version}" deepseekBinaryVersion 2>/dev/null)"; then
67 if [[ "${npm_binary_version}" == "${version}" ]]; then
68 echo "npm deepseekBinaryVersion=${npm_binary_version}."
69 elif [[ "${allow_npm_binary_mismatch}" == "1" ]]; then
70 echo "npm deepseekBinaryVersion=${npm_binary_version} (allowed packaging-only mismatch)."
71 else
72 echo "npm deepseekBinaryVersion=${npm_binary_version}, expected ${version}." >&2
73 fail=1
74 fi
75 elif [[ "${allow_npm_binary_mismatch}" == "1" ]]; then
76 echo "npm deepseekBinaryVersion is absent (allowed packaging-only mismatch)."
77 else
78 echo "npm deepseekBinaryVersion is absent for deepseek-tui@${version}." >&2
79 fail=1
80 fi
81
82 for crate in "${release_crates[@]}"; do
83 if curl -fsSL "https://crates.io/api/v1/crates/${crate}/${version}" >/dev/null 2>&1; then
84 echo "crates.io ${crate}@${version} is published."
85 else
86 echo "crates.io ${crate}@${version} is not published." >&2
87 fail=1
88 fi
89 done
90
91 if [[ "${fail}" == "0" ]]; then
92 echo "Published release OK: npm deepseek-tui@${version} and ${#release_crates[@]} crates are visible."
93 fi
94
95 exit "${fail}"
96
96 lines BASH