forked from 1312Delta/imgui-java-relocator
-
Notifications
You must be signed in to change notification settings - Fork 0
333 lines (289 loc) · 11.1 KB
/
release.yml
File metadata and controls
333 lines (289 loc) · 11.1 KB
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
name: Build & Publish
on:
# Trigger manually or on upstream tag detection via schedule
workflow_dispatch:
inputs:
upstream_tag:
description: 'Upstream imgui-java tag to build (e.g. v1.90.0)'
required: false
type: string
# Poll upstream for new tags daily
# schedule:
# - cron: '0 6 * * *'
permissions:
contents: write
env:
ZIG_VERSION: '0.15.2'
JAVA_VERSION: '21'
jobs:
# ─── Check for new upstream release ─────────────────────────────────────────
check-release:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.resolve.outputs.tag }}
should_build: ${{ steps.resolve.outputs.should_build }}
steps:
- uses: actions/checkout@v4
- name: Load config
id: config
run: |
source config.env
echo "upstream_repo=$UPSTREAM_REPO" >> "$GITHUB_OUTPUT"
echo "upstream_tag=$UPSTREAM_TAG" >> "$GITHUB_OUTPUT"
- name: Resolve tag
id: resolve
env:
INPUT_TAG: ${{ inputs.upstream_tag }}
CONFIG_TAG: ${{ steps.config.outputs.upstream_tag }}
UPSTREAM_REPO: ${{ steps.config.outputs.upstream_repo }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -n "$INPUT_TAG" ]; then
TAG="$INPUT_TAG"
else
# Fetch latest release tag from upstream
TAG=$(git ls-remote --tags --sort=-v:refname "$UPSTREAM_REPO" 'v*' \
| head -1 | sed 's/.*refs\/tags\///' | sed 's/\^{}//')
echo "Latest upstream tag: $TAG"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
# Check if we already built this tag
if gh release view "$TAG" --json tagName >/dev/null 2>&1; then
echo "Release $TAG already exists, skipping."
echo "should_build=false" >> "$GITHUB_OUTPUT"
else
echo "should_build=true" >> "$GITHUB_OUTPUT"
fi
# ─── Relocate + generate JNI sources ────────────────────────────────────────
relocate:
needs: check-release
if: needs.check-release.outputs.should_build == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: Override upstream tag
run: |
TAG="${{ needs.check-release.outputs.tag }}"
sed -i "s/^UPSTREAM_TAG=.*/UPSTREAM_TAG=\"$TAG\"/" config.env
- name: Run relocate
run: ./scripts/relocate.sh
- name: Run verify
run: ./scripts/verify.sh
- name: Upload work directory
uses: actions/upload-artifact@v4
with:
name: relocated-sources
retention-days: 1
path: |
work/imgui-java/
!work/imgui-java/.git/
# ─── Cross-compile natives ──────────────────────────────────────────────────
build-natives:
needs: [check-release, relocate]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-linux-gnu
artifact: linux-x86_64
- target: x86_64-windows-gnu
artifact: windows-x86_64
- target: x86_64-macos
artifact: macos-x86_64
- target: aarch64-macos
artifact: macos-aarch64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- uses: mlugg/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
- name: Download relocated sources
uses: actions/download-artifact@v4
with:
name: relocated-sources
path: work/imgui-java/
- name: Load config
id: config
run: |
source config.env
echo "lib_name=$LIB_NAME" >> "$GITHUB_OUTPUT"
- name: Build native (${{ matrix.target }})
run: |
zig build \
--release=fast \
-Dtarget=${{ matrix.target }} \
-Dlib-name=${{ steps.config.outputs.lib_name }} \
-Djni-dir=work/imgui-java/imgui-binding/build/jni
- name: Upload native artifact
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.artifact }}
retention-days: 1
path: |
zig-out/lib/*
zig-out/bin/*.dll
# ─── Package JARs + publish to Maven ────────────────────────────────────────
publish:
needs: [check-release, relocate, build-natives]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: Download relocated sources
uses: actions/download-artifact@v4
with:
name: relocated-sources
path: work/imgui-java/
# Download all native artifacts and flatten into bin/
- name: Download natives
uses: actions/download-artifact@v4
with:
pattern: native-*
merge-multiple: true
path: work/imgui-java/natives-tmp/
- name: Flatten natives into bin/
run: |
mkdir -p work/imgui-java/bin
find work/imgui-java/natives-tmp -type f \( -name '*.so' -o -name '*.dll' -o -name '*.dylib' \) \
-exec cp {} work/imgui-java/bin/ \;
rm -rf work/imgui-java/natives-tmp
ls -la work/imgui-java/bin/
- name: Load config
id: config
run: |
source config.env
echo "lib_name=$LIB_NAME" >> "$GITHUB_OUTPUT"
echo "artifact_prefix=$ARTIFACT_PREFIX" >> "$GITHUB_OUTPUT"
echo "maven_group=$MAVEN_GROUP" >> "$GITHUB_OUTPUT"
- name: Verify native libs present
run: |
LIB_NAME="${{ steps.config.outputs.lib_name }}"
for f in "lib${LIB_NAME}.so" "${LIB_NAME}.dll" "lib${LIB_NAME}.dylib"; do
if [ ! -f "work/imgui-java/bin/$f" ]; then
echo "ERROR: Missing $f"
exit 1
fi
echo "OK: $f ($(stat --printf='%s' "work/imgui-java/bin/$f") bytes)"
done
# Report glibc version requirements (informational, not blocking)
- name: Check glibc versions
run: |
LIB_NAME="${{ steps.config.outputs.lib_name }}"
echo "glibc version requirements:"
objdump -T "work/imgui-java/bin/lib${LIB_NAME}.so" \
| grep -oP 'GLIBC_\d+\.\d+(\.\d+)?' | sort -V | uniq -c | sort -rn
# Restore execute permission lost during artifact upload/download
- name: Fix gradlew permissions
run: chmod +x work/imgui-java/gradlew
- name: Verify Maven credentials
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
run: |
if [ -z "$MAVEN_URL" ]; then echo "ERROR: MAVEN_URL secret not set"; exit 1; fi
if [ -z "$MAVEN_USER" ]; then echo "ERROR: MAVEN_USER secret not set"; exit 1; fi
if [ -z "$MAVEN_TOKEN" ]; then echo "ERROR: MAVEN_TOKEN secret not set"; exit 1; fi
echo "All Maven secrets are set"
# Build all JARs
- name: Build JARs
working-directory: work/imgui-java
run: ./gradlew build -x test -x :example:compileJava
# Run unit tests
- name: Run tests
working-directory: work/imgui-java
run: ./gradlew imgui-binding:test
# Publish binding, lwjgl3, app JARs
- name: Publish to Maven
working-directory: work/imgui-java
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
run: |
for module in imgui-binding imgui-lwjgl3 imgui-app; do
echo "Publishing $module..."
./gradlew :$module:publishImguiPublicationToCustomRepository
done
# Publish per-platform natives JARs
- name: Publish native JARs
working-directory: work/imgui-java
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
run: |
for platform in linux windows macos; do
echo "Publishing natives for $platform..."
./gradlew :imgui-binding-natives:publishImguiPublicationToCustomRepository \
-PdeployType=$platform
done
# ─── Create GitHub release ──────────────────────────────────────────────────
github-release:
needs: [check-release, publish]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Load config
id: config
run: |
source config.env
echo "lib_name=$LIB_NAME" >> "$GITHUB_OUTPUT"
echo "target_pkg=$TARGET_PKG" >> "$GITHUB_OUTPUT"
echo "artifact_prefix=$ARTIFACT_PREFIX" >> "$GITHUB_OUTPUT"
# Collect native binaries for the release
- name: Download all natives
uses: actions/download-artifact@v4
with:
pattern: native-*
merge-multiple: true
path: natives-tmp/
- name: Flatten natives
run: |
mkdir -p natives
find natives-tmp -type f \( -name '*.so' -o -name '*.dll' -o -name '*.dylib' \) \
-exec cp {} natives/ \;
rm -rf natives-tmp
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.check-release.outputs.tag }}
PKG: ${{ steps.config.outputs.target_pkg }}
PREFIX: ${{ steps.config.outputs.artifact_prefix }}
run: |
VERSION="${TAG#v}"
gh release create "$TAG" \
--title "$PREFIX $VERSION" \
--notes "$(cat <<EOF
Relocated build of [imgui-java $TAG](https://github.com/SpaiR/imgui-java/releases/tag/$TAG).
**Package:** \`$PKG\`
### Maven coordinates
\`\`\`xml
<dependency>
<groupId>com.delta</groupId>
<artifactId>${PREFIX}-binding</artifactId>
<version>${VERSION}</version>
</dependency>
\`\`\`
### Native libraries
| Platform | File |
|----------|------|
| Linux x86_64 | \`lib${{ steps.config.outputs.lib_name }}.so\` |
| Windows x86_64 | \`${{ steps.config.outputs.lib_name }}.dll\` |
| macOS x86_64 | \`lib${{ steps.config.outputs.lib_name }}.dylib\` |
| macOS aarch64 | \`lib${{ steps.config.outputs.lib_name }}.dylib\` |
EOF
)" \
natives/*