-
Notifications
You must be signed in to change notification settings - Fork 0
307 lines (254 loc) · 9.34 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
name: Publish
on:
workflow_dispatch:
inputs:
environment:
description: The environment to publish to
type: environment
concurrency:
group: "publish"
cancel-in-progress: false
env:
JDK_VERSION: "23"
DOCS_BUNDLE: docs.bundle
DOCS_BUNDLE_ARTIFACT: docs-bundle
WORKSPACE_ARCHIVE: workspace.tar
WORKSPACE_ARTIFACT: build-results
jobs:
build:
name: Build
strategy:
matrix:
os: [ macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JDK_VERSION }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Gradle Assemble
run: ./gradlew assemble --info -S --show-version
- name: Tar files
run: tar --exclude='.git' --exclude=${{ env.WORKSPACE_ARCHIVE }} -cvf ${{ env.WORKSPACE_ARCHIVE }} .
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ env.WORKSPACE_ARTIFACT }}
path: ${{ env.WORKSPACE_ARCHIVE }}
retention-days: 1
check:
name: Check
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
needs: build
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/download-artifact@v4
with:
# https://github.com/actions/runner/issues/409#issuecomment-752775072
name: ${{ matrix.os == 'windows-latest' && 'ubuntu-latest' || matrix.os }}-${{ env.WORKSPACE_ARTIFACT }}
path: .
- name: Untar
run: |
tar -xvf ${{ env.WORKSPACE_ARCHIVE }}
rm ${{ env.WORKSPACE_ARCHIVE }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JDK_VERSION }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Gradle Check
run: ./gradlew check --info -S --show-version
build-docs:
name: Build Documentation
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/download-artifact@v4
with:
name: ubuntu-latest-${{ env.WORKSPACE_ARTIFACT }}
path: .
- name: Untar
run: |
tar -xvf ${{ env.WORKSPACE_ARCHIVE }}
rm ${{ env.WORKSPACE_ARCHIVE }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JDK_VERSION }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Dokka Generate
run: ./gradlew :dokkaGenerate --info -S --show-version
- name: Setup Python
uses: actions/setup-python@v5
- name: Install dependencies
run: pip3 install --no-deps -r .github/workflows/mkdocs-requirements.txt
- name: Configure git for mike
shell: bash
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git fetch origin gh-pages
- name: Get Version
id: version
run: grep '^version=' gradle.properties >> $GITHUB_OUTPUT
- name: Mike Deploy
env:
VERSION_NAME: ${{ steps.version.outputs.version }}
run: mike deploy -u $VERSION_NAME latest
- name: Create Bundle
run: git bundle create ${{ env.DOCS_BUNDLE }} gh-pages
- name: Upload workspace artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.DOCS_BUNDLE_ARTIFACT }}
path: ${{ env.DOCS_BUNDLE }}
retention-days: 1
ghp-release:
name: Release Documentation to GitHub Pages
needs: [build-docs, close-staging-repository]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/download-artifact@v4
with:
name: ${{ env.DOCS_BUNDLE_ARTIFACT }}
path: .
- name: Unpack git bundle
run: |
git fetch ${{ env.DOCS_BUNDLE }} gh-pages:gh-pages
git switch --force gh-pages
- name: Configure git
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Push to GH Pages
run: git push origin gh-pages
create-staging-repository:
name: Create Staging Repository
needs: check
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- id: create
uses: TheMrMilchmann/nexus-actions/create-staging-repo@v2
with:
base-url: ${{ vars.SONATYPE_BASE_URL }}
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staging-profile-id: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
description: ${{ github.repository }}/${{ github.workflow }}#${{ github.run_number }}
outputs:
staging-repository-id: ${{ steps.create.outputs.staging-repository-id }}
nexus-upload:
name: Upload to Nexus
needs: create-staging-repository
strategy:
matrix:
os: [ macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
environment: ${{ inputs.environment }}
steps:
- name: Checkout
uses: actions/download-artifact@v4
with:
name: ${{ matrix.os }}-${{ env.WORKSPACE_ARTIFACT }}
path: .
- name: Untar
run: |
tar -xvf ${{ env.WORKSPACE_ARCHIVE }}
rm ${{ env.WORKSPACE_ARCHIVE }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ env.JDK_VERSION }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Gradle Publish
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeBaseUrl: ${{ vars.SONATYPE_BASE_URL }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_stagingRepositoryId: ${{ needs.create-staging-repository.outputs.staging-repository-id }}
# Running this on linux and macOS means that we might overwrite some artifacts but that's not an issue since
# they should be identical anyway.
run: ./gradlew publishAllPublicationsToMavenRepository --info -S --show-version --no-configuration-cache
close-staging-repository:
name: Close Staging Repository
needs: [create-staging-repository, nexus-upload]
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: TheMrMilchmann/nexus-actions/close-staging-repo@v2
with:
base-url: ${{ vars.SONATYPE_BASE_URL }}
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staging-repository-id: ${{ needs.create-staging-repository.outputs.staging-repository-id }}
description: ${{ github.repository }}/${{ github.workflow }}#${{ github.run_number }}
nexus-release:
name: Release to Nexus
needs: [create-staging-repository, close-staging-repository, ghp-release]
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Release Staging Repository
uses: TheMrMilchmann/nexus-actions/release-staging-repo@v2
with:
base-url: ${{ vars.SONATYPE_BASE_URL }}
username: ${{ secrets.SONATYPE_USERNAME }}
password: ${{ secrets.SONATYPE_PASSWORD }}
staging-repository-id: ${{ needs.create-staging-repository.outputs.staging-repository-id }}
description: ${{ github.repository }}/${{ github.workflow }}#${{ github.run_number }}
# So, what's happening here?
#
# Basically, restoring the workspace state between jobs is incredibly annoying.
# We can get reasonable support by using the upload-/download-artifact
# actions, but they suffer from a severe limitation:
# GH Actions has a storage limit and the minimum retention is 24 hours...
#
# Since the storage quota is limited, we have to make sure that the artifact
# is removed. Unfortunately, there is no official way to do this, so we resort
# to a third party action for now.
#
# See also: https://github.com/actions/upload-artifact/issues/290
cleanup:
name: Cleanup
if: ${{ always() }}
needs: nexus-release
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Cleanup
uses: GeekyEggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b
with:
name: macos-latest-${{ env.WORKSPACE_ARTIFACT }}
- name: Cleanup
uses: GeekyEggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b
with:
name: ubuntu-latest-${{ env.WORKSPACE_ARTIFACT }}
- name: Cleanup
uses: GeekyEggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b
with:
name: ubuntu-latest-${{ env.DOCS_BUNDLE_ARTIFACT }}