Skip to content

Commit 00281d1

Browse files
committed
Fixed
1 parent 0f3b0c9 commit 00281d1

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

.github/workflows/generate-vicutils-docs.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,93 @@ jobs:
5757
sed -i "s/version=\"[^\"]*\"/version=\"$new_version\"/" setup.py
5858
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
5959
60+
- name: Update setup.py requirements
61+
run: |
62+
if [ -f requirements.txt ]; then
63+
echo "Updating install_requires in setup.py from requirements.txt"
64+
65+
# Read requirements and format as Python list
66+
reqs=$(grep -v '^#' requirements.txt | grep -v '^
67+
68+
- name: Generate __init__.py files automatically
69+
run: |
70+
echo "Generating __init__.py files..."
71+
find vicutils -type d | while read dir; do
72+
init_file="$dir/__init__.py"
73+
if [ ! -f "$init_file" ]; then
74+
touch "$init_file"
75+
fi
76+
echo "" > "$init_file"
77+
for py in "$dir"/*.py; do
78+
[ -f "$py" ] || continue
79+
base=$(basename "$py" .py)
80+
if [ "$base" != "__init__" ]; then
81+
echo "from .${base} import *" >> "$init_file"
82+
fi
83+
done
84+
done
85+
86+
- name: Check vicutils directory
87+
run: |
88+
echo "=== Contents of vicutils directory ==="
89+
ls -la vicutils/
90+
echo "=== Python files found ==="
91+
find vicutils/ -name "*.py" -not -name "__init__.py"
92+
93+
- name: Generate documentation
94+
run: |
95+
echo "=== Generating documentation ==="
96+
find vicutils/ -mindepth 2 -name "*.py" -not -name "__init__.py" | while read file; do
97+
dir=$(dirname "$file")
98+
basename=$(basename "$file" .py)
99+
cd "$dir"
100+
python -m pdoc --html --force --output-dir . "$basename"
101+
if [ -d "$basename" ]; then
102+
mv "$basename"/index.html "$basename.html"
103+
rm -rf "$basename"
104+
fi
105+
cd - > /dev/null
106+
done
107+
echo "=== Final vicutils contents ==="
108+
find vicutils/ -type f
109+
110+
- name: Build package
111+
run: |
112+
echo "=== Building package ==="
113+
python -m build
114+
echo "=== Build artifacts ==="
115+
ls -la dist/
116+
117+
- name: Publish to PyPI
118+
env:
119+
TWINE_USERNAME: __token__
120+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
121+
run: |
122+
python -m twine upload dist/* --skip-existing
123+
124+
- name: Commit and push if changes
125+
run: |
126+
git config --local user.name "Vic-Nas"
127+
git config --local user.email "github-actions@github.com"
128+
git add .version setup.py
129+
git add vicutils/**/*.html || echo "No HTML files to add"
130+
git add vicutils/**/*.py || echo "No Python files to add"
131+
132+
if git diff --staged --quiet; then
133+
echo "No changes to commit"
134+
else
135+
git commit -m "Auto-generate docs and bump version $NEW_VERSION"
136+
git push
137+
fi | sed 's/.*/"&"/' | paste -sd ',' -)
138+
139+
# Update install_requires in setup.py
140+
sed -i "s/install_requires=\[.*\]/install_requires=[$reqs]/" setup.py
141+
142+
echo "Updated install_requires: [$reqs]"
143+
else
144+
echo "No requirements.txt found, skipping setup.py update"
145+
fi
146+
60147
- name: Generate __init__.py files automatically
61148
run: |
62149
echo "Generating __init__.py files..."

0 commit comments

Comments
 (0)