Skip to content

Commit 9ec9b80

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

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

.github/workflows/deploy_to_maven_central.yml

Lines changed: 27 additions & 20 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,17 +150,36 @@ 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+
environment:
167+
name: github-pages
168+
url: ${{ steps.deployment.outputs.page_url }}
169+
runs-on: ubuntu-latest
170+
steps:
171+
- name: Checkout
172+
uses: actions/checkout@v4
173+
- name: Setup Pages
174+
uses: actions/configure-pages@v5
175+
- name: Upload artifact
176+
uses: actions/upload-pages-artifact@v3
177+
with:
178+
path: "docs/api"
179+
- name: Deploy to GitHub Pages
180+
id: deployment
181+
uses: actions/deploy-pages@v4
182+
164183
close-release:
165184
name: Close release
166185
needs: [ open-release, deploy ]
@@ -239,16 +258,4 @@ jobs:
239258
- name: Delete tag
240259
if: needs.open-release.outputs.TAG != ''
241260
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
261+
git push --delete origin ${{ needs.open-release.outputs.TAG }}

0 commit comments

Comments
 (0)