-
Notifications
You must be signed in to change notification settings - Fork 3
321 lines (319 loc) · 11 KB
/
build-test-and-publish.yaml
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
name: CI
on:
push:
branches:
- main
- 0.0.x
paths-ignore:
- "README.md"
- ".github/ISSUE_TEMPLATE/*.md"
pull_request:
branches:
- main
- 0.0.x
jobs:
build-maven:
name: Build Maven
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.tag.outputs.tag }}
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: "temurin" # See 'Supported distributions' for available options
java-version: "17"
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: New version
id: version
run: |
filter=$( awk -F '[.]' '{printf "v"$1"."$2".*"}' <<< $( yq -p xml '.project.version' pom.xml ) )
tag=$(git tag -l $filter --sort=-creatordate | head -1)
new_tag=$( cut -c2- <<< "$( awk -F '[.]' '{printf $1"."$2"."}' <<< $tag)$[$( awk -F '[.]' '{printf $3}' <<< $tag)+1]" )
echo "version=$new_tag" >> $GITHUB_OUTPUT
- name: New tag
id: tag
run: |
if [[ ${{ github.event_name }} == 'push' ]]; then
export TAG=$NEW_VERSION
export RELEASE="true"
else
export TAG=pr-${{ github.event.pull_request.number }}
export RELEASE="false"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "release=$RELEASE" >> $GITHUB_OUTPUT
env:
NEW_VERSION: ${{ steps.version.outputs.version }}
- name: MVN set version
run: |
if [[ ${{ github.event_name }} == 'push' ]]; then
mvn versions:set -DnewVersion=$NEW_VERSION
else
mvn versions:set -DnewVersion=$NEW_VERSION-PR-${{ github.event.pull_request.number }}-SNAPSHOT
fi
env:
NEW_VERSION: ${{ steps.version.outputs.version }}
- name: test and build JAR
run: mvn package -ntp -Drepo.login=${{ github.actor }} -Drepo.pwd=${{ secrets.GH_TOKEN }} -s .m2/settings.xml -Dmaven.test.skip
- name: Upload new versions in maven registry
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
mvn deploy -ntp -Drepo.login=${{ github.actor }} -Drepo.pwd=${{ secrets.GH_TOKEN }} -s .m2/settings.xml -DskipTests
fi
- name: Build and push Docker image camunda-formio-react-app
uses: softcannery/.github/actions/github-docker-registry@master
with:
chart-path: ./camunda-formio-react-app
git-username: ${{ github.actor }}
git-token: ${{ secrets.GH_TOKEN }}
image-name: camunda-formio-react-app
version: ${{ steps.tag.outputs.tag }}
release: ${{ steps.tag.outputs.release }}
- name: Build and push Docker image camunda-formio-example
uses: softcannery/.github/actions/github-docker-registry@master
with:
chart-path: ./camunda-formio-example
git-username: ${{ github.actor }}
git-token: ${{ secrets.GH_TOKEN }}
image-name: camunda-formio-example
version: ${{ steps.tag.outputs.tag }}
release: ${{ steps.tag.outputs.release }}
- name: Build and push Docker image camunda-formio-content
uses: softcannery/.github/actions/github-docker-registry@master
with:
chart-path: ./camunda-formio-content
git-username: ${{ github.actor }}
git-token: ${{ secrets.GH_TOKEN }}
image-name: camunda-formio-content
version: ${{ steps.tag.outputs.tag }}
release: ${{ steps.tag.outputs.release }}
build-plugin:
name: Build Camunda Modeler Plugin
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: build plugin
run: |
cd ./camunda-modeler-formio-plugin
chmod +x ./install.sh
export MODELER_DIR=$(pwd)
npm install -f
npm run build
cd ${MODELER_DIR}/resources/plugins/formio-plugin
zip -r -l ~/formio-plugin.zip ./
env:
NODE_OPTIONS: "--openssl-legacy-provider"
- name: Upload build results
uses: actions/upload-artifact@v4
with:
name: plugin
path: ~/formio-plugin.zip
retention-days: 1
build-deployment-plugin:
name: Build Camunda Modeler Deployment Plugin
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: build plugin
run: |
cd ./camunda-modeler-deployment-plugin
chmod +x ./install.sh
export MODELER_DIR=$(pwd)
npm install -f
npm run build
cd ${MODELER_DIR}/resources/plugins/deploy-plugin
zip -r -l ~/deploy-plugin.zip ./
env:
NODE_OPTIONS: "--openssl-legacy-provider"
- name: Upload build results
uses: actions/upload-artifact@v4
with:
name: deploy-plugin
path: ~/deploy-plugin.zip
retention-days: 1
run-modeler-tests:
name: Run modeler tests
needs:
- build-plugin
- build-deployment-plugin
- build-maven
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- uses: actions/download-artifact@v4
with:
name: plugin
path: ./
- uses: actions/download-artifact@v4
with:
name: deploy-plugin
path: ./
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: run services
env:
CR_PAT: ${{ secrets.GH_TOKEN }}
run: |
sed -i -e "s/IMAGE_TAG=.*/IMAGE_TAG=${{ needs.build-maven.outputs.tag }}/" ./.env
docker compose pull
docker compose -f "docker-compose.yml" up -d --no-build
- name: install modeller
run: |
wget https://downloads.camunda.cloud/release/camunda-modeler/5.30.0/camunda-modeler-5.30.0-linux-x64.tar.gz
tar -xvf camunda-modeler*.tar.gz
mkdir -p ~/.config/camunda-modeler/plugins
unzip formio-plugin.zip -d ~/.config/camunda-modeler/plugins/formio-plugin
unzip deploy-plugin.zip -d ~/.config/camunda-modeler/plugins/deploy-plugin
cd ./cucumber-tests
chmod +x ./healthcheck.sh
./healthcheck.sh
- name: Run Camunda Modeler test
uses: coactions/setup-xvfb@v1.0.1
with:
run: mvn clean verify -ntp -Dcucumber.filter.tags="@modeler"
working-directory: ./cucumber-tests
run-tests:
name: Run Tests
needs: [ build-maven ]
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin" # See 'Supported distributions' for available options
java-version: "17"
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: run services
env:
CR_PAT: ${{ secrets.GH_TOKEN }}
run: |
sed -i -e "s/IMAGE_TAG=.*/IMAGE_TAG=${{ needs.build-maven.outputs.tag }}/" ./.env
docker compose pull
docker compose -f "docker-compose.yml" up -d --no-build
- name: run cucumber tests
run: |
cd ./cucumber-tests
chmod +x ./healthcheck.sh
./healthcheck.sh
mvn clean verify -ntp -Dcucumber.filter.tags="@web"
- name: save test report
if: always()
run: |
cd ./cucumber-tests/target/site/serenity
zip -r -l ~/report.zip ./
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report
path: ~/report.zip
release:
name: Publish Release
if: github.event_name == 'push'
needs:
- build-maven
- build-plugin
- build-deployment-plugin
- run-modeler-tests
- run-tests
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: "temurin" # See 'Supported distributions' for available options
java-version: "17"
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/download-artifact@v4
with:
name: plugin
path: ./
- uses: actions/download-artifact@v4
with:
name: deploy-plugin
path: ./
- name: MVN set version
run: |
mvn versions:set -DnewVersion=$NEW_VERSION
env:
NEW_VERSION: ${{ needs.build-maven.outputs.version }}
- name: Create Release Tag
uses: softcannery/.github/actions/release-tag@master
with:
git-token: ${{ secrets.GH_TOKEN }}
version: v${{ needs.build-maven.outputs.version }}
- name: test and build JAR
run: mvn package -ntp -Drepo.login=${{ github.actor }} -Drepo.pwd=${{ secrets.GH_TOKEN }} -s .m2/settings.xml -Dmaven.test.skip
- name: Upload new versions in maven registry
run: |
mvn deploy -ntp -Drepo.login=${{ github.actor }} -Drepo.pwd=${{ secrets.GH_TOKEN }} -s .m2/settings.xml -DskipTests
- name: Release it
run: |
export PREV_VERSION=$(gh release list | grep Latest | awk '{print $3}')
gh release create v$NEW_VERSION --title v$NEW_VERSION --notes-start-tag $PREV_VERSION --generate-notes --latest ./formio-plugin.zip ./deploy-plugin.zip
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NEW_VERSION: ${{ needs.build-maven.outputs.version }}