forked from unbroken-dome/gradle-xjc-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
271 lines (224 loc) · 9.79 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
name: CI-Gradle-build
on:
push:
release:
workflow_dispatch:
inputs:
GRADLE_TARGET_ENABLE_integrationTest:
description: 'Run with integrationTest ?'
default: false
type: boolean
schedule:
# FIXME we probably want this to work on the latest release tag only
# * is a special character in YAML
# setup monthly background build
- cron: '45 4 18 * *'
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
jvm: ['8', '11']
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Version
run: |
if [ -z "${GRADLE_TARGET_ENABLE_integrationTest}" ] && [ -n "${{ github.event.schedule }}" ]; then
# force this on for schedule build
# "${{ github.event.schedule }}" == "45 4 18 * *"
# $GITHUB_EVENT_NAME == "schedule"
echo "GRADLE_TARGET_ENABLE_integrationTest=true" >> $GITHUB_ENV
fi
target_plugin="org.unbroken-dome.xjc"
target_group=$(grep "^group=" gradle.properties | cut -d'=' -f2-)
target_artifact="gradle-xjc-plugin"
target_version=$(grep "^version=" gradle.properties | cut -d'=' -f2-)
echo "target_plugin=$target_plugin" >> $GITHUB_ENV
echo "target_group=$target_group" >> $GITHUB_ENV
echo "target_artifact=$target_artifact" >> $GITHUB_ENV
echo "target_version=$target_version" >> $GITHUB_ENV
- name: Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: ${{ matrix.jvm }}
- name: Cache
uses: actions/cache@v3
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/gradle-build-action@v2
- name: Gradle - build
run: ./gradlew build
- name: Gradle - check
run: ./gradlew check
- name: Gradle - integrationTest
if: ${{ vars.GRADLE_TARGET_ENABLE_integrationTest == 'true' || inputs.GRADLE_TARGET_ENABLE_integrationTest }}
run: ./gradlew integrationTest
- name: Gradle - asciidoctor
run: ./gradlew asciidoctor
- name: Gradle - dokka
run: ./gradlew dokka
- name: Gradle - publish
run: ./gradlew publish
- name: Upload - prepare
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
mkdir dist;
for dir in $(find . -type d -path "*/build/repo");
do
cp -a "$dir" "dist/";
done
find "dist" -type f -exec ls -ld {} \;
du -s "dist"
mkdir -p build/gh-pages
cp -a build/reports/tests build/gh-pages/
docs_build_dir="build"
[ -d docs/build ] && docs_build_dir="docs/build" || true
cp -a $docs_build_dir/asciidoc/html5/* build/gh-pages/
cp -a $docs_build_dir/dokka build/gh-pages/
mkdir -p build/gh-pages/maven2
cp -a build/repo/* build/gh-pages/maven2/
ls -lad build/gh-pages
du -s build/gh-pages
- name: Upload - java${{ matrix.jvm }}-github-pages
uses: actions/upload-pages-artifact@main
with:
name: java${{ matrix.jvm }}-github-pages
path: build/gh-pages/
retention-days: 1
- name: Upload - perform
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: java${{ matrix.jvm }}-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts
path: dist/repo/*
if-no-files-found: error
gh-pages-prepare:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Version
run: |
if [ -z "${GRADLE_TARGET_ENABLE_integrationTest}" ] && [ -n "${{ github.event.schedule }}" ]; then
# force this on for schedule build
# "${{ github.event.schedule }}" == "45 4 18 * *"
# $GITHUB_EVENT_NAME == "schedule"
echo "GRADLE_TARGET_ENABLE_integrationTest=true" >> $GITHUB_ENV
fi
target_plugin="org.unbroken-dome.xjc"
target_group=$(grep "^group=" gradle.properties | cut -d'=' -f2-)
target_artifact="gradle-xjc-plugin"
target_version=$(grep "^version=" gradle.properties | cut -d'=' -f2-)
echo "target_plugin=$target_plugin" >> $GITHUB_ENV
echo "target_group=$target_group" >> $GITHUB_ENV
echo "target_artifact=$target_artifact" >> $GITHUB_ENV
echo "target_version=$target_version" >> $GITHUB_ENV
- name: Download - java8-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts
uses: actions/download-artifact@v3
with:
name: java8-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts
path: build/java8-artifacts/
- name: Download - java8-github-pages
uses: actions/download-artifact@v3
with:
name: java8-github-pages
path: build/java8-github-pages-artifacts/
- name: Download - java11-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts
uses: actions/download-artifact@v3
with:
name: java11-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts
path: build/java11-artifacts/
- name: Download - java11-github-pages
uses: actions/download-artifact@v3
with:
name: java11-github-pages
path: build/java11-github-pages-artifacts/
- name: Shell
run: |
pwd
ls -la
find . -type f
ls -lR build
echo "#### build/java8-github-pages-artifacts/artifact.tar:"
#[ ! -f "build/java8-github-pages-artifacts/artifact.tar" ] || tar -tvf "build/java8-github-pages-artifacts/artifact.tar"
mkdir -p build/java8-github-pages/
tar -xvf build/java8-github-pages-artifacts/artifact.tar -C build/java8-github-pages/
echo "#### build/java11-github-pages-artifacts/artifact.tar:"
#[ ! -f "build/java11-github-pages-artifacts/artifact.tar" ] || tar -tvf "build/java11-github-pages-artifacts/artifact.tar"
mkdir -p build/java11-github-pages/
tar -xvf build/java11-github-pages-artifacts/artifact.tar -C build/java11-github-pages/
mkdir -p build/gh-pages/
# build/gh-pages/artifacts
mkdir -p build/gh-pages/artifacts
tar -cf "build/gh-pages/artifacts/java8-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts.tar.gz" -C build/java8-artifacts/ .
pushd build/java8-artifacts
zip -q -r "../gh-pages/artifacts/java8-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts.zip" .
popd
tar -cf "build/gh-pages/artifacts/java11-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts.tar.gz" -C build/java11-artifacts/ .
pushd build/java11-artifacts
zip -q -r "../gh-pages/artifacts/java11-${{ env.target_group }}-${{ env.target_artifact }}-${{ env.target_version }}-artifacts.zip" .
popd
# build/gh-pages/index.html (asciidoctor)
# build/gh-pages/dokka/
cp -av build/java8-github-pages/* build/gh-pages/
mkdir -p build/gh-pages/java8
# build/gh-pages/java8/tests/
cp -a build/java8-github-pages/tests build/gh-pages/java8/
# build/gh-pages/java8/maven2/
cp -a build/java8-github-pages/maven2 build/gh-pages/java8/
touch build/gh-pages/java8/maven2/M2_Java8_Artifacts.txt
mkdir -p build/gh-pages/java11
# build/gh-pages/java11/tests/
cp -a build/java11-github-pages/tests build/gh-pages/java11/
# build/gh-pages/java11/maven2/
cp -a build/java11-github-pages/maven2 build/gh-pages/java11/
touch build/gh-pages/java11/maven2/M2_Java11_Artifacts.txt
echo "#### DONE ####"
pwd
ls -la
find . -type f
ls -lR build
- name: github-pages - artifacts/ Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@19ee734e017b656528749434335f75a1efb931bc
with:
FOLDER: build/gh-pages/artifacts/ #directory to generate index
- name: github-pages - java8/ Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@19ee734e017b656528749434335f75a1efb931bc
with:
FOLDER: build/gh-pages/java8/ #directory to generate index
- name: github-pages - java11/ Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@19ee734e017b656528749434335f75a1efb931bc
with:
FOLDER: build/gh-pages/java11/ #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@v2