-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo
More file actions
executable file
·185 lines (153 loc) · 5 KB
/
do
File metadata and controls
executable file
·185 lines (153 loc) · 5 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env bash
COMMAND="$1"
case "$COMMAND" in
build-dev-docker)
echo "Building Docker image 'aito-python-tools'..."
docker build -t aito-python-tools -f Dockerfile.dev .
;;
run-dev-docker)
echo "Running Docker container from 'aito-python-tools' image..."
docker run -it --rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e TERM=xterm-256color \
-v "$(pwd)":/workspace \
--network host \
aito-python-tools \
bash
;;
deploy-docs)
echo "Building and deploying documentation to GitHub Pages..."
set -e
# Check we're at project root
if [[ ! -f aito/__init__.py ]]; then
echo "Error: must be run from project root directory"
exit 1
fi
# Activate virtualenv if present
if [[ -f venv/bin/activate ]]; then
echo "Activating virtual environment..."
source venv/bin/activate
fi
# Check sphinx-build is available
if ! command -v sphinx-build &> /dev/null; then
echo "Error: sphinx-build not found. Install with: pip install -r requirements/docs.txt"
exit 1
fi
# Build docs
echo "Building Sphinx documentation..."
cd docs
make clean html SPHINXOPTS="-W"
cd ..
# Get current branch and commit info
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
CURRENT_COMMIT=$(git rev-parse --short HEAD)
VERSION=$(python -c "import aito; print(aito.__version__)")
# Clone gh-pages branch to temp directory
TEMP_DIR=$(mktemp -d)
echo "Cloning gh-pages branch to $TEMP_DIR..."
git clone --branch gh-pages --single-branch --depth 1 "$(git remote get-url origin)" "$TEMP_DIR"
# Clear old content (except .git) and copy new
echo "Updating documentation..."
find "$TEMP_DIR" -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
cp -r docs/build/html/* "$TEMP_DIR/"
touch "$TEMP_DIR/.nojekyll"
# Commit and push
cd "$TEMP_DIR"
git add -A
git commit -m "Deploy docs from $CURRENT_BRANCH ($CURRENT_COMMIT) - v$VERSION" || echo "No changes to commit"
git push origin gh-pages
# Cleanup
cd -
rm -rf "$TEMP_DIR"
echo "Documentation deployed successfully!"
echo "View at: https://aitodotai.github.io/aito-python-tools/"
;;
release)
echo "Release aitoai package to PyPI"
set -e
# Check we're at project root
if [[ ! -f aito/__init__.py ]]; then
echo "Error: must be run from project root directory"
exit 1
fi
# Activate virtualenv if present
if [[ -f venv/bin/activate ]]; then
echo "Activating virtual environment..."
source venv/bin/activate
fi
# Check required tools
for cmd in twine python3; do
if ! command -v $cmd &> /dev/null; then
echo "Error: $cmd not found. Install with: pip install -r requirements/deploy.txt"
exit 1
fi
done
# Get version info
VERSION=$(python3 -c "import aito; print(aito.__version__)")
echo "Current version in code: $VERSION"
# Check PyPI for existing versions
LATEST_PYPI=$(python3 -c "import requests; versions=list(requests.get('https://pypi.org/pypi/aitoai/json').json()['releases'].keys()); print(sorted(versions)[-1])")
echo "Latest version on PyPI: $LATEST_PYPI"
if [[ "$VERSION" == "$LATEST_PYPI" ]]; then
echo "Error: Version $VERSION already exists on PyPI"
exit 1
fi
# Check git status
if [[ -n $(git status --porcelain) ]]; then
echo "Error: Working tree is dirty. Commit changes before release."
exit 1
fi
# Check we're on master
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "$BRANCH" != "master" ]]; then
echo "Warning: Not on master branch (currently on $BRANCH)"
read -p "Continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Check changelog exists for this version
if ! grep -q "^$VERSION" docs/source/changelog.rst; then
echo "Error: Changelog entry for $VERSION not found in docs/source/changelog.rst"
exit 1
fi
echo ""
echo "=== Release Checklist ==="
echo " Version: $VERSION"
echo " Branch: $BRANCH"
echo " Changelog: OK"
echo ""
read -p "Proceed with release to PyPI? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 1
fi
# Build package
echo "Building package..."
rm -rf dist/
python3 setup.py sdist bdist_wheel
twine check dist/*
# Upload to PyPI
echo "Uploading to PyPI..."
twine upload dist/*
# Deploy docs
echo "Deploying documentation..."
./do deploy-docs
# Tag release
echo "Creating git tag..."
git tag "$VERSION"
git push origin "$VERSION"
echo ""
echo "=== Release Complete ==="
echo " PyPI: https://pypi.org/project/aitoai/$VERSION/"
echo " Docs: https://aitodotai.github.io/aito-python-tools/"
echo " Tag: $VERSION"
;;
*)
echo "Usage: $0 {build-dev-docker|run-dev-docker|deploy-docs|release}"
exit 1
;;
esac