forked from Cluster444/agentic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-npm-token.sh
More file actions
executable file
Β·50 lines (41 loc) Β· 1.51 KB
/
setup-npm-token.sh
File metadata and controls
executable file
Β·50 lines (41 loc) Β· 1.51 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
#!/bin/bash
echo "π Setting up NPM_TOKEN for GitHub Actions publishing"
echo "=================================================="
REPO="ferg-cod3s/codeflow"
echo ""
echo "Step 1: Checking if you're logged into npm..."
if npm whoami >/dev/null 2>&1; then
echo "β
Already logged in as: $(npm whoami)"
else
echo "β Not logged into npm. Please run: npm login"
echo " Then rerun this script"
exit 1
fi
echo ""
echo "Step 2: Generating new NPM automation token..."
echo "Note: This will create a token with publishing permissions"
read -p "Press Enter to continue..."
# Generate token and capture it
TOKEN_OUTPUT=$(npm token create)
echo "$TOKEN_OUTPUT"
# Extract token from output (npm shows it in the output)
TOKEN=$(echo "$TOKEN_OUTPUT" | grep -o 'npm_[a-zA-Z0-9_-]*' | head -1)
if [ -z "$TOKEN" ]; then
echo "β Could not extract token. Please copy it manually from above output."
read -p "Enter the NPM token: " TOKEN
fi
if [ -n "$TOKEN" ]; then
echo ""
echo "Step 3: Setting NPM_TOKEN secret in GitHub..."
echo "$TOKEN" | gh secret set NPM_TOKEN --repo "$REPO"
if [ $? -eq 0 ]; then
echo "β
NPM_TOKEN secret set successfully!"
echo ""
echo "π Setup complete! Your GitHub Actions can now publish to NPM."
echo " Test by creating and pushing a new tag: git tag v0.22.1 && git push origin v0.22.1"
else
echo "β Failed to set secret. Please check your GitHub permissions."
fi
else
echo "β No token provided. Setup aborted."
fi