Skip to content

Commit a21b122

Browse files
authored
Enhance build.yml for Node.js 24 and JAR handling
Updated build workflow to support Node.js 24 and optimized JAR collection.
1 parent 39c8972 commit a21b122

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

.github/workflows/build.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ on:
55
pull_request:
66
workflow_dispatch:
77

8+
env:
9+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true # opt into Node.js 24 ahead of the June 2026 forced migration
10+
811
jobs:
912
build:
1013
runs-on: ubuntu-latest
1114
outputs:
1215
jars: ${{ steps.collect.outputs.jars }} # JSON array of filenames (basenames)
16+
permissions:
17+
contents: read
1318
steps:
1419
- name: Checkout
1520
uses: actions/checkout@v4
@@ -21,12 +26,10 @@ jobs:
2126
java-version: '21'
2227

2328
- name: Set up Gradle
24-
uses: gradle/actions/setup-gradle@v3
29+
uses: gradle/actions/setup-gradle@v4 # v4 supports Node.js 24
2530

2631
- name: Build
27-
run: |
28-
chmod +x ./gradlew
29-
./gradlew --no-daemon shadowJar
32+
run: ./gradlew --no-daemon shadowJar # gradlew is already executable after checkout
3033

3134
- name: Collect runtime JARs (flatten)
3235
run: |
@@ -46,12 +49,17 @@ jobs:
4649
files=()
4750
while IFS= read -r -d '' f; do
4851
files+=("$(basename "$f")")
49-
done < <(find jars -type f -name "*.jar" -print0)
52+
done < <(find jars -type f -name "*.jar" -print0 | sort -z)
5053
5154
if [ ${#files[@]} -eq 0 ]; then
5255
json='[]'
5356
else
54-
printf -v json '[%s]' "$(printf '"%s",' "${files[@]}" | sed 's/,$//')"
57+
# Use jq if available for safe JSON construction, otherwise fall back to printf
58+
if command -v jq &>/dev/null; then
59+
json=$(printf '%s\n' "${files[@]}" | jq -R . | jq -sc .)
60+
else
61+
printf -v json '[%s]' "$(printf '"%s",' "${files[@]}" | sed 's/,$//')"
62+
fi
5563
fi
5664
5765
echo "jars=$json" >> "$GITHUB_OUTPUT"
@@ -63,12 +71,14 @@ jobs:
6371
name: all-jars
6472
path: jars/*.jar
6573
if-no-files-found: error
66-
retention-days: 14
74+
retention-days: 1 # only needed as a staging area for upload-each; no need to keep it longer
6775

6876
upload-each:
6977
needs: build
7078
if: needs.build.outputs.jars != '[]'
7179
runs-on: ubuntu-latest
80+
permissions:
81+
contents: read
7282
strategy:
7383
fail-fast: false
7484
matrix:
@@ -80,7 +90,7 @@ jobs:
8090
name: all-jars
8191
path: jars
8292

83-
- name: Upload this JAR as its own artifact
93+
- name: Upload ${{ matrix.jar }} as its own artifact
8494
uses: actions/upload-artifact@v4
8595
with:
8696
name: ${{ matrix.jar }}

0 commit comments

Comments
 (0)