-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-cargo-token.sh
More file actions
executable file
·62 lines (54 loc) · 1.81 KB
/
setup-cargo-token.sh
File metadata and controls
executable file
·62 lines (54 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
echo "Setting up CARGO_REGISTRY_TOKEN for Rust SDK publishing"
echo "======================================================="
echo ""
# Check if gh CLI is authenticated
if ! gh auth status &>/dev/null; then
echo -e "${RED}✗ GitHub CLI not authenticated${NC}"
echo "Please run: gh auth login"
exit 1
fi
echo -e "${GREEN}✓ GitHub CLI authenticated${NC}"
# Get crates.io token
echo ""
echo -e "${YELLOW}Please provide your crates.io API token:${NC}"
echo "1. Go to https://crates.io/settings/tokens"
echo "2. Create a new token with 'publish-update' scope"
echo "3. Copy the token (starts with 'crates-io_...')"
echo ""
read -s -p "Enter your CARGO_REGISTRY_TOKEN: " CARGO_TOKEN
echo ""
if [[ -z "$CARGO_TOKEN" ]]; then
echo -e "${RED}✗ No token provided${NC}"
exit 1
fi
# Add to GitHub secrets
echo ""
echo "Adding CARGO_REGISTRY_TOKEN to GitHub secrets..."
if gh secret set CARGO_REGISTRY_TOKEN --repo hanzoai/rust-sdk --body "$CARGO_TOKEN"; then
echo -e "${GREEN}✓ Successfully added CARGO_REGISTRY_TOKEN${NC}"
else
echo -e "${RED}✗ Failed to add token${NC}"
exit 1
fi
# Verify
echo ""
echo "Verifying setup..."
if gh secret list --repo hanzoai/rust-sdk | grep -q CARGO_REGISTRY_TOKEN; then
echo -e "${GREEN}✓ CARGO_REGISTRY_TOKEN verified in GitHub secrets${NC}"
echo ""
echo "Setup complete! You can now:"
echo "1. Test with: cd ~/work/hanzo/rust-sdk && ./scripts/release-package.sh hanzo-kbs 0.1.0 --dry-run"
echo "2. Release with: cd ~/work/hanzo/rust-sdk && ./scripts/release-package.sh <package> <version>"
echo ""
echo "Monitor releases at: https://github.com/hanzoai/rust-sdk/actions"
else
echo -e "${RED}✗ Token not found after adding${NC}"
exit 1
fi