Skip to content

Commit d0796c9

Browse files
authored
refactor: GitHub Actions build workflow
1 parent a21b122 commit d0796c9

1 file changed

Lines changed: 18 additions & 59 deletions

File tree

.github/workflows/build.yml

Lines changed: 18 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,58 @@
1-
name: Build with Gradle
1+
name: Build
22

33
on:
44
push:
5+
branches: [main, master, develop] # ignore noise from short-lived feature branches
56
pull_request:
67
workflow_dispatch:
78

9+
# Cancel any in-progress run on the same branch/PR when a new one is triggered.
10+
# This prevents redundant builds piling up while you're actively pushing.
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
815
env:
9-
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true # opt into Node.js 24 ahead of the June 2026 forced migration
16+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true # opt into Node.js 24 ahead of June 2026 forced migration
1017

1118
jobs:
1219
build:
1320
runs-on: ubuntu-latest
14-
outputs:
15-
jars: ${{ steps.collect.outputs.jars }} # JSON array of filenames (basenames)
1621
permissions:
1722
contents: read
23+
1824
steps:
1925
- name: Checkout
2026
uses: actions/checkout@v4
2127

22-
- name: Set up JDK
28+
- name: Set up JDK 21
2329
uses: actions/setup-java@v4
2430
with:
2531
distribution: temurin
2632
java-version: '21'
2733

2834
- name: Set up Gradle
29-
uses: gradle/actions/setup-gradle@v4 # v4 supports Node.js 24
35+
uses: gradle/actions/setup-gradle@v4
3036

3137
- name: Build
32-
run: ./gradlew --no-daemon shadowJar # gradlew is already executable after checkout
38+
run: |
39+
chmod +x ./gradlew
40+
./gradlew --no-daemon shadowJar
3341
34-
- name: Collect runtime JARs (flatten)
42+
- name: Collect JARs
3543
run: |
3644
mkdir -p jars
37-
# collect jars from all subprojects; exclude sources/javadoc/tests/plain
3845
find . -path "*/build/libs/*.jar" -type f \
3946
! -name "*-sources.jar" \
4047
! -name "*-javadoc.jar" \
4148
! -name "*-tests.jar" \
4249
! -name "*-plain.jar" \
4350
-exec cp {} jars/ \;
4451
45-
- name: Make list of JAR filenames (JSON)
46-
id: collect
47-
shell: bash
48-
run: |
49-
files=()
50-
while IFS= read -r -d '' f; do
51-
files+=("$(basename "$f")")
52-
done < <(find jars -type f -name "*.jar" -print0 | sort -z)
53-
54-
if [ ${#files[@]} -eq 0 ]; then
55-
json='[]'
56-
else
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
63-
fi
64-
65-
echo "jars=$json" >> "$GITHUB_OUTPUT"
66-
67-
- name: Upload temporary combined artifact
68-
if: steps.collect.outputs.jars != '[]'
52+
- name: Upload JARs
6953
uses: actions/upload-artifact@v4
7054
with:
71-
name: all-jars
55+
name: jars-${{ github.sha }} # include commit SHA so each run's artifact is uniquely identifiable
7256
path: jars/*.jar
7357
if-no-files-found: error
74-
retention-days: 1 # only needed as a staging area for upload-each; no need to keep it longer
75-
76-
upload-each:
77-
needs: build
78-
if: needs.build.outputs.jars != '[]'
79-
runs-on: ubuntu-latest
80-
permissions:
81-
contents: read
82-
strategy:
83-
fail-fast: false
84-
matrix:
85-
jar: ${{ fromJSON(needs.build.outputs.jars) }}
86-
steps:
87-
- name: Download combined artifact
88-
uses: actions/download-artifact@v4
89-
with:
90-
name: all-jars
91-
path: jars
92-
93-
- name: Upload ${{ matrix.jar }} as its own artifact
94-
uses: actions/upload-artifact@v4
95-
with:
96-
name: ${{ matrix.jar }}
97-
path: jars/${{ matrix.jar }}
98-
if-no-files-found: error
9958
retention-days: 14

0 commit comments

Comments
 (0)