-
Notifications
You must be signed in to change notification settings - Fork 1
359 lines (294 loc) · 13.8 KB
/
build.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
name: CI-Gradle-build
on:
push:
workflow_dispatch:
schedule:
# * is a special character in YAML
# setup monthly background build
- cron: '30 4 14 * *'
jobs:
build:
strategy:
max-parallel: 3
matrix:
os: [ubuntu-latest] #, macos-latest, windows-latest]
jaxb: ['2.2', '2.3', '3.0']
fail-fast: false
runs-on: ${{ matrix.os }}
environment: CI
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: JVM Download
env:
JVM11_B_URL: ${{ vars.JVM11_B_URL }}
run: |
echo -n "$JVM11_B_URL" | wget -q -O $RUNNER_TEMP/java_package.tar.gz -i -
gunzip -t $RUNNER_TEMP/java_package.tar.gz
- name: Java
uses: actions/setup-java@v4
with:
distribution: 'jdkfile' # temurin
jdkFile: ${{ runner.temp }}/java_package.tar.gz
java-version: 11
architecture: x64
mvn-toolchain-vendor: 'jvm11_b'
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties', '**/gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Gradle - setup
uses: gradle/actions/setup-gradle@v4
- name: Gradle - gradle.properties
shell: bash
run: |
rm -f gradle.properties
propFile="$(echo -n "jaxb${{ matrix.jaxb }}" | tr '.' '_').properties" # jaxb2_2.properties
cp -v ".github/$propFile" gradle.properties || exit 1
echo "=== gradle.properties ==="
grep -v "^#" gradle.properties
projectVersion=$(egrep "^projectVersion\s*=" gradle.properties | cut -d '=' -f2- | tr -d '\r\n')
echo "projectVersion=$projectVersion" >> $GITHUB_ENV
if [ -z "$projectVersion" ]; then
echo "projectVersion=$projectVersion INVALID" 1>&2
exit 1
fi
if echo -n $projectVersion | fgrep -q -- "-SNAPSHOT"
then
snapshotVersion=$projectVersion # empty if not SNAPSHOT
isSnapshot="true"
fi
echo "snapshotVersion=$snapshotVersion" >> $GITHUB_ENV
echo "isSnapshot=$isSnapshot" >> $GITHUB_ENV
# Resolve external dependecies (this will validate org.darrylmiles.forked.org.unbroken-dome.xjc is accessible)
- name: Gradle - refresh-dependencies
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew --refresh-dependencies clean
- name: Gradle - build
run: ./gradlew build -Djavax.xml.accessExternalSchema=file,jar,jar:file,maven,classpath -Djavax.xml.accessExternalDTD=file,jar,jar:file,maven,classpath
# -Djavax.xml.accessExternalDTD=file,jar,jar:file,maven,classpath
# -Djavax.xml.accessExternalSchema=file,jar,jar:file,maven,classpath
# -Djavax.xml.accessExternalStylesheet=file,jar,jar:file,maven,classpath
- name: Gradle - check
run: ./gradlew check
- name: Gradle - publish
run: ./gradlew publish
- name: Gradle - publish github-packages
if: github.actor == 'dlmiles'
run: ./gradlew -PpublishMode=github-packages publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload - prepare
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
mkdir -p dist/content/
for dir in $(find . -type d -path "*/build/repo")
do
cp -a "$dir" "dist/content/"
done
mv "dist/content/repo" "dist/content/maven2" # rename directory
#declare -p # careful if permissions are set
# GIT SHORT HASH
echo "GITHUB_SHA=$GITHUB_SHA"
echo "GITHUB_SHA_SHORT=$(echo -n $GITHUB_SHA | cut -c 1-7)"
githash=$(git log -1 --format='%h')
echo "githash=$githash"
echo "githash=$githash" >> $GITHUB_ENV
dash_githash=${githash:+-$githash}
echo "dash_githash=$dash_githash"
echo "dash_githash=$dash_githash" >> $GITHUB_ENV
# YYYYMMDD from JAR when -SNAPSHOT otherwise $projectVersion
if [ -n "$projectVersion" ]; then
buildid=$projectVersion
fi
# isolate YYYYMMDD from SNAPSHOT version filename
[ -n "$snapshotVersion" ] && buildyyyymmdd=$(find dist \
-type f \
-path "*/*-SNAPSHOT/*" \
-name "ipxact-1685-2014-*.jar" \
-printf "%f\n" | \
sed -e 's#ipxact-1685-2014-##' \
-e 's#.jar$##' \
-e 's#-[a-z]\+[g-z][a-z]\+$##' \
-e 's#^[^-]\+\-##' \
-e 's#\-[^-]*$##' \
-e 's#\..*$##' | \
sort -r | uniq | head -n 1)
[ -z "$buildyyyymmdd" ] && buildyyyymmdd=$(date --utc "+%Y%m%d")
echo "buildyyyymmdd=$buildyyyymmdd"
echo "buildyyyymmdd=$buildyyyymmdd" >> $GITHUB_ENV
if [ -n "$snapshotVersion" ]; then
dash_buildyyyymmdd=${buildyyyymmdd:+-$buildyyyymmdd}
echo "dash_buildyyyymmdd=$dash_buildyyyymmdd"
echo "dash_buildyyyymmdd=$dash_buildyyyymmdd" >> $GITHUB_ENV
fi
echo "buildid=$buildid" >> $GITHUB_ENV
dash_buildid=${buildid:+-$buildid}
echo "dash_buildid=$dash_buildid" >> $GITHUB_ENV
echo "=== \$GITHUB_ENV ==="
cat $GITHUB_ENV
mkdir -p dist/content/javadoc
for dir in $(find . -type d -path "*/build/docs/*" -name javadoc)
do
# ./ipxact-1685-2014/build/docs/javadoc
echo $dir
stem=$(echo -n "$dir" | sed -e 's#^./##' -e 's#/build/docs/javadoc$##')
# ipxact-1685-2014
cp -a "$dir" "dist/content/javadoc/$stem"
done
mkdir -p dist/content/docs
cp docs/index.html dist/content/docs/
BUILD_PROPS="dist/content/build.properties"
echo "#" >> $BUILD_PROPS
echo "# $(date --utc)" >> $BUILD_PROPS
echo "#" >> $BUILD_PROPS
echo "matrix_os=${{ matrix.os }}" >> $BUILD_PROPS
echo "matrix_jaxb=${{ matrix.jaxb }}" >> $BUILD_PROPS
echo "projectVersion=$projectVersion" >> $BUILD_PROPS
echo "snapshotVersion=$snapshotVersion" >> $BUILD_PROPS
echo "isSnapshot=$isSnapshot" >> $BUILD_PROPS
echo "buildid=$buildid" >> $BUILD_PROPS
echo "dash_buildid=$dash_buildid=" >> $BUILD_PROPS
echo "buildyyyymmdd=$buildyyyymmdd" >> $BUILD_PROPS
echo "dash_buildyyyymmdd=$dash_buildyyyymmdd" >> $BUILD_PROPS
echo "githash=$githash" >> $BUILD_PROPS
echo "dash_githash=$dash_githash" >> $BUILD_PROPS
echo "#" >> $BUILD_PROPS
sed -e 's#\"#\\\"#' -e 's#\(.*=\)#\1\"#' -e 's#\(.*=\".*\)$#\1"#' $BUILD_PROPS > dist/content/build.sh
echo "=== $BUILD_PROPS:"
cat $BUILD_PROPS
echo "=== dist/ summary:"
echo "file_count=$(find dist -type f | wc -l)"
echo "dir_count=$(find dist -type d | wc -l)"
echo "disk_usage=$(du -sh dist)"
tar -zcf dist/artifacts.tar.gz -C dist/content .
- name: Upload - perform
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: java-schema-ipxact-maven2-jaxb${{ matrix.jaxb }}-artifacts
path: dist/artifacts.tar.gz
retention-days: 1
if-no-files-found: error
gh-pages-prepare:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# java-schema-ipxact-maven-m2-artifacts-jaxb${{ matrix.jaxb }}${{ env.dash_buildid }}${{ env.dash_buildyyyymmdd }}${{ env.dash_githash }}
- name: Download - java-schema-ipxact-maven2-jaxb2.2-artifacts
uses: actions/download-artifact@v4
with:
name: java-schema-ipxact-maven2-jaxb2.2-artifacts
path: build/java-jaxb2.2-artifacts/
- name: Download - java-schema-ipxact-maven2-jaxb2.3-artifacts
uses: actions/download-artifact@v4
with:
name: java-schema-ipxact-maven2-jaxb2.3-artifacts
path: build/java-jaxb2.3-artifacts/
- name: Download - java-schema-ipxact-maven2-jaxb3.0-artifacts
uses: actions/download-artifact@v4
with:
name: java-schema-ipxact-maven2-jaxb3.0-artifacts
path: build/java-jaxb3.0-artifacts/
- name: Shell
run: |
pwd
ls -la
ls -la build || true
ls -la build/java-jaxb2.2-artifacts || true
ls -la build/java-jaxb2.3-artifacts || true
ls -la build/java-jaxb3.0-artifacts || true
#find . -type f
#ls -lR build
#declare -p # careful if permissions are set
echo "### build/java-jaxb2.2-artifacts/artifacts.tar.gz:"
[ ! -f "build/java-jaxb2.2-artifacts/artifacts.tar.gz" ] || tar -xf "build/java-jaxb2.2-artifacts/artifacts.tar.gz" -C build/java-jaxb2.2-artifacts
echo "### build/java-jaxb2.3-artifacts/artifacts.tar.gz:"
[ ! -f "build/java-jaxb2.3-artifacts/artifacts.tar.gz" ] || tar -xf "build/java-jaxb2.3-artifacts/artifacts.tar.gz" -C build/java-jaxb2.3-artifacts
echo "### build/java-jaxb3.0-artifacts/artifacts.tar.gz:"
[ ! -f "build/java-jaxb3.0-artifacts/artifacts.tar.gz" ] || tar -xf "build/java-jaxb3.0-artifacts/artifacts.tar.gz" -C build/java-jaxb3.0-artifacts
cat "build/java-jaxb2.2-artifacts/build.properties"
mkdir -p build/gh-pages/
# build/gh-pages/artifacts
mkdir -p build/gh-pages/artifacts
source "build/java-jaxb2.2-artifacts/build.sh"
name="java-schema-ipxact-maven2-jaxb${matrix_jaxb}${dash_buildid}${dash_buildyyyymmdd}${dash_githash}-artifacts"
tar -cf "build/gh-pages/artifacts/${name}.tar.gz" -C "build/java-jaxb${matrix_jaxb}-artifacts/maven2" .
pushd "build/java-jaxb${matrix_jaxb}-artifacts/maven2"
zip -q -r "../../gh-pages/artifacts/${name}.zip" .
popd
source "build/java-jaxb2.3-artifacts/build.sh"
name="java-schema-ipxact-maven2-jaxb${matrix_jaxb}${dash_buildid}${dash_buildyyyymmdd}${dash_githash}-artifacts"
tar -cf "build/gh-pages/artifacts/${name}.tar.gz" -C "build/java-jaxb${matrix_jaxb}-artifacts/maven2" .
pushd "build/java-jaxb${matrix_jaxb}-artifacts/maven2"
zip -q -r "../../gh-pages/artifacts/${name}.zip" .
popd
source "build/java-jaxb3.0-artifacts/build.sh"
name="java-schema-ipxact-maven2-jaxb${matrix_jaxb}${dash_buildid}${dash_buildyyyymmdd}${dash_githash}-artifacts"
tar -cf "build/gh-pages/artifacts/${name}.tar.gz" -C "build/java-jaxb${matrix_jaxb}-artifacts/maven2" .
pushd "build/java-jaxb${matrix_jaxb}-artifacts/maven2"
zip -q -r "../../gh-pages/artifacts/${name}.zip" .
popd
# build/gh-pages/javadoc
mkdir -p build/gh-pages/javadoc
cp -a build/java-jaxb2.2-artifacts/javadoc build/gh-pages/javadoc/jaxb2.2
cp -a build/java-jaxb2.3-artifacts/javadoc build/gh-pages/javadoc/jaxb2.3
cp -a build/java-jaxb3.0-artifacts/javadoc build/gh-pages/javadoc/jaxb3.0
# build/gh-pages/maven2
mkdir -p build/gh-pages/maven2
cp -a build/java-jaxb2.2-artifacts/maven2 build/gh-pages/
cp -a build/java-jaxb2.3-artifacts/maven2 build/gh-pages/
cp -a build/java-jaxb3.0-artifacts/maven2 build/gh-pages/
touch build/gh-pages/maven2/M2_Java8_Artifacts.txt
# build/gh-pages/index.html (asciidoctor)
cp -a build/java-jaxb3.0-artifacts/docs/* build/gh-pages/
echo "#### DONE ####"
pwd
ls -la
find . -type f
ls -lR build
- name: github-pages - artifacts/ Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@624ac8c4e56893256d3772f61a88e3b14d54314e
with:
FOLDER: build/gh-pages/artifacts/ #directory to generate index
- name: github-pages - maven2/ Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@624ac8c4e56893256d3772f61a88e3b14d54314e
with:
FOLDER: build/gh-pages/maven2/ #directory to generate index
- name: github-pages - javadoc/ Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@624ac8c4e56893256d3772f61a88e3b14d54314e
with:
FOLDER: build/gh-pages/javadoc/ #directory to generate index
- name: Upload - github-pages
uses: actions/upload-pages-artifact@main
with:
name: github-pages
path: build/gh-pages/
retention-days: 90
deploy:
if: ( github.ref == 'master' && github.event_name == 'push' ) || github.event_name == 'release' || github.event_name == 'schedule'
needs: gh-pages-prepare
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4