|
| 1 | +name: Deploy MkDocs to GitHub Pages |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] # Trigger when GitHub Release is published |
| 6 | + # Release tag should contain 'python' (case-insensitive, e.g., v25.9.1-python, v1.0.0-Python) |
| 7 | + |
| 8 | + # Allow manual trigger for testing |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Version to deploy (e.g., 25.9.1 or dev)' |
| 13 | + required: true |
| 14 | + default: 'dev' |
| 15 | + set_latest: |
| 16 | + description: 'Set as latest version?' |
| 17 | + required: true |
| 18 | + type: boolean |
| 19 | + default: true |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: write # Need write to push to gh-pages branch |
| 23 | + pages: write |
| 24 | + id-token: write |
| 25 | + |
| 26 | +# Allow only one concurrent deployment |
| 27 | +concurrency: |
| 28 | + group: "pages" |
| 29 | + cancel-in-progress: false |
| 30 | + |
| 31 | +jobs: |
| 32 | + deploy: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + environment: |
| 35 | + name: github-pages |
| 36 | + url: https://humemai.github.io/arcadedb/ |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Check if this is a Python release |
| 40 | + if: github.event_name == 'release' |
| 41 | + id: check-python-release |
| 42 | + run: | |
| 43 | + TAG_NAME="${{ github.event.release.tag_name }}" |
| 44 | + TAG_LOWER=$(echo "$TAG_NAME" | tr '[:upper:]' '[:lower:]') |
| 45 | +
|
| 46 | + if [[ "$TAG_LOWER" == *"python"* ]]; then |
| 47 | + echo "✅ This is a Python release: $TAG_NAME" |
| 48 | + echo "is-python-release=true" >> $GITHUB_OUTPUT |
| 49 | + else |
| 50 | + echo "⏭️ Not a Python release (tag: $TAG_NAME), skipping docs deployment" |
| 51 | + echo "is-python-release=false" >> $GITHUB_OUTPUT |
| 52 | + exit 0 |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Skip workflow for non-Python releases |
| 56 | + if: github.event_name == 'release' && steps.check-python-release.outputs.is-python-release != 'true' |
| 57 | + run: | |
| 58 | + echo "This is not a Python release, exiting gracefully" |
| 59 | + exit 0 |
| 60 | +
|
| 61 | + - name: Checkout repository |
| 62 | + if: github.event_name != 'release' || steps.check-python-release.outputs.is-python-release == 'true' |
| 63 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 64 | + with: |
| 65 | + fetch-depth: 0 # Full history for mike versioning |
| 66 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Set up Python |
| 69 | + if: github.event_name != 'release' || steps.check-python-release.outputs.is-python-release == 'true' |
| 70 | + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
| 71 | + with: |
| 72 | + python-version: '3.11' |
| 73 | + cache: 'pip' |
| 74 | + |
| 75 | + - name: Install dependencies |
| 76 | + if: github.event_name != 'release' || steps.check-python-release.outputs.is-python-release == 'true' |
| 77 | + working-directory: bindings/python |
| 78 | + run: | |
| 79 | + pip install --upgrade pip |
| 80 | + pip install mkdocs-material mkdocs-git-revision-date-localized-plugin mike |
| 81 | +
|
| 82 | + - name: Configure Git |
| 83 | + if: github.event_name != 'release' || steps.check-python-release.outputs.is-python-release == 'true' |
| 84 | + run: | |
| 85 | + git config user.name "github-actions[bot]" |
| 86 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 87 | +
|
| 88 | + - name: Extract version from release tag or input |
| 89 | + if: github.event_name != 'release' || steps.check-python-release.outputs.is-python-release == 'true' |
| 90 | + id: version |
| 91 | + run: | |
| 92 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 93 | + VERSION="${{ github.event.inputs.version }}" |
| 94 | + SET_LATEST="${{ github.event.inputs.set_latest }}" |
| 95 | + else |
| 96 | + # Extract version from release tag (v25.9.1-python -> 25.9.1 or v25.9.1.1-python -> 25.9.1.1) |
| 97 | + TAG_NAME="${{ github.event.release.tag_name }}" |
| 98 | + TAG_LOWER=$(echo "$TAG_NAME" | tr '[:upper:]' '[:lower:]') |
| 99 | +
|
| 100 | + # Verify tag contains 'python' (case-insensitive) |
| 101 | + if [[ ! "$TAG_LOWER" == *"python"* ]]; then |
| 102 | + echo "❌ Release tag should contain 'python' (case-insensitive), got: $TAG_NAME" |
| 103 | + exit 1 |
| 104 | + fi |
| 105 | +
|
| 106 | + # Strip 'v' prefix and remove everything after and including '-python' or '-Python', etc. |
| 107 | + VERSION="${TAG_NAME#v}" # Remove 'v' prefix |
| 108 | + VERSION="${VERSION%%-[Pp][Yy][Tt][Hh][Oo][Nn]*}" # Remove '-python' suffix (case-insensitive) |
| 109 | + SET_LATEST="true" |
| 110 | + fi |
| 111 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 112 | + echo "set_latest=$SET_LATEST" >> $GITHUB_OUTPUT |
| 113 | + echo "📦 Deploying documentation version: $VERSION" |
| 114 | +
|
| 115 | + - name: Deploy with mike (set as latest) |
| 116 | + if: (github.event_name != 'release' || steps.check-python-release.outputs.is-python-release == 'true') && steps.version.outputs.set_latest == 'true' |
| 117 | + working-directory: bindings/python |
| 118 | + run: | |
| 119 | + mike deploy --push --update-aliases \ |
| 120 | + ${{ steps.version.outputs.version }} latest \ |
| 121 | + --title "${{ steps.version.outputs.version }} (latest)" |
| 122 | + mike set-default --push latest |
| 123 | +
|
| 124 | + - name: Deploy with mike (not latest) |
| 125 | + if: (github.event_name != 'release' || steps.check-python-release.outputs.is-python-release == 'true') && steps.version.outputs.set_latest != 'true' |
| 126 | + working-directory: bindings/python |
| 127 | + run: | |
| 128 | + mike deploy --push \ |
| 129 | + ${{ steps.version.outputs.version }} \ |
| 130 | + --title "${{ steps.version.outputs.version }}" |
0 commit comments