Skip to content

Commit 1c1a2d8

Browse files
committed
fix: improve cargo authentication check to properly detect login status
1 parent 47bcc6f commit 1c1a2d8

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

scripts/release.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,36 @@ check_clean_tree() {
5656

5757
# Function to check Cargo authentication
5858
check_cargo_auth() {
59-
if ! cargo login --help &> /dev/null; then
59+
if ! command -v cargo &> /dev/null; then
6060
print_error "Cargo is not available"
6161
return 1
6262
fi
6363

64-
# Check if user is logged in to crates.io
65-
if ! cargo publish --dry-run &> /dev/null; then
64+
# Check if credentials file exists
65+
local credentials_file="$HOME/.cargo/credentials.toml"
66+
if [[ ! -f "$credentials_file" ]]; then
6667
print_warning "Not logged in to crates.io"
6768
print_info "Run: cargo login"
6869
print_info "Get your API token from: https://crates.io/me"
6970
return 1
7071
fi
7172

73+
# Check if credentials file has content (not empty)
74+
if [[ ! -s "$credentials_file" ]]; then
75+
print_warning "Cargo credentials file is empty"
76+
print_info "Run: cargo login"
77+
print_info "Get your API token from: https://crates.io/me"
78+
return 1
79+
fi
80+
81+
# Try a simple cargo command that requires authentication
82+
if ! cargo search --limit 1 dummy-package-name &> /dev/null; then
83+
print_warning "Cargo authentication may have issues"
84+
print_info "Try re-running: cargo login"
85+
print_info "Or check your token at: https://crates.io/me"
86+
return 1
87+
fi
88+
7289
print_success "Cargo authentication verified"
7390
}
7491

0 commit comments

Comments
 (0)