QDMI 1.2.1 Release #7
Workflow file for this run
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: π Build and Deploy Release Docs | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version to deploy (e.g., v1.2.0)" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-deploy-release-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository ποΈ | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| ref: ${{ github.event.release.tag_name || inputs.version }} | |
| - name: Fetch version selector scripts from develop π | |
| run: | | |
| # Fetch and checkout the scripts from develop branch | |
| git fetch origin develop | |
| mkdir -p .github/scripts | |
| git checkout origin/develop -- .github/scripts/inject-version-selector.sh .github/scripts/version-selector.html || echo "Scripts not found in develop, will skip version selector" | |
| - name: Install Doxygen | |
| uses: ssciwr/doxygen-install@501e53b879da7648ab392ee226f5b90e42148449 # v1.6.4 | |
| with: | |
| version: "1.15.0" | |
| - name: Install and Build π§ | |
| run: | | |
| cmake -S . -B build | |
| cmake --build build --target qdmi_docs | |
| mv build/docs/html/ static | |
| - name: Set version variable | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" == "release" ]; then | |
| VERSION="${{ github.event.release.tag_name }}" | |
| else | |
| VERSION="${{ inputs.version }}" | |
| fi | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Inject version selector | |
| run: | | |
| if [ -f .github/scripts/inject-version-selector.sh ]; then | |
| chmod +x .github/scripts/inject-version-selector.sh | |
| .github/scripts/inject-version-selector.sh static | |
| else | |
| echo "Version selector script not found, skipping..." | |
| fi | |
| - name: Deploy versioned docs π | |
| uses: JamesIves/github-pages-deploy-action@9d877eea73427180ae43cf98e8914934fe157a1a # v4.7.6 | |
| with: | |
| folder: static | |
| target-folder: ${{ steps.version.outputs.version }} | |
| clean: false | |
| force: false | |
| - name: Checkout gh-pages branch ποΈ | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| ref: gh-pages | |
| path: gh-pages | |
| persist-credentials: true | |
| fetch-depth: 0 | |
| - name: Update versions.json and redirect π | |
| working-directory: gh-pages | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| # Get all version directories (excluding 'latest' and 'pr-preview') | |
| VERSIONS=$(find . -maxdepth 1 -type d -name 'v*' | sed 's|./||' | sort -V -r) | |
| # Create versions.json | |
| cat > versions.json << EOF | |
| { | |
| "stable": "${VERSION}", | |
| "releases": [ | |
| EOF | |
| # Add versions to JSON | |
| if [ -n "$VERSIONS" ]; then | |
| FIRST=true | |
| for v in $VERSIONS; do | |
| if [ "$FIRST" = true ]; then | |
| echo " \"$v\"" >> versions.json | |
| FIRST=false | |
| else | |
| echo " ,\"$v\"" >> versions.json | |
| fi | |
| done | |
| fi | |
| cat >> versions.json << EOF | |
| ] | |
| } | |
| EOF | |
| # Create an index.html that redirects to the latest stable version | |
| cat > index.html << EOF | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Redirecting to latest stable documentation</title> | |
| <meta http-equiv="refresh" content="0; url=${VERSION}/"> | |
| <link rel="canonical" href="${VERSION}/"> | |
| </head> | |
| <body> | |
| <p>Redirecting to <a href="${VERSION}/">latest stable documentation (${VERSION})</a>...</p> | |
| </body> | |
| </html> | |
| EOF | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add versions.json index.html | |
| git commit -m "Update versions.json and stable docs redirect to ${VERSION}" || echo "No changes to commit" | |
| git push origin gh-pages |