-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·92 lines (80 loc) · 2.39 KB
/
Copy pathpublish.sh
File metadata and controls
executable file
·92 lines (80 loc) · 2.39 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# publish.sh - Clean, build, and publish diff-epr to PyPI
# Usage: ./publish.sh [test|prod]
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Determine target (test or production PyPI)
TARGET="${1:-prod}"
echo -e "${YELLOW}🧬 diff-epr PyPI Publisher${NC}"
echo "=================================="
echo ""
# Step 1: Check current version
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2)
echo -e "${GREEN}✓${NC} Current version: ${CURRENT_VERSION}"
echo ""
# Step 2: Run tests
echo -e "${YELLOW}Running tests...${NC}"
if python -m pytest tests/; then
echo -e "${GREEN}✓${NC} All tests passed!"
else
echo -e "${RED}✗${NC} Tests failed! Aborting."
exit 1
fi
echo ""
# Step 3: Clean old builds
echo -e "${YELLOW}Cleaning old builds...${NC}"
rm -rf dist/
rm -rf build/
rm -rf *.egg-info
echo -e "${GREEN}✓${NC} Cleaned dist/, build/, and *.egg-info"
echo ""
# Step 4: Build package
echo -e "${YELLOW}Building package...${NC}"
python -m build
echo -e "${GREEN}✓${NC} Package built successfully"
echo ""
# Step 5: List built files
echo -e "${YELLOW}Built files:${NC}"
ls -lh dist/
echo ""
# Step 6: Upload to PyPI
if [ "$TARGET" = "test" ]; then
echo -e "${YELLOW}Uploading to TestPyPI...${NC}"
python -m twine upload --repository testpypi dist/*
echo ""
echo -e "${GREEN}✓${NC} Uploaded to TestPyPI!"
echo ""
echo "Test installation with:"
echo " pip install --index-url https://test.pypi.org/simple/ --no-deps diff-epr"
elif [ "$TARGET" = "prod" ]; then
echo -e "${YELLOW}⚠️ About to upload to PRODUCTION PyPI${NC}"
echo "Version: ${CURRENT_VERSION}"
echo ""
read -p "Are you sure? (yes/no): " CONFIRM
if [ "$CONFIRM" = "yes" ]; then
echo ""
echo -e "${YELLOW}Uploading to PyPI...${NC}"
python -m twine upload dist/*
echo ""
echo -e "${GREEN}✓${NC} Successfully published to PyPI!"
echo ""
echo "Install with:"
echo " pip install diff-epr"
echo ""
echo "View at:"
echo " https://pypi.org/project/diff-epr/${CURRENT_VERSION}/"
else
echo -e "${RED}✗${NC} Upload cancelled."
exit 1
fi
else
echo -e "${RED}✗${NC} Invalid target: $TARGET"
echo "Usage: ./publish.sh [test|prod]"
exit 1
fi
echo ""
echo -e "${GREEN}🎉 Done!${NC}"