| name: Release - Docs | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Release tag (e.g., selenium-4.29.0 or selenium-4.28.1-ruby)' | |
| required: true | |
| type: string | |
| language: | |
| description: 'Language (overrides tag suffix if provided)' | |
| required: false | |
| type: choice | |
| default: "all" | |
| options: | |
| - all | |
| - java | |
| - ruby | |
| - python | |
| - dotnet | |
| - javascript | |
| generate: | |
| description: Build the documentation | |
| type: boolean | |
| default: true | |
| commit: | |
| description: Push the documentation to gh-pages | |
| type: boolean | |
| default: true | |
| workflow_call: | |
| inputs: | |
| tag: | |
| required: true | |
| type: string | |
| language: | |
| type: string | |
| default: "" | |
| generate: | |
| description: Build the documentation | |
| type: boolean | |
| default: true | |
| commit: | |
| description: Push the documentation to gh-pages | |
| type: boolean | |
| default: true | |
| permissions: | |
| contents: write | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| jobs: | |
| parse: | |
| name: Parse Tag | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.parse.outputs.version }} | |
| language: ${{ steps.parse.outputs.language }} | |
| steps: | |
| - name: Parse tag | |
| id: parse | |
| env: | |
| TAG: ${{ inputs.tag }} | |
| INPUT_LANG: ${{ inputs.language }} | |
| run: | | |
| echo "version=$(echo "$TAG" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT" | |
| # Extract language from tag suffix or use input | |
| if [ -n "$INPUT_LANG" ] && [ "$INPUT_LANG" != "all" ]; then | |
| LANG="$INPUT_LANG" | |
| elif [[ "$TAG" =~ -(javascript|python|ruby|java|dotnet)$ ]]; then | |
| LANG="${BASH_REMATCH[1]}" | |
| else | |
| LANG="all" | |
| fi | |
| echo "language=$LANG" >> "$GITHUB_OUTPUT" | |
| generate-docs: | |
| name: Generate Documentation | |
| needs: parse | |
| if: ${{ inputs.generate }} | |
| uses: ./.github/workflows/bazel.yml | |
| with: | |
| name: Generate Docs | |
| ref: ${{ inputs.tag }} | |
| run: ./go ${{ needs.parse.outputs.language }}:docs | |
| artifact-name: documentation-${{ needs.parse.outputs.language }} | |
| artifact-path: build/docs/api/**/* | |
| commit-docs: | |
| name: Commit Documentation | |
| needs: [parse, generate-docs] | |
| if: >- | |
| ${{ !cancelled() && inputs.commit && | |
| needs.parse.result == 'success' && needs.generate-docs.result != 'failure' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout gh-pages | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: gh-pages | |
| - name: Download documentation | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: documentation-* | |
| merge-multiple: true | |
| path: docs-api | |
| - name: Commit documentation | |
| run: | | |
| [ -d docs-api ] || { echo "::error::No documentation artifacts found"; exit 1; } | |
| for dir in docs-api/*/; do | |
| lang=$(basename "$dir") | |
| rm -rf "docs/api/$lang" | |
| cp -R "$dir" "docs/api/$lang" | |
| done | |
| git config --local user.email "selenium-ci@users.noreply.github.com" | |
| git config --local user.name "Selenium CI Bot" | |
| git add -A docs/api/ | |
| git diff --staged --quiet && exit 0 | |
| git commit -m "Update ${{ needs.parse.outputs.language }} documentation for Selenium ${{ needs.parse.outputs.version }}" | |
| git push origin gh-pages |