16
16
open-release :
17
17
runs-on : ubuntu-latest
18
18
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 }}
20
21
TAG : ${{ steps.create-tag.outputs.TAG }}
21
22
VERSION : ${{ steps.create-tag.outputs.VERSION }}
22
23
STAGING_PROFILE_ID : ${{ steps.parse-profile-id.outputs.STAGING_PROFILE_ID }}
25
26
- uses : actions/checkout@v4
26
27
with :
27
28
ref : ${{ github.ref }}
28
- fetch-depth : 0
29
- token : ${{ secrets.WORKFLOW_TOKEN }}
30
29
- uses : actions/setup-java@v4
31
30
with :
32
31
distribution : zulu
41
40
- name : Cache Dependencies
42
41
uses : actions/cache@v4
43
42
with :
44
- path : |
45
- ~/.m2/repository/*
43
+ path : ~/.m2/repository/*
46
44
key : " ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
47
45
48
46
- name : Configure Git User
64
62
- name : Create tag
65
63
id : create-tag
66
64
run : |
67
- echo "INITIAL_REF_POSITION =$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
65
+ echo "INITIAL_MASTER_POSITION =$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
68
66
./mvnw release:prepare --batch-mode -V -e
69
67
TAG=$(git describe --tag --abbrev=0)
70
68
echo "TAG=${TAG}" >> "$GITHUB_OUTPUT"
@@ -106,7 +104,6 @@ jobs:
106
104
- uses : actions/checkout@v4
107
105
with :
108
106
ref : ${{ needs.open-release.outputs.TAG }}
109
- token : ${{ secrets.WORKFLOW_TOKEN }}
110
107
- uses : actions/setup-java@v4
111
108
with :
112
109
distribution : zulu
@@ -121,24 +118,57 @@ jobs:
121
118
- name : Cache Dependencies
122
119
uses : actions/cache@v4
123
120
with :
124
- path : |
125
- ~/.m2/repository/*
121
+ path : ~/.m2/repository/*
126
122
key : " ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
127
123
128
124
- name : Test build
129
125
run : ./mvnw --batch-mode -V -e verify
130
126
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
132
128
- name : Deploy to Maven Central
133
129
run : >
134
130
./mvnw --batch-mode -V -e -pl '!test,!benchmark,!benchmark/java,!benchmark/guava,!benchmark/assertj'
135
131
-Dstaging_repository_id=${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}
136
132
-Dstaging_host="${{ env.STAGING_HOST }}"
137
133
deploy -P release
138
134
139
- close-release :
135
+ document :
136
+ name : Publish Javadoc documentation
140
137
needs : [ open-release, deploy ]
141
138
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
142
172
steps :
143
173
- uses : actions/checkout@v4
144
174
with :
@@ -158,8 +188,7 @@ jobs:
158
188
- name : Cache Dependencies
159
189
uses : actions/cache@v4
160
190
with :
161
- path : |
162
- ~/.m2/repository/*
191
+ path : ~/.m2/repository/*
163
192
key : " ${{ runner.OS }}-maven-${{ hashFiles('**/pom.xml') }}"
164
193
165
194
- name : Close staging repository
@@ -191,13 +220,6 @@ jobs:
191
220
gpg-private-key : ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
192
221
gpg-passphrase : MAVEN_GPG_PASSPHRASE
193
222
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
-
201
223
- name : Drop staging repository
202
224
if : needs.open-release.outputs.STAGING_REPOSITORY_ID != '' && needs.open-release.outputs.STAGING_PROFILE_ID != ''
203
225
run : >
@@ -206,17 +228,12 @@ jobs:
206
228
-d '{"data": {"stagedRepositoryId": "${{ needs.open-release.outputs.STAGING_REPOSITORY_ID }}", "description": "Dropping repository"}}'
207
229
'https://${{ env.STAGING_HOST }}/service/local/staging/profiles/${{ needs.open-release.outputs.STAGING_PROFILE_ID }}/drop'
208
230
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 != ''
216
233
run : |
217
234
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 }}
220
237
if [ "${{ github.ref_type }}" == "tag" ]; then
221
238
git ${{ github.ref_type }} -f ${{ github.ref_name }}
222
239
fi
@@ -226,4 +243,16 @@ jobs:
226
243
- name : Delete tag
227
244
if : needs.open-release.outputs.TAG != ''
228
245
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