generated from Fallen-Breath/fabric-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 13
114 lines (101 loc) · 3.19 KB
/
build.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
name: _step.build
on:
workflow_call:
inputs:
release:
type: boolean
required: false
default: false
target_subproject:
description: see release.yml, leave it empty to build all
type: string
required: false
default: ''
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Cache gradle files
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
./.gradle/loom-cache
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle.properties', '**/*.accesswidener', 'settings.json') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with gradle
run: |
chmod +x gradlew
if [ -z "${{ inputs.target_subproject }}" ]; then
echo "Building all subprojects"
./gradlew build
else
args=$(echo "${{ inputs.target_subproject }}" | tr ',' '\n' | sed 's/$/:build/' | paste -sd ' ')
echo "Building with arguments=$args"
./gradlew $args
fi
env:
BUILD_ID: ${{ github.run_number }}
BUILD_RELEASE: ${{ inputs.release }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: versions/*/build/libs/
- name: Collect mod jars
run: |
shopt -s extglob
mkdir mod-jars
for jar in versions/*/build/libs/!(*-@(dev|sources|shadow)).jar; do
cp -p "$jar" mod-jars/
done
ls -l mod-jars
# This is the artifact recommended for users to download
- name: Upload mod jars
uses: actions/upload-artifact@v4
with:
name: mod-jars
path: mod-jars/*.jar
- name: Publish with gradle
if: inputs.release || github.ref == 'refs/heads/dev'
run: |
if [ -z "${{ inputs.target_subproject }}" ]; then
echo "Publishing all subprojects"
./gradlew publish
else
args=$(echo "${{ inputs.target_subproject }}" | tr ',' '\n' | sed 's/$/:publish/' | paste -sd ' ')
echo "Publishing with arguments=$args"
./gradlew $args
fi
env:
BUILD_ID: ${{ github.run_number }}
BUILD_RELEASE: ${{ inputs.release }}
FALLENS_MAVEN_TOKEN: ${{ secrets.FALLENS_MAVEN_TOKEN }}
summary:
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: build-artifacts
- name: Make build summary
run: |
pip install jproperties
python .github/workflows/scripts/summary.py
env:
TARGET_SUBPROJECT: ${{ inputs.target_subproject }}