Skip to content

Add a manual release workflow [skip deploy] #59

Add a manual release workflow [skip deploy]

Add a manual release workflow [skip deploy] #59

Workflow file for this run

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 }}