Skip to content

Commit 6708058

Browse files
committed
Publish Javadoc to docs directory
1 parent 1e3fb24 commit 6708058

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

.github/workflows/deploy_to_maven_central.yml

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ concurrency:
99
cancel-in-progress: true
1010
permissions:
1111
contents: write
12+
pages: write
1213
id-token: write
1314

1415
env:
@@ -22,7 +23,6 @@ jobs:
2223
runs-on: ubuntu-latest
2324
outputs:
2425
INITIAL_MAIN_POSITION: ${{ steps.create-tag.outputs.INITIAL_MAIN_POSITION }}
25-
INITIAL_GH_PAGES_POSITION: ${{ steps.create-tag.outputs.INITIAL_GH_PAGES_POSITION }}
2626
TAG: ${{ steps.create-tag.outputs.TAG }}
2727
VERSION: ${{ steps.create-tag.outputs.VERSION }}
2828
STAGING_PROFILE_ID: ${{ steps.parse-profile-id.outputs.STAGING_PROFILE_ID }}
@@ -150,20 +150,40 @@ jobs:
150150
- name: Generate Javadoc
151151
run: |
152152
./mvnw --batch-mode -V -e javadoc:aggregate
153-
mkdir --parents "${{ needs.open-release.outputs.VERSION }}/docs"
154-
mv target/reports/apidocs "${{ needs.open-release.outputs.VERSION }}/docs/api"
153+
VERSION=${{ needs.open-release.outputs.VERSION }}
154+
rm -rf "docs/api/${VERSION}"
155+
mkdir --parents "docs/api/${VERSION}"
156+
mv target/reports/apidocs "docs/api/${VERSION}"
155157
156158
- name: Commit changes
157159
run: |
158-
git checkout gh-pages -f
159-
echo "INITIAL_GH_PAGES_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
160-
git add "${{ needs.open-release.outputs.VERSION }}/docs/api"
161-
git commit -m "Released version ${{ needs.open-release.outputs.VERSION }}"
160+
git checkout ${{ github.ref_name }} -f
161+
git add "docs/api/${{ needs.open-release.outputs.VERSION }}"
162+
git commit -m "Publishing Javadoc for version ${{ needs.open-release.outputs.VERSION }}"
162163
git push
163164
165+
javadoc:
166+
needs: deploy
167+
environment:
168+
name: github-pages
169+
url: ${{ steps.deployment.outputs.page_url }}
170+
runs-on: ubuntu-latest
171+
steps:
172+
- name: Checkout
173+
uses: actions/checkout@v4
174+
- name: Setup Pages
175+
uses: actions/configure-pages@v5
176+
- name: Upload artifact
177+
uses: actions/upload-pages-artifact@v3
178+
with:
179+
path: "docs/api"
180+
- name: Deploy to GitHub Pages
181+
id: deployment
182+
uses: actions/deploy-pages@v4
183+
164184
close-release:
165185
name: Close release
166-
needs: [ open-release, deploy ]
186+
needs: [ open-release, deploy, javadoc ]
167187
runs-on: ubuntu-latest
168188
steps:
169189
- uses: actions/checkout@v4
@@ -196,7 +216,7 @@ jobs:
196216
# Cleanup on failure: https://stackoverflow.com/a/74562058/14731
197217
on-failure:
198218
name: On failure
199-
needs: [ open-release, deploy, close-release ]
219+
needs: [ open-release, deploy, javadoc, close-release ]
200220
runs-on: ubuntu-latest
201221
if: ${{ failure() || cancelled() }}
202222
steps:
@@ -239,16 +259,4 @@ jobs:
239259
- name: Delete tag
240260
if: needs.open-release.outputs.TAG != ''
241261
run: |
242-
git push --delete origin ${{ needs.open-release.outputs.TAG }}
243-
244-
- name: Restore the gh-pages ref to its original position
245-
if: needs.open-release.outputs.INITIAL_GH_PAGES_POSITION != ''
246-
run: |
247-
CURRENT_REF_POSITION=$(git rev-parse HEAD)
248-
if [ "${CURRENT_REF_POSITION}" != "${{ needs.open-release.outputs.INITIAL_GH_PAGES_POSITION }}" ]; then
249-
git reset --hard ${{ needs.open-release.outputs.INITIAL_GH_PAGES_POSITION }}
250-
if [ "${{ github.ref_type }}" == "tag" ]; then
251-
git ${{ github.ref_type }} -f ${{ github.ref_name }}
252-
fi
253-
git push -f origin ${{ github.ref_name }}
254-
fi
262+
git push --delete origin ${{ needs.open-release.outputs.TAG }}

0 commit comments

Comments
 (0)