-
Notifications
You must be signed in to change notification settings - Fork 8
241 lines (233 loc) · 7.48 KB
/
workflow.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
name: Build
on:
push:
branches:
- master
tags:
- 'v*.*.*'
paths-ignore:
- .dockerignore
- .gitignore
- Dockerfile
- LICENSE
- README.md
- demo-media/*
- chocolatey/**
pull_request:
branches:
- master
env:
JAVA_VERSION: '21.0.3+9.0.LTS'
JAVA_DISTRIBUTION: 'temurin'
TEST_SCREEN_WIDTH: '1920'
TEST_SCREEN_HEIGHT: '1080'
jobs:
Build-and-Test-Windows:
runs-on: windows-latest
name: Build and Test (Windows)
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Verify Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Build
run: ./gradlew --info --stacktrace build -x test
- name: Test setup
run: |
choco install -y change-screen-resolution
changescreenresolution $TEST_SCREEN_WIDTH $TEST_SCREEN_HEIGHT
- name: Test
id: test
run: ./gradlew --info --stacktrace test
- name: Upload failed test screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-test-screenshots-windows
path: build/test-screenshots
- name: Publish coverage report
uses: codecov/codecov-action@v4
env:
OS: Windows
with:
fail_ci_if_error: true
directory: build/reports/
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS
- name: Jpackage
run: ./gradlew --info --stacktrace jpackage
- name: Upload installer (exe)
uses: actions/upload-artifact@v4
with:
name: boundingboxeditor-installer-windows-exe
path: build/jpackage/*.exe
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: boundingboxeditor-portable-windows
path: build/jpackage/BoundingBoxEditor
- name: Stop Gradle daemons
run: ./gradlew --stop
Build-and-Test-Linux:
runs-on: ubuntu-latest
name: Build and Test (Linux)
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Verify Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java
- name: Build
run: ./gradlew --info --stacktrace build -x test
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
- name: Test setup
run: |
sudo apt-get install xvfb fluxbox
Xvfb :10 -screen 0 ${TEST_SCREEN_WIDTH}x${TEST_SCREEN_HEIGHT}x24 &
fluxbox -display :10 &
- name: Test
id: test
run: DISPLAY=:10 ./gradlew --stacktrace --info test
- name: Upload failed test screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-test-screenshots-linux
path: build/test-screenshots
- name: Publish coverage report
uses: codecov/codecov-action@v4
env:
OS: Linux
with:
fail_ci_if_error: true
directory: build/reports/
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS
- name: Jpackage
run: ./gradlew --info --stacktrace jpackage
- name: Upload installer (deb)
uses: actions/upload-artifact@v4
with:
name: boundingboxeditor-installer-linux-deb
path: build/jpackage/*.deb
- name: Upload installer (rpm)
uses: actions/upload-artifact@v4
with:
name: boundingboxeditor-installer-linux-rpm
path: build/jpackage/*.rpm
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: boundingboxeditor-portable-linux
path: build/jpackage/BoundingBoxEditor
Build-and-Test-macOS:
runs-on: macos-latest
name: Build and Test (macOS)
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: gradle
- name: Verify Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Build
run: ./gradlew --info --stacktrace build -x test
- name: Test
id: test
run: ./gradlew --info --stacktrace test
- name: Publish coverage report
uses: codecov/codecov-action@v4
env:
OS: macOS
with:
fail_ci_if_error: true
directory: build/reports/
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS
- name: Jpackage
run: ./gradlew --info --stacktrace jpackage
- name: Upload installer (dmg)
uses: actions/upload-artifact@v4
with:
name: boundingboxeditor-installer-macos-dmg
path: build/jpackage/*.dmg
- name: Upload image
uses: actions/upload-artifact@v4
with:
name: boundingboxeditor-portable-macos
path: build/jpackage/BoundingBoxEditor.app
Release:
needs: [Build-and-Test-Windows, Build-and-Test-Linux, Build-and-Test-macOS]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
name: Github Release
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create changelog
id: changelog
run: |
body_text="$(git log --no-merges --pretty=format:"* %H %s" $(git describe --tags --abbrev=0 @^)..@)"
num_lines="$(echo "$body_text" | wc -l)"
if [ "$num_lines" -gt "10" ]
then
body_text="$(echo "$body_text" | sed '10a<details><summary><b>See More</b></summary>\n')"
body_text="$(echo "$body_text" | sed '$a\\n</details>')"
fi
body_text="$(echo "$body_text" | sed '1i## Changes:\n')"
body_text="${body_text//'%'/'%25'}"
body_text="${body_text//$'\n'/'%0A'}"
body_text="${body_text//$'\r'/'%0D'}"
echo "::set-output name=body::$body_text"
- name: Download all build artifacts
uses: actions/download-artifact@v4
- name: Prepare artifacts
run: |
sudo apt-get install rename
mv boundingboxeditor-installer-*/* .
find "$PWD"/* -maxdepth 0 -type f -name "BoundingBoxEditor*" -exec basename {} ";" | rename -f 'y/A-Z/a-z/'
for image_dir in $(find "$PWD"/* -maxdepth 0 -type d -name "boundingboxeditor-portable-*")
do
cd $image_dir
zip -r $image_dir *
done
- name: Release to github
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.changelog.outputs.body }}
files: |
boundingboxeditor*.exe
boundingboxeditor*.deb
boundingboxeditor*.rpm
boundingboxeditor*.dmg
boundingboxeditor-portable-*.zip