Skip to content

Commit 6b88755

Browse files
committed
Publish new Javadoc on release
1 parent 5528bcd commit 6b88755

File tree

2 files changed

+60
-31
lines changed

2 files changed

+60
-31
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
path: |
2525
~/.m2/repository/*
26-
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
26+
key: ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}
2727

2828
# Maven command-line options:
2929
# --batch-mode: recommended in CI to inform maven to not run in interactive mode (less logs)

.github/workflows/deploy_to_maven_central.yml

Lines changed: 59 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616
open-release:
1717
runs-on: ubuntu-latest
1818
outputs:
19-
INITIAL_REF_POSITION: ${{ steps.create-tag.outputs.INITIAL_REF_POSITION }}
19+
INITIAL_MASTER_POSITION: ${{ steps.create-tag.outputs.INITIAL_MASTER_POSITION }}
20+
INITIAL_GH_PAGES_POSITION: ${{ steps.create-tag.outputs.INITIAL_GH_PAGES_POSITION }}
2021
TAG: ${{ steps.create-tag.outputs.TAG }}
2122
VERSION: ${{ steps.create-tag.outputs.VERSION }}
2223
STAGING_PROFILE_ID: ${{ steps.parse-profile-id.outputs.STAGING_PROFILE_ID }}
@@ -25,8 +26,6 @@ jobs:
2526
- uses: actions/checkout@v4
2627
with:
2728
ref: ${{ github.ref }}
28-
fetch-depth: 0
29-
token: ${{ secrets.WORKFLOW_TOKEN }}
3029
- uses: actions/setup-java@v4
3130
with:
3231
distribution: zulu
@@ -41,8 +40,7 @@ jobs:
4140
- name: Cache Dependencies
4241
uses: actions/cache@v4
4342
with:
44-
path: |
45-
~/.m2/repository/*
43+
path: ~/.m2/repository/*
4644
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
4745

4846
- name: Configure Git User
@@ -64,7 +62,7 @@ jobs:
6462
- name: Create tag
6563
id: create-tag
6664
run: |
67-
echo "INITIAL_REF_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
65+
echo "INITIAL_MASTER_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
6866
./mvnw release:prepare --batch-mode -V -e
6967
TAG=$(git describe --tag --abbrev=0)
7068
echo "TAG=${TAG}" >> "$GITHUB_OUTPUT"
@@ -106,7 +104,6 @@ jobs:
106104
- uses: actions/checkout@v4
107105
with:
108106
ref: ${{ needs.open-release.outputs.TAG }}
109-
token: ${{ secrets.WORKFLOW_TOKEN }}
110107
- uses: actions/setup-java@v4
111108
with:
112109
distribution: zulu
@@ -121,24 +118,57 @@ jobs:
121118
- name: Cache Dependencies
122119
uses: actions/cache@v4
123120
with:
124-
path: |
125-
~/.m2/repository/*
121+
path: ~/.m2/repository/*
126122
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
127123

128124
- name: Test build
129125
run: ./mvnw --batch-mode -V -e verify
130126

131-
# Avoid using exclamation mark on bash: https://stackoverflow.com/a/27177197/14731
127+
# Must quote exclamation mark on bash: https://stackoverflow.com/a/27177197/14731
132128
- name: Deploy to Maven Central
133129
run: >
134130
./mvnw --batch-mode -V -e -pl '!test,!benchmark,!benchmark/java,!benchmark/guava,!benchmark/assertj'
135131
-Dstaging_repository_id=${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}
136132
-Dstaging_host="${{ env.STAGING_HOST }}"
137133
deploy -P release
138134
139-
close-release:
135+
document:
136+
name: Publish Javadoc documentation
140137
needs: [ open-release, deploy ]
141138
runs-on: ubuntu-latest
139+
steps:
140+
- uses: actions/checkout@v4
141+
with:
142+
ref: ${{ needs.open-release.outputs.TAG }}
143+
fetch-depth: 0
144+
token: ${{ secrets.WORKFLOW_TOKEN }}
145+
- uses: actions/setup-java@v4
146+
with:
147+
distribution: zulu
148+
java-version: 21
149+
150+
- name: Configure Git User
151+
run: |
152+
git config user.email "cowwoc2020@gmail.com"
153+
git config user.name "Gili Tzabari"
154+
155+
- name: Generate Javadoc
156+
run: |
157+
./mvnw --batch-mode -V -e verify javadoc:aggregate -pl !dropwizard,!jersey
158+
mkdir --parents "${{ needs.open-release.outputs.VERSION }}/docs"
159+
mv target/reports/apidocs "${{ needs.open-release.outputs.VERSION }}/docs/api"
160+
161+
- name: Commit changes
162+
run: |
163+
git checkout gh-pages
164+
echo "INITIAL_GH_PAGES_POSITION=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
165+
git add "${{ needs.open-release.outputs.VERSION }}/docs/api"
166+
git commit -m "Released version ${{ needs.open-release.outputs.VERSION }}"
167+
git push
168+
169+
close-release:
170+
needs: [ open-release, deploy, document ]
171+
runs-on: ubuntu-latest
142172
steps:
143173
- uses: actions/checkout@v4
144174
with:
@@ -158,8 +188,7 @@ jobs:
158188
- name: Cache Dependencies
159189
uses: actions/cache@v4
160190
with:
161-
path: |
162-
~/.m2/repository/*
191+
path: ~/.m2/repository/*
163192
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
164193

165194
- name: Close staging repository
@@ -191,13 +220,6 @@ jobs:
191220
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
192221
gpg-passphrase: MAVEN_GPG_PASSPHRASE
193222

194-
- name: Cache Dependencies
195-
uses: actions/cache@v4
196-
with:
197-
path: |
198-
~/.m2/repository/*
199-
key: "${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
200-
201223
- name: Drop staging repository
202224
if: needs.open-release.outputs.STAGING_REPOSITORY_ID != '' && needs.open-release.outputs.STAGING_PROFILE_ID != ''
203225
run: >
@@ -206,17 +228,12 @@ jobs:
206228
-d '{"data": {"stagedRepositoryId": "${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}", "description": "Dropping repository"}}'
207229
'https://${{ env.STAGING_HOST }}/service/local/staging/profiles/${{ needs.open-release.outputs.STAGING_PROFILE_ID }}/drop'
208230
209-
- name: Configure Git User
210-
run: |
211-
git config user.email "cowwoc2020@gmail.com"
212-
git config user.name "Gili Tzabari"
213-
214-
- name: Restore the workflow ref to its original position
215-
if: needs.open-release.outputs.INITIAL_REF_POSITION != ''
231+
- name: Restore the master ref to its original position
232+
if: needs.open-release.outputs.INITIAL_MASTER_POSITION != ''
216233
run: |
217234
CURRENT_REF_POSITION=$(git rev-parse HEAD)
218-
if [ "${CURRENT_REF_POSITION}" != "${{ needs.open-release.outputs.INITIAL_REF_POSITION }}" ]; then
219-
git reset --hard ${{ needs.open-release.outputs.INITIAL_REF_POSITION }}
235+
if [ "${CURRENT_REF_POSITION}" != "${{ needs.open-release.outputs.INITIAL_MASTER_POSITION }}" ]; then
236+
git reset --hard ${{ needs.open-release.outputs.INITIAL_MASTER_POSITION }}
220237
if [ "${{ github.ref_type }}" == "tag" ]; then
221238
git ${{ github.ref_type }} -f ${{ github.ref_name }}
222239
fi
@@ -226,4 +243,16 @@ jobs:
226243
- name: Delete tag
227244
if: needs.open-release.outputs.TAG != ''
228245
run: |
229-
git push --delete origin ${{ needs.open-release.outputs.TAG }}
246+
git push --delete origin ${{ needs.open-release.outputs.TAG }}
247+
248+
- name: Restore the gh-pages ref to its original position
249+
if: needs.open-release.outputs.INITIAL_GH_PAGES_POSITION != ''
250+
run: |
251+
CURRENT_REF_POSITION=$(git rev-parse HEAD)
252+
if [ "${CURRENT_REF_POSITION}" != "${{ needs.open-release.outputs.INITIAL_GH_PAGES_POSITION }}" ]; then
253+
git reset --hard ${{ needs.open-release.outputs.INITIAL_GH_PAGES_POSITION }}
254+
if [ "${{ github.ref_type }}" == "tag" ]; then
255+
git ${{ github.ref_type }} -f ${{ github.ref_name }}
256+
fi
257+
git push -f origin ${{ github.ref_name }}
258+
fi

0 commit comments

Comments
 (0)