Add a manual release workflow [skip deploy] #59
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: Deploy Docs | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| workflow_dispatch: # Allow manual triggers | |
| # Cancel in-progress runs when new commit is pushed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy: | |
| name: π Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| container: | |
| image: python:3.13 | |
| if: ${{ github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip deploy]') }} | |
| # Skip deployment if commit message contains '[skip deploy]' (only for push events) | |
| services: | |
| kroki: | |
| image: yuzutech/kroki | |
| env: | |
| KROKI_MERMAID_HOST: mermaid | |
| KROKI_BPMN_HOST: bpmn | |
| KROKI_EXCALIDRAW_HOST: excalidraw | |
| ports: | |
| - 8000:8000 | |
| mermaid: | |
| image: yuzutech/kroki-mermaid | |
| bpmn: | |
| image: yuzutech/kroki-bpmn | |
| excalidraw: | |
| image: yuzutech/kroki-excalidraw | |
| steps: | |
| - name: π₯ Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history for git-revision-date plugin | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| sparse-checkout: | | |
| docs | |
| includes | |
| overrides | |
| scripts | |
| kroki_wrapper.py | |
| code_fence_formatter.py | |
| pyproject.toml | |
| mkdocs.yml | |
| - name: π Mark repository safe for git | |
| shell: bash | |
| run: | | |
| # Allow git operations inside the runner workspace | |
| git config --global --add safe.directory "${{ github.workspace }}" | |
| git config --global --add safe.directory "$(pwd)" | |
| echo "β Git safe directories configured" | |
| - name: π€ Configure git user | |
| shell: bash | |
| run: | | |
| git config --global user.email "78714349+Eatham532@users.noreply.github.com" | |
| git config --global user.name "Eatham532" | |
| echo "β Git user configured as Eatham532" | |
| - name: π§ Setup Python environment | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python --version | |
| python -m pip install --upgrade pip setuptools wheel build | |
| - name: π¦ Install dependencies | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| python -m pip install -e . || python -m pip install . | |
| - name: π οΈ Install zip utility | |
| shell: bash | |
| run: | | |
| apt-get update && apt-get install -y zip | |
| - name: π¦ Build site for release | |
| env: | |
| KROKI_SERVER_URL: http://kroki:8000 | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if ! command -v mkdocs >/dev/null 2>&1; then | |
| echo "β ERROR: mkdocs not found on PATH" | |
| exit 1 | |
| fi | |
| echo "π¦ Building site..." | |
| mkdocs build --clean | |
| echo "β Build complete!" | |
| - name: π¦ Create site archive | |
| shell: bash | |
| run: | | |
| cd site | |
| zip -r ../site-build.zip . | |
| cd .. | |
| echo "β Site archive created" | |
| - name: π€ Upload site artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: site-build | |
| path: site-build.zip | |
| retention-days: 1 | |
| - name: π Deploy to GitHub Pages | |
| env: | |
| KROKI_SERVER_URL: http://kroki:8000 | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "π Deploying to GitHub Pages..." | |
| mkdocs gh-deploy --force --clean --remote-name origin | |
| echo "β Deployment complete!" | |
| notify-indexnow: | |
| name: π Notify Search Engines | |
| runs-on: ubuntu-latest | |
| needs: deploy # Only run after deployment succeeds | |
| if: success() && !contains(github.event.head_commit.message, '[skip indexnow]') # Only run if deployment was successful AND not skipping IndexNow | |
| steps: | |
| - name: π₯ Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history to compare with gh-pages branch | |
| ref: ${{ github.ref }} # Checkout the branch that triggered the workflow | |
| - name: π§ Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: π¦ Install requests library | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install requests | |
| - name: π Notify IndexNow of changes | |
| shell: bash | |
| run: | | |
| echo "π Notifying search engines of changed pages..." | |
| python scripts/indexnow_notify.py | |
| continue-on-error: true # Don't fail workflow if IndexNow has issues | |
| create-release: | |
| name: π¦ Create GitHub Release | |
| runs-on: ubuntu-latest | |
| needs: [deploy, notify-indexnow] # Run after deployment and notification | |
| if: success() && !contains(github.event.head_commit.message, '[skip deploy]') # Only run if deployment was successful AND not skipping deploy | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: π₯ Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history for release notes | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: π§ Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: π Get current version | |
| id: get_version | |
| shell: bash | |
| run: | | |
| current_version=$(python scripts/bump_version.py show) | |
| echo "current_version=${current_version}" >> $GITHUB_OUTPUT | |
| echo "π Current version: ${current_version}" | |
| - name: πΌ Bump patch version | |
| id: bump_version | |
| shell: bash | |
| run: | | |
| # Bump the patch version | |
| version_change=$(python scripts/bump_version.py patch) | |
| new_version=$(echo "$version_change" | cut -d' ' -f3) | |
| echo "new_version=${new_version}" >> $GITHUB_OUTPUT | |
| echo "β Version bumped: ${version_change}" | |
| - name: πΎ Commit version bump | |
| shell: bash | |
| run: | | |
| git config user.name "Eatham532" | |
| git config user.email "78714349+Eatham532@users.noreply.github.com" | |
| git add pyproject.toml | |
| git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }} [skip deploy]" | |
| git push origin main | |
| echo "β Version committed and pushed" | |
| - name: π₯ Download site artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: site-build | |
| - name: π Generate release notes | |
| id: release_notes | |
| shell: bash | |
| run: | | |
| # Get the previous tag (if exists) | |
| previous_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -z "$previous_tag" ]; then | |
| echo "π First release - including all commits" | |
| commit_range="HEAD" | |
| else | |
| echo "π Generating release notes since ${previous_tag}" | |
| commit_range="${previous_tag}..HEAD" | |
| fi | |
| # Generate commit log | |
| echo "## π Changes" > release_notes.md | |
| echo "" >> release_notes.md | |
| git log ${commit_range} --pretty=format:"- %s (%h)" --no-merges | grep -v "\[skip deploy\]" >> release_notes.md || true | |
| echo "" >> release_notes.md | |
| # Get contributors since last tag | |
| if [ -n "$previous_tag" ]; then | |
| contributors=$(git log ${commit_range} --format='%an' | sort -u | grep -v "github-actions\[bot\]" || true) | |
| if [ -n "$contributors" ]; then | |
| echo "" >> release_notes.md | |
| echo "## π₯ Contributors" >> release_notes.md | |
| echo "" >> release_notes.md | |
| echo "$contributors" | while read contributor; do | |
| echo "- $contributor" >> release_notes.md | |
| done | |
| fi | |
| fi | |
| echo "β Release notes generated" | |
| cat release_notes.md | |
| - name: π·οΈ Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.bump_version.outputs.new_version }} | |
| name: Release v${{ steps.bump_version.outputs.new_version }} | |
| body_path: release_notes.md | |
| files: | | |
| site-build.zip | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |