Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 50 additions & 34 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ on:
workflow_dispatch:
inputs:
tag_ref:
description: 'Existing Git Tag to deploy (e.g., 1.0.0)'
description: 'Existing Git Tag to deploy (e.g., 1.0.0):'
required: true
default: '1.0.0' # Default can be left blank or set to a placeholder
default: '99.0.0' # unlikely to conflict if accidentally used. Can be left blank

jobs:
build-and-deploy-javadoc:
runs-on: ubuntu-latest
permissions:
contents: write # Sufficient for checkout and pushing to gh-pages
contents: write

steps:
- name: Checkout Code at Specified Tag
Expand All @@ -30,37 +30,53 @@ jobs:
with:
java-version: '25'
distribution: 'temurin'
cache: 'maven'
- name: Build and Generate Javadoc
cache: 'maven'

- name: Build and Generate Javadoc # POM is configured to output to target/site/apidocs
run: mvn javadoc:javadoc
- name: Deploy Javadoc to gh-pages/docs/${TAG}

- name: Deploy Javadoc via Worktree
env:
GH_PAGES_EMAIL: noreply@github.com
GH_PAGES_NAME: github-actions[bot]
GIT_TAG_NAME: ${{ github.event.inputs.tag_ref }}
TARGET_DIR: docs/${{ github.event.inputs.tag_ref }}

TAG_NAME: ${{ github.event.inputs.tag_ref }}
run: |
# 1. Configure Git user
git config user.email "${GH_PAGES_EMAIL}"
git config user.name "${GH_PAGES_NAME}"

# 2. Fetch and checkout the existing gh-pages branch (or create it if it doesn't exist)
git fetch origin gh-pages:gh-pages
git checkout gh-pages

# 3. Clean up any previous documentation for this tag (optional, but safer)
rm -rf $TARGET_DIR

# 4. Create the versioned directory structure
mkdir -p $TARGET_DIR

# 5. Copy the generated Javadoc files into the versioned directory
cp -r target/reports/apidocs/* $TARGET_DIR/

# 6. Add the new directory and files, commit, and push
git add $TARGET_DIR
git commit -m "Manual Javadoc deployment for tag ${GIT_TAG_NAME} into $TARGET_DIR"
git push origin gh-pages
# 1. Initialize error tracking
EXIT_CODE=0

# 2. Configure Git Identity
git config user.email "noreply@github.com"
git config user.name "github-actions[bot]"

# 3. Ensure gh-pages exists and is fetched
git fetch origin gh-pages --depth=1 || git branch gh-pages

# 4. Create worktree for the gh-pages branch in a separate folder
git worktree add ./gh-pages-dir origin/gh-pages

# 5. Deployment Logic in a subshell to capture exit code
(
set -e # Exit subshell on any internal error
TARGET_PATH="gh-pages-dir/docs/$TAG_NAME" # target directory inside the worktree
mkdir -p "$TARGET_PATH"
cp -a target/site/apidocs/. "$TARGET_PATH/"

cd gh-pages-dir
git add .

if git diff --staged --quiet; then
echo "No changes detected for Javadoc $TAG_NAME."
else
git commit -m "Manual Javadoc deployment for tag $TAG_NAME"
git push origin gh-pages
fi
) || EXIT_CODE=$?

# 6. Cleanup (Always runs)
echo "Cleaning up worktree..."
git worktree remove --force ./gh-pages-dir || true

# 7. Final exit based on subshell success
exit $EXIT_CODE

- name: Confirm Deployment
if: success()
run: echo "Javadoc for ${{ github.event.inputs.tag_ref }} is now live on gh-pages."
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

# Additional tools
.clover/
.mvn/

# OSX files
**/.DS_Store
Expand Down
6 changes: 6 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# suppresses the warning:
# Direct modification of testCompileSourceRoots through add() is deprecated and will not work in Maven 4.0.0. Please use the add/remove methods instead.
# If you're using a plugin that causes this warning, please upgrade to the latest version and report an issue if the warning persists.
# To disable these warnings, set -Dmaven.project.sourceRoots.warningsDisabled=true on the command line, in the .mvn/maven.config file,
# or in project POM properties.
-Dmaven.project.sourceRoots.warningsDisabled=true
Loading
Loading