-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add multi-version documentation support #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| name: Build and deploy multi-version OpenSPP documentation | ||
|
|
||
| # This workflow builds and deploys multi-version documentation: | ||
| # - v2.0 (latest) from v2-odoo19-doc-refresh branch → root (/) | ||
| # - v1.3 from stable branch → /v1.3/ | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - stable # Only run on stable branch | ||
| workflow_dispatch: # Allow manual trigger | ||
|
|
||
| jobs: | ||
| build_multiversion: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout stable branch | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| ref: stable | ||
| fetch-depth: 0 # Fetch all history for branch switching | ||
| submodules: true | ||
|
|
||
| - name: Set up Python 3.10 | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.10' | ||
|
|
||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y graphviz libsasl2-dev libldap2-dev libssl-dev | ||
|
|
||
| # ============================================ | ||
| # BUILD v1.3 (from stable branch) | ||
| # ============================================ | ||
| - name: Install v1.3 dependencies (stable) | ||
| run: | | ||
| pip install -q -r requirements_frozen.txt | ||
|
|
||
| - name: Prepare v1.3 build | ||
| run: | | ||
| # Temporarily disable csvlexer import (not in requirements_frozen.txt) | ||
| sed -i 's/from csvlexer.csv import CsvLexer/# from csvlexer.csv import CsvLexer # disabled for CI/' docs/conf.py | ||
| sed -i "s/lexers\['csv'\] = CsvLexer/# lexers['csv'] = CsvLexer # disabled for CI/" docs/conf.py | ||
|
|
||
| # Save version_switcher.js for later (before switching branches) | ||
| cp docs/_static/version_switcher.js /tmp/version_switcher.js | ||
|
|
||
| - name: Build v1.3 documentation | ||
| run: | | ||
| set -e | ||
| rm -rf _build/ | ||
| export DOCS_VERSION=1.3 | ||
| export DOCS_BASEURL=https://docs.openspp.org/v1.3/ | ||
| sphinx-build -b html docs _build/html/v1.3 | ||
| echo "✅ v1.3 build complete" | ||
|
|
||
| # ============================================ | ||
| # BUILD v2.0 (from v2-odoo19-doc-refresh branch) | ||
| # ============================================ | ||
| - name: Checkout v2 docs | ||
| run: | | ||
| # Save v1.3 build | ||
| mv _build/html/v1.3 /tmp/v1.3-build | ||
|
|
||
| # Checkout v2 branch | ||
| git checkout v2-odoo19-doc-refresh | ||
| git submodule update --init --recursive | ||
|
|
||
| - name: Install v2.0 dependencies | ||
| run: | | ||
| # Install any additional requirements for v2 | ||
| pip install -q -r requirements_frozen.txt || pip install -q -r requirements.txt | ||
|
|
||
| - name: Build v2.0 documentation (root) | ||
| run: | | ||
| set -e | ||
| rm -rf _build/ | ||
| export DOCS_VERSION=2.0 | ||
| export DOCS_BASEURL=https://docs.openspp.org/ | ||
| sphinx-build -b html docs _build/html | ||
| echo "✅ v2.0 build complete" | ||
|
|
||
| # ============================================ | ||
| # COMBINE BUILDS & SETUP VERSION SWITCHER | ||
| # ============================================ | ||
| - name: Combine builds | ||
| run: | | ||
| # Move v1.3 build back | ||
| mv /tmp/v1.3-build _build/html/v1.3 | ||
| echo "✅ Combined v2.0 (root) and v1.3 (/v1.3/)" | ||
|
|
||
| - name: Setup version switcher | ||
| run: | | ||
| set -e | ||
|
|
||
| # Create production switcher.json | ||
| cat > _build/html/_static/switcher.json << 'EOF' | ||
| [ | ||
| { | ||
| "name": "2.0 (latest)", | ||
| "version": "2.0", | ||
| "url": "https://docs.openspp.org/" | ||
| }, | ||
| { | ||
| "name": "1.3", | ||
| "version": "1.3", | ||
| "url": "https://docs.openspp.org/v1.3/" | ||
| } | ||
| ] | ||
| EOF | ||
|
|
||
| # Copy to v1.3 | ||
| cp _build/html/_static/switcher.json _build/html/v1.3/_static/ | ||
|
|
||
| # Copy version_switcher.js from stable (saved earlier) to both builds | ||
| # This ensures we use the fixed version with proper regex | ||
| cp /tmp/version_switcher.js _build/html/_static/ | ||
| cp /tmp/version_switcher.js _build/html/v1.3/_static/ | ||
|
|
||
| echo "✅ Version switcher configured" | ||
|
|
||
| - name: Inject version switcher script | ||
| run: | | ||
| # Inject script tag into all HTML files that don't already have it | ||
| find _build/html -name "*.html" -exec grep -L "version_switcher.js" {} \; | \ | ||
| xargs -I {} sed -i 's|</body>|<script src="/_static/version_switcher.js"></script></body>|g' {} | ||
|
|
||
| echo "✅ Version switcher script injected" | ||
|
|
||
| - name: Display build summary | ||
| run: | | ||
| echo "============================================" | ||
| echo "Multi-version documentation build complete" | ||
| echo "============================================" | ||
| echo "" | ||
| echo "v2.0 (root):" | ||
| ls -la _build/html/ | head -10 | ||
| echo "" | ||
| echo "v1.3 (/v1.3/):" | ||
| ls -la _build/html/v1.3/ | head -10 | ||
| echo "" | ||
| echo "Version switcher:" | ||
| cat _build/html/_static/switcher.json | ||
|
|
||
| # ============================================ | ||
| # DEPLOY TO CF-PAGES | ||
| # ============================================ | ||
| - name: Deploy to cf-pages branch | ||
| run: | | ||
| set -e | ||
|
|
||
| # Configure git | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| # Create a temporary directory for the deployment | ||
| DEPLOY_DIR=$(mktemp -d) | ||
| cp -r _build/html/* "$DEPLOY_DIR/" | ||
|
|
||
| # Fetch cf-pages branch | ||
| git fetch origin cf-pages:cf-pages || git checkout --orphan cf-pages | ||
| git checkout cf-pages | ||
|
|
||
| # Preserve preview deployments (keep_files equivalent) | ||
| if [ -d "previews" ]; then | ||
| cp -r previews "$DEPLOY_DIR/" | ||
| fi | ||
|
|
||
| # Clean current content except .git | ||
| find . -maxdepth 1 ! -name '.git' ! -name '.' -exec rm -rf {} + | ||
|
|
||
| # Copy new content | ||
| cp -r "$DEPLOY_DIR"/* . | ||
|
|
||
| # Add .nojekyll to prevent Jekyll processing | ||
| touch .nojekyll | ||
|
|
||
| # Commit and push | ||
| git add -A | ||
| git commit -m "Deploy multi-version documentation (v2.0 + v1.3)" || echo "No changes to commit" | ||
| git push origin cf-pages | ||
|
|
||
| # Clean up | ||
| rm -rf "$DEPLOY_DIR" | ||
|
|
||
| - name: Display deployment status | ||
| run: | | ||
| echo "============================================" | ||
| echo "Multi-version documentation deployed!" | ||
| echo "============================================" | ||
| echo "" | ||
| echo "URLs:" | ||
| echo " - v2.0 (latest): https://docs.openspp.org/" | ||
| echo " - v1.3: https://docs.openspp.org/v1.3/" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| [ | ||
| { | ||
| "name": "stable (latest)", | ||
| "version": "stable", | ||
| "name": "2.0 (latest)", | ||
| "version": "2.0", | ||
| "url": "https://docs.openspp.org/" | ||
| }, | ||
| { | ||
| "name": "1.3", | ||
| "version": "1.3", | ||
| "url": "https://docs.openspp.org/1.3/" | ||
| "url": "https://docs.openspp.org/v1.3/" | ||
| } | ||
| ] |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For efficiency and conciseness, you can combine these two
replacecalls into a single one using the|(OR) operator in your regular expression. This avoids running a second replacement if the first one doesn't match and makes the code slightly cleaner.