Skip to content

Build and Publish #1510

Build and Publish

Build and Publish #1510

name: Build and Publish
on:
push:
tags: ["**"]
branches:
- master
pull_request:
jobs:
build-and-publish:
name: Java Gradle
uses: bakdata/ci-templates/.github/workflows/java-gradle-library.yaml@1.72.2
with:
java-version: 17
secrets:
sonar-token: ${{ secrets.SONARCLOUD_TOKEN }}
sonar-organization: ${{ secrets.SONARCLOUD_ORGANIZATION }}
signing-secret-key-ring: ${{ secrets.SONATYPE_SIGNING_SECRET_KEY_RING }}
signing-key-id: ${{ secrets.SONATYPE_SIGNING_KEY_ID }}
signing-password: ${{ secrets.SONATYPE_SIGNING_PASSWORD }}
ossrh-username: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
ossrh-password: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
github-token: ${{ secrets.GH_TOKEN }}
extract-javadoc:
name: Extract Javadoc JARs into docs
runs-on: ubuntu-24.04
needs: build-and-publish
if: ${{ needs.build-and-publish.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download aggregated Javadoc artifact
uses: actions/download-artifact@v7
with:
name: build-artifact
path: build-artifact
- name: Extract aggregated Javadoc JAR
shell: bash
run: |
mkdir -p docs/docs/javadoc
jar_path=$(find build-artifact/build/libs -type f -name "*-javadoc.jar" | head -n 1)
if [[ -f "$jar_path" ]]; then
echo "Found aggregated Javadoc JAR: $jar_path"
unzip -q "$jar_path" -d docs/docs/javadoc
echo "Extracted Javadoc to docs/docs/javadoc"
find docs/docs/javadoc
else
echo "No aggregated Javadoc JAR found!"
exit 1
fi
- name: Upload extracted Javadoc
uses: actions/upload-artifact@v6
with:
name: javadoc
path: docs/docs/javadoc
docs:
name: Build Docs
runs-on: ubuntu-24.04
needs: extract-javadoc
if: ${{ needs.extract-javadoc.result == 'success' }}
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install Poetry
uses: abatilo/actions-poetry@v4
with:
poetry-version: "1.8.2"
- name: Install docs dependencies
run: poetry install --no-root
- name: Build docs
run: poetry run mkdocs build -f docs/mkdocs.yml
publish-docs:
name: Publish Docs
runs-on: ubuntu-24.04
needs: docs
if: ${{ needs.docs.result == 'success' }}
permissions:
contents: write # Explicitly grant write access to allow pushing in this job for dependabot
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all tags; Required for doc versioning
- name: Download extracted Javadoc
uses: actions/download-artifact@v7
with:
name: javadoc
path: docs/docs/javadoc
- name: Determine tag
id: get-tag
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "tag=dev" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF_NAME}" == "${{ github.event.repository.default_branch }}" ]]; then
echo "tag=main" >> "$GITHUB_OUTPUT"
fi
- name: Check for docs changes (PR)
if: ${{ github.event_name == 'pull_request' }}
uses: dorny/paths-filter@v3
id: docs-changes
with:
filters: |
docs:
- added|deleted|modified: 'docs/**'
- name: Publish docs
if: ${{ github.event_name != 'pull_request' || steps.docs-changes.outputs.docs == 'true' }}
uses: ./.github/actions/update-docs
with:
username: ${{ secrets.GH_USERNAME }}
email: ${{ secrets.GH_EMAIL }}
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.get-tag.outputs.tag }}
release: ${{ github.ref_type == 'tag' }}