Skip to content

Commit b3dad99

Browse files
committed
fix: move branch matrix into build-branches workflow
Reusable workflow jobs cannot combine strategy with uses; build all MC branches inside build-branches.yml instead. Narrow Dev Builds path filters so release workflow edits no longer run on ordinary pushes.
1 parent 56b6e74 commit b3dad99

3 files changed

Lines changed: 102 additions & 23 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: build-branches
2+
on:
3+
workflow_call:
4+
inputs:
5+
release:
6+
type: boolean
7+
required: false
8+
default: false
9+
tag:
10+
type: string
11+
required: false
12+
branch_matrix:
13+
type: string
14+
required: true
15+
description: JSON matrix object with include entries (branch, java, build_task)
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
continue-on-error: true
21+
strategy:
22+
fail-fast: false
23+
matrix: ${{ fromJson(inputs.branch_matrix) }}
24+
25+
steps:
26+
- name: Check out branch
27+
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ matrix.branch }}
30+
31+
- name: Set up JDK
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: ${{ matrix.java }}
35+
distribution: 'temurin'
36+
37+
- name: Cache gradle files
38+
uses: actions/cache@v4
39+
with:
40+
path: |
41+
~/.gradle/caches
42+
~/.gradle/wrapper
43+
./.gradle/loom-cache
44+
key: ${{ runner.os }}-gradle-${{ matrix.branch }}-${{ hashFiles('*.gradle', 'gradle.properties', '**/*.accesswidener') }}
45+
restore-keys: |
46+
${{ runner.os }}-gradle-${{ matrix.branch }}-
47+
${{ runner.os }}-gradle-
48+
49+
- name: Grant execute permission
50+
run: chmod +x gradlew
51+
52+
- name: Build with Gradle
53+
run: ./gradlew ${{ matrix.build_task }} --no-daemon
54+
env:
55+
BUILD_TAG: ${{ inputs.tag }}
56+
BUILD_ID: ${{ github.run_number }}
57+
BUILD_RELEASE: ${{ inputs.release }}
58+
59+
- name: Upload JAR file
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: build-artifacts-${{ matrix.branch }}
63+
path: |
64+
./*/build/libs/
65+
!./*/build/libs/*shadow*.jar
66+
!./*/build/libs/*source*.jar
67+
!./common/build/libs/
68+
!./cli/build/libs/
69+
70+
summary:
71+
runs-on: ubuntu-22.04
72+
needs:
73+
- build
74+
if: ${{ always() }}
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Download build artifacts
79+
continue-on-error: true
80+
uses: actions/download-artifact@v4
81+
with:
82+
pattern: build-artifacts-*
83+
path: build-artifacts
84+
merge-multiple: true
85+
86+
- name: Make build summary
87+
run: python3 .github/workflows/scripts/summary.py

.github/workflows/gradle.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ on:
66
- "*.gradle"
77
- "gradle.properties"
88
- "*/src/**"
9-
- ".github/**"
9+
- ".github/workflows/build.yml"
10+
- ".github/workflows/gradle.yml"
11+
- ".github/workflows/scripts/**"
1012

1113
pull_request:
1214
paths:
1315
- "*.gradle"
1416
- "gradle.properties"
1517
- "*/src/**"
16-
- ".github/**"
18+
- ".github/workflows/build.yml"
19+
- ".github/workflows/gradle.yml"
20+
- ".github/workflows/scripts/**"
1721

1822

1923
jobs:

.github/workflows/release.yml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Release
2+
13
on:
24
workflow_dispatch:
35
inputs:
@@ -45,7 +47,7 @@ jobs:
4547
run: |
4648
if [ $GITHUB_EVENT_NAME == 'release' ]
4749
then
48-
echo "tag_name=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT # leave an empty value here so softprops/action-gh-release will use the default value
50+
echo "tag_name=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
4951
elif [ $GITHUB_EVENT_NAME == 'workflow_dispatch' ]
5052
then
5153
echo "tag_name=${{ github.event.inputs.target_release_tag }}" >> $GITHUB_OUTPUT
@@ -62,37 +64,23 @@ jobs:
6264
needs:
6365
- generate_release_info
6466
- branch_matrix_prep
65-
strategy:
66-
fail-fast: false
67-
matrix: ${{ fromJson(needs.branch_matrix_prep.outputs.branch_matrix) }}
68-
continue-on-error: true
69-
uses: ./.github/workflows/build.yml
67+
uses: ./.github/workflows/build-branches.yml
7068
with:
7169
release: true
7270
tag: ${{ needs.generate_release_info.outputs.tag_name }}
73-
ref: ${{ matrix.branch }}
74-
java_version: ${{ matrix.java }}
75-
build_task: ${{ matrix.build_task }}
76-
artifact_name: build-artifacts-${{ matrix.branch }}
71+
branch_matrix: ${{ needs.branch_matrix_prep.outputs.branch_matrix }}
7772

7873
build_alpha:
7974
if: ${{ !((github.event_name == 'release' && !github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) }}
8075
needs:
8176
- generate_release_info
8277
- branch_matrix_prep
83-
strategy:
84-
fail-fast: false
85-
matrix: ${{ fromJson(needs.branch_matrix_prep.outputs.branch_matrix) }}
86-
continue-on-error: true
87-
uses: ./.github/workflows/build.yml
78+
uses: ./.github/workflows/build-branches.yml
8879
with:
8980
tag: ${{ needs.generate_release_info.outputs.tag_name }}
90-
ref: ${{ matrix.branch }}
91-
java_version: ${{ matrix.java }}
92-
build_task: ${{ matrix.build_task }}
93-
artifact_name: build-artifacts-${{ matrix.branch }}
81+
branch_matrix: ${{ needs.branch_matrix_prep.outputs.branch_matrix }}
9482

95-
release:
83+
publish_release:
9684
if: ${{ always() && ((github.event_name == 'release' && !github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) && (needs.build_release.result == 'success' || needs.build_release.result == 'failure') }}
9785
needs:
9886
- branch_matrix_prep
@@ -110,7 +98,7 @@ jobs:
11098
permissions:
11199
contents: write
112100

113-
release_alpha:
101+
publish_alpha:
114102
if: ${{ always() && !((github.event_name == 'release' && !github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.event.inputs.release == 'true')) && (needs.build_alpha.result == 'success' || needs.build_alpha.result == 'failure') }}
115103
needs:
116104
- branch_matrix_prep

0 commit comments

Comments
 (0)