forked from plantuml/plantuml
-
Notifications
You must be signed in to change notification settings - Fork 0
340 lines (314 loc) · 12.5 KB
/
ci.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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: CI
on:
create:
pull_request:
types: [ opened, synchronize, reopened ]
paths-ignore:
- '**.md'
- 'docs/**'
push:
branches:
- master
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
workflow_config:
runs-on: ubuntu-latest
outputs:
do_release: ${{ steps.config.outputs.do_release }}
do_snapshot_release: ${{ steps.config.outputs.do_snapshot_release }}
pom_version: ${{ steps.config.outputs.pom_version }}
do_javadoc: ${{ steps.config.outputs.do_javadoc }}
do_test_linux: ${{ steps.config.outputs.do_test_linux }}
do_test_windows: ${{ steps.config.outputs.do_test_windows }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Configure workflow
id: config
env:
ACTOR: ${{ github.actor }}
EVENT_ACTION: ${{ github.event.action }}
REF_TYPE: ${{ github.event.ref_type }}
REF: ${{ github.event.ref }}
run: |
cat <<-EOF
::group::Debug Info
GITHUB_EVENT_NAME : '${GITHUB_EVENT_NAME}'
EVENT_ACTION : '${EVENT_ACTION}'
REF_TYPE : '${REF_TYPE}'
REF : '${REF}'
ACTOR : '${ACTOR}'
GITHUB_REPOSITORY_OWNER : '${GITHUB_REPOSITORY_OWNER}'
::endgroup::
EOF
# Do a release when a git tag starting with 'v' has been created by a suitable user.
# (We match against github.repository_owner as a kludge so that forked repos can release themselves when testing the workflow)
if [[ "${GITHUB_EVENT_NAME}" == "create" && "${REF_TYPE}" == "tag" && "${REF}" == v* && \
( "${ACTOR}" == "arnaudroques" || "${ACTOR}" == "${GITHUB_REPOSITORY_OWNER}" ) \
]]; then
echo "::notice title=::This run will release '${REF}'"
echo "do_release=true" >> $GITHUB_OUTPUT
echo "pom_version=${REF#v}"
echo "pom_version=${REF#v}" >> $GITHUB_OUTPUT # pom_version is the tag without the 'v' prefix
echo "do_javadoc=true" >> $GITHUB_OUTPUT
echo "This run will update the Javadoc"
elif [[ "${GITHUB_EVENT_NAME}" =~ push|workflow_dispatch && "${REF}" == "refs/heads/master" && "${ACTOR}" == "arnaudroques" ]]; then
echo "::notice title=::This run will release a snapshot"
echo "do_snapshot_release=true" >> $GITHUB_OUTPUT
V=$(perl -ne 'if (/return (\d{6,7});/) {$v=$1} if (/final int beta = (\d+);/) {$b=$1} END{print(substr($v, 0, 1),".", substr($v, 1, 4),"."); if ($b) {print(int(substr($v+1, 5)), "beta", $b);} else {print(int(substr($v, 5)))}}' src/net/sourceforge/plantuml/version/Version.java)
echo "pom_version=$V-SNAPSHOT"
echo "pom_version=$V-SNAPSHOT" >> $GITHUB_OUTPUT # pom_version is taken from Version.java
echo "do_javadoc=true" >> $GITHUB_OUTPUT
echo "This run will update the Javadoc"
else
echo "This run will NOT make a release"
echo "do_javadoc=false" >> $GITHUB_OUTPUT
echo "This run will NOT update the Javadoc"
fi
echo "do_test_linux=true" >> $GITHUB_OUTPUT
echo "do_test_windows=false" >> $GITHUB_OUTPUT
# We run the tests on many OS / Java combinations but also the Compile step because some users build
# their own jars from source, so it is good for CI to check that is working on all combinations.
# We split windows and ubuntu because windows is so slow...
test_linux:
needs: workflow_config
strategy:
fail-fast: false
matrix:
java_version: [ 8, 17 ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout the repository
if: needs.workflow_config.outputs.do_test_linux == 'true'
uses: actions/checkout@v4
- name: Set up java
if: needs.workflow_config.outputs.do_test_linux == 'true'
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java_version }}
distribution: temurin
cache: gradle
# Compile / Test / Package are separate steps so the reason for any failure is more obvious in GitHub UI
- name: Compile
if: needs.workflow_config.outputs.do_test_linux == 'true'
run: gradle -q compileJava --no-daemon
- name: Test
if: needs.workflow_config.outputs.do_test_linux == 'true'
run: gradle test --no-daemon -i
- name: Upload test reports
uses: actions/upload-artifact@v4
if: needs.workflow_config.outputs.do_test_linux == 'true'
with:
# Using github.run_number here to reduce confusion when downloading & comparing from several builds
name: ${{ github.run_number }}-${{ matrix.os }}-java-${{ matrix.java_version }}-test-reports
path: build/reports/tests/
build_artifacts:
needs: [ workflow_config ]
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.version.outputs.release_version }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: gradle
# - name: Set version in gradle.properties
# if: env.POM_VERSION
# env:
# POM_VERSION: ${{ needs.workflow_config.outputs.pom_version }}
# run: |
# sed -i "s/version = .*/version = $POM_VERSION/" gradle.properties
# cat gradle.properties
- name: Generate artifacts
run: |
echo "print gradle.properties"
cat gradle.properties
gradle clean build \
pdfJar \
generateMetadataFileForMavenPublication generatePomFileForMavenPublication \
-x test
find . -name "*.jar"
- name: Sign artifacts
if: env.ORG_GRADLE_PROJECT_signingKey
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ARTIFACT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }}
run: |
gradle -i signMavenPublication signPdfJar
ls -l build/libs
ls -l plantuml-asl/build/libs
ls -l plantuml-bsd/build/libs
ls -l plantuml-epl/build/libs
ls -l plantuml-lgpl/build/libs
ls -l plantuml-mit/build/libs
ls -l plantuml-gplv2/build/libs
- name: Get release version
id: version
run: |
echo "release_version=$(gradle properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_OUTPUT
- name: Cache libs
uses: actions/cache/save@v4
with:
path: |
build/libs
build/publications
plantuml-asl/build/libs
plantuml-bsd/build/libs
plantuml-epl/build/libs
plantuml-lgpl/build/libs
plantuml-mit/build/libs
plantuml-gplv2/build/libs
key: "libs-${{ github.run_id }}"
enableCrossOsArchive: true
deploy_javadoc:
needs: [ build_artifacts, test_linux ]
if: needs.workflow_config.outputs.do_javadoc == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Build Javadoc
run: gradle javadoc
- name: Deploy Javadoc to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/docs/javadoc
upload:
if: |
needs.workflow_config.outputs.do_release == 'true' ||
needs.workflow_config.outputs.do_snapshot_release == 'true'
needs: [ workflow_config, build_artifacts, test_linux ]
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Restore Libs cache
uses: actions/cache/restore@v4
with:
path: |
build/libs
build/publications
plantuml-asl/build/libs
plantuml-bsd/build/libs
plantuml-epl/build/libs
plantuml-lgpl/build/libs
plantuml-mit/build/libs
plantuml-gplv2/build/libs
key: "libs-${{ github.run_id }}"
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
# Using github.run_number here to reduce confusion when downloading & comparing artifacts from several builds
name: ${{ github.run_number }}-artifacts
path: |
build/libs/*
build/publications/maven/*
plantuml-asl/build/libs
plantuml-bsd/build/libs
plantuml-epl/build/libs
plantuml-lgpl/build/libs
plantuml-mit/build/libs
plantuml-gplv2/build/libs
- name: Create snapshot
if: needs.workflow_config.outputs.do_snapshot_release == 'true'
env:
RELEASE_VERSION: ${{ needs.build_artifacts.outputs.RELEASE_VERSION }}
GITHUB_TOKEN: ${{ github.token }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
#do not remove signing key and password or signatures will not be published
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ARTIFACT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }}
run: |
echo "print gradle.properties"
cat gradle.properties
echo "RELEASE_VERSION=$RELEASE_VERSION"
.github/scripts/release-snapshot.sh
- name: Create release in GitHub and OSSRH
if: needs.workflow_config.outputs.do_release == 'true'
env:
RELEASE_VERSION: ${{ needs.build_artifacts.outputs.RELEASE_VERSION }}
GITHUB_TOKEN: ${{ github.token }}
TAG: ${{ github.event.ref }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
#do not remove signing key and password or signatures will not be published
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ARTIFACT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ARTIFACT_SIGNING_PASSPHRASE }}
run: |
echo "print gradle.properties"
cat gradle.properties
echo "RELEASE_VERSION=$RELEASE_VERSION"
.github/scripts/release.sh
gradle --debug publish
push_to_docker_registry:
needs: [ workflow_config, upload, test_linux ]
if: needs.workflow_config.outputs.do_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Log into Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build/push container image
uses: docker/build-push-action@v6
with:
context: .
push: true
build-args: |
PLANTUML_VERSION=${{ github.event.ref }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64