Edit to test version ctrl #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate VicUtils Docs | |
| on: | |
| push: | |
| paths: | |
| - 'vicutils/**/*.py' | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| generate-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install pdoc | |
| run: | | |
| pip install pdoc3 | |
| echo "pdoc3 version:" | |
| pdoc --version | |
| - name: Increment version | |
| run: | | |
| # Create .version file if it doesn't exist | |
| if [ ! -f .version ]; then | |
| echo "0.1" > .version | |
| echo "Created .version file with initial version 0.1" | |
| fi | |
| # Read current version | |
| current_version=$(cat .version) | |
| echo "Current version: $current_version" | |
| # Increment version (major.minor format) | |
| IFS='.' read -r major minor <<< "$current_version" | |
| new_minor=$((minor + 1)) | |
| new_version="${major}.${new_minor}" | |
| echo "New version: $new_version" | |
| # Save new version | |
| echo "$new_version" > .version | |
| # Update setup.py | |
| sed -i "s/version=\"[^\"]*\"/version=\"$new_version\"/" setup.py | |
| echo "=== Updated files ===" | |
| echo "Version file:" | |
| cat .version | |
| echo "setup.py:" | |
| grep 'version=' setup.py | |
| - name: Check vicutils directory | |
| run: | | |
| echo "=== Contents of vicutils directory ===" | |
| ls -la vicutils/ | |
| echo "=== Python files found ===" | |
| find vicutils/ -name "*.py" -not -name "__init__.py" | |
| - name: Generate documentation | |
| run: | | |
| cd vicutils | |
| echo "=== Generating documentation ===" | |
| for file in *.py; do | |
| if [ "$file" != "__init__.py" ] && [ -f "$file" ]; then | |
| echo "Processing: $file" | |
| python -m pdoc --html --force --output-dir . "${file%.py}" | |
| echo "Contents after pdoc:" | |
| ls -la | |
| # Move generated HTML | |
| if [ -d "${file%.py}" ]; then | |
| echo "Moving ${file%.py}/index.html to ${file%.py}.html" | |
| mv "${file%.py}"/index.html "${file%.py}.html" | |
| rm -rf "${file%.py}" | |
| fi | |
| fi | |
| done | |
| cd .. | |
| echo "=== Final vicutils contents ===" | |
| ls -la vicutils/ | |
| - name: Commit and push if changes | |
| run: | | |
| git config --local user.name "Vic-Nas" | |
| git config --local user.email "github-actions@github.com" | |
| # Add all changes | |
| git add .version setup.py | |
| git add vicutils/*.html || echo "No HTML files to add" | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| new_version=$(cat .version) | |
| echo "Committing changes for version $new_version" | |
| git commit -m "Auto-generate docs and bump version to $new_version [skip ci]" | |
| git push | |
| fi |