Skip to content

Commit f6d3f6a

Browse files
committed
Updates to javadoc.yml
1 parent 1f52203 commit f6d3f6a

File tree

1 file changed

+61
-203
lines changed

1 file changed

+61
-203
lines changed

.github/workflows/javadoc.yml

Lines changed: 61 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -1,209 +1,67 @@
1-
name: JavaDoc Releases
1+
name: Deploy Versioned Javadoc (Manual Trigger)
2+
3+
# Select the target TAG where to run the workflow from.
4+
# This TAG name becomes the subdirectory under branch gh-pages/docs/${TAG}
5+
# where the javadocs will be copied to.
26

37
on:
4-
push:
5-
tags:
6-
- "*" # Only publish docs for tags
7-
delete:
8-
tags:
9-
- "*" # Auto-remove docs when tags are deleted
108
workflow_dispatch:
11-
12-
permissions:
13-
contents: write
14-
pages: write
15-
id-token: write
9+
inputs:
10+
tag_ref:
11+
description: 'Existing Git Tag to deploy (e.g., 1.0.0)'
12+
required: true
13+
default: '1.0.0' # Default can be left blank or set to a placeholder
1614

1715
jobs:
18-
build:
19-
name: Build JavaDoc
20-
runs-on: ubuntu-latest
21-
22-
steps:
23-
- name: Checkout source
24-
uses: actions/checkout@v5
25-
26-
- name: Set up JDK
27-
uses: actions/setup-java@v5
28-
with:
29-
distribution: temurin
30-
java-version: 25
31-
32-
- name: Set up Maven cache
33-
uses: actions/cache@v4
34-
with:
35-
path: |
36-
~/.m2/repository
37-
key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
38-
restore-keys: |
39-
maven-${{ runner.os }}-
40-
41-
- name: Build JavaDoc
42-
run: mvn -B javadoc:javadoc
43-
44-
# Upload for GitHub Pages preview (this is optional)
45-
- name: Upload Pages Artifact
46-
uses: actions/upload-pages-artifact@v4
47-
with:
48-
path: target/reports/apidocs
49-
50-
update-gh-pages:
51-
name: Update gh-pages
52-
needs: build
16+
build-and-deploy-javadoc:
5317
runs-on: ubuntu-latest
54-
55-
if: github.event_name != 'delete' # skip this job on delete events
56-
57-
steps:
58-
- name: Checkout gh-pages branch
59-
uses: actions/checkout@v5
60-
with:
61-
ref: gh-pages
62-
path: gh-pages
63-
64-
- name: Copy Javadoc into versioned folder
65-
run: |
66-
# TAG="${GITHUB_REF_NAME}"
67-
TAG="9.0.0-rc"
68-
VERSION_DIR="docs/${TAG}"
69-
echo "$VERSION_DIR"
70-
rm -rf "gh-pages/${VERSION_DIR}"
71-
mkdir -p "gh-pages/${VERSION_DIR}"
72-
SRC_DIR="target/reports/apidocs/"
73-
echo $SRC_DIR
74-
if [ -d "$SRC_DIR" ]; then
75-
echo "$SRC_DIR exists."
76-
else
77-
echo "$SRC_DIR does not exist."
78-
fi
79-
cp -r target/reports/apidocs/ "gh-pages/${VERSION_DIR}/"
80-
81-
- name: Regenerate multi-version index.html
82-
run: |
83-
cd gh-pages
84-
85-
# Create index header
86-
cat > index.html << 'EOF'
87-
<!DOCTYPE html>
88-
<html>
89-
<head>
90-
<meta charset="UTF-8"/>
91-
<title>Javadoc Versions</title>
92-
<style>
93-
body { font-family: Arial; padding: 2rem; max-width: 800px; margin: auto; }
94-
h1 { font-size: 2rem; }
95-
ul { line-height: 1.8; font-size: 1.1rem; }
96-
</style>
97-
</head>
98-
<body>
99-
<h1>Available Javadoc Versions</h1>
100-
<ul>
101-
EOF
102-
103-
# Insert entries for each version directory
104-
for dir in docs/*; do
105-
[ -d "$dir" ] || continue
106-
ver=$(basename "$dir")
107-
echo "<li><a href=\"docs/$ver/\">$ver</a></li>" >> index.html
108-
done
109-
110-
# Close HTML
111-
cat >> index.html << 'EOF'
112-
</ul>
113-
</body>
114-
</html>
115-
EOF
116-
117-
- name: Commit & push changes
118-
run: |
119-
cd gh-pages
120-
git config user.email "github-actions[bot]@users.noreply.github.com"
121-
git config user.name "github-actions[bot]"
122-
123-
if git diff --quiet; then
124-
echo "No changes to commit"
125-
exit 0
126-
fi
127-
128-
git add .
129-
git commit -m "Update release Javadoc for ${GITHUB_REF_NAME}"
130-
git push origin gh-pages
131-
132-
# delete-tag-docs:
133-
# name: Remove deleted tag docs
134-
# runs-on: ubuntu-latest
135-
#
136-
# if: github.event_name == 'delete' && github.event.ref_type == 'tag'
137-
#
138-
# steps:
139-
# - name: Checkout gh-pages
140-
# uses: actions/checkout@v5
141-
# with:
142-
# ref: gh-pages
143-
# path: gh-pages
144-
#
145-
# - name: Remove documentation for deleted tag
146-
# run: |
147-
# TAG="${GITHUB_REF_NAME}"
148-
# VERSION_DIR="docs/${TAG}"
149-
# rm -rf "gh-pages/${VERSION_DIR}"
150-
#
151-
# - name: Rebuild index.html
152-
# run: |
153-
# cd gh-pages
154-
#
155-
# # Regenerate index.html (same as above)
156-
# cat > index.html << 'EOF'
157-
# <!DOCTYPE html>
158-
# <html>
159-
# <head>
160-
# <meta charset="UTF-8"/>
161-
# <title>Javadoc Versions</title>
162-
# <style>
163-
# body { font-family: Arial; padding: 2rem; max-width: 800px; margin: auto; }
164-
# h1 { font-size: 2rem; }
165-
# ul { line-height: 1.8; font-size: 1.1rem; }
166-
# </style>
167-
# </head>
168-
# <body>
169-
# <h1>Available Javadoc Versions</h1>
170-
# <ul>
171-
# EOF
172-
#
173-
# for dir in docs/*; do
174-
# [ -d "$dir" ] || continue
175-
# ver=$(basename "$dir")
176-
# echo "<li><a href=\"docs/$ver/\">$ver</a></li>" >> index.html
177-
# done
178-
#
179-
# cat >> index.html << 'EOF'
180-
# </ul>
181-
# </body>
182-
# </html>
183-
# EOF
184-
#
185-
# - name: Commit & push removal
186-
# run: |
187-
# cd gh-pages
188-
# git config user.email "github-actions[bot]@users.noreply.github.com"
189-
# git config user.name "github-actions[bot]"
190-
#
191-
# if git diff --quiet; then
192-
# echo "No changes to commit"
193-
# exit 0
194-
# fi
195-
#
196-
# git add .
197-
# git commit -m "Remove Javadoc for deleted tag ${GITHUB_REF_NAME}"
198-
# git push origin gh-pages
199-
#
200-
# Summary of Features
201-
# Multi-version docs (docs/<tag>/)
202-
# Auto-generated index.html
203-
# Only publish for tags
204-
# Delete docs when tags are deleted
205-
# Upload Pages artifact
206-
# Maven dependency caching
207-
# No third-party actions
208-
# No force-push
209-
# Clean HTML layout
18+
permissions:
19+
contents: write
20+
pages: write
21+
id-token: write
22+
23+
steps:
24+
- name: Checkout Code at Specified Tag
25+
uses: actions/checkout@v5
26+
with:
27+
ref: ${{ github.event.inputs.tag_ref }} # from manual trigger input
28+
fetch-depth: 0
29+
30+
- name: Set up JDK
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: '25'
34+
distribution: 'temurin'
35+
cache: 'maven'
36+
37+
- name: Build and Generate Javadoc
38+
run: mvn javadoc:javadoc
39+
40+
- name: Deploy Javadoc to gh-pages/docs/${TAG}
41+
env:
42+
GH_PAGES_EMAIL: noreply@github.com
43+
GH_PAGES_NAME: github-actions[bot]
44+
GIT_TAG_NAME: ${{ github.event.inputs.tag_ref }}
45+
TARGET_DIR: docs/${{ github.event.inputs.tag_ref }}
46+
run: |
47+
# 1. Configure Git user
48+
git config user.email "${GH_PAGES_EMAIL}"
49+
git config user.name "${GH_PAGES_NAME}"
50+
51+
# 2. Fetch and checkout the existing gh-pages branch
52+
git fetch origin gh-pages:gh-pages
53+
git checkout gh-pages
54+
55+
# 3. Clean up any previous documentation for this tag (optional, but safer)
56+
rm -rf $TARGET_DIR
57+
58+
# 4. Create the versioned directory structure
59+
mkdir -p $TARGET_DIR
60+
61+
# 5. Copy the generated Javadoc files into the versioned directory
62+
cp -r target/reports/apidocs/* $TARGET_DIR/
63+
64+
# 6. Add the new directory and files, commit, and push
65+
git add $TARGET_DIR
66+
git commit -m "Manual Javadoc deployment for tag ${GIT_TAG_NAME} into $TARGET_DIR"
67+
git push origin gh-pages

0 commit comments

Comments
 (0)