-
-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (63 loc) · 2.22 KB
/
gradle.build.yaml
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
# Based off https://github.com/MinecraftForge/SharedActions/blob/main/.github/workflows/gradle.yml
name: Gradle Building CI
on:
workflow_call:
inputs:
java:
description: "The version of Java to use to run Gradle"
required: false
type: string
default: "21"
gradle_tasks:
description: "The Gradle task(s) to run for building"
required: false
type: string
default: "build"
secrets:
GRADLE_ENCRYPTION_KEY:
description: The AES key to enable Gradle cache encryption
required: false
permissions:
contents: read
jobs:
generate-build-information:
name: "Generate build information"
runs-on: ubuntu-latest
outputs:
branch_suffix: ${{ steps.computeBranchSuffix.outputs.branch_suffix }}
steps:
- id: computeBranchSuffix
name: "🔢 Compute branch suffix"
run: |
gitRef="${{ github.ref }}"
branchName=$(echo "${gitRef/refs\/heads\//}")
echo "Branch name: $branchName"
cleanedBranchName=$(echo $branchName | sed 's/[^a-zA-Z0-9]/-/g')
echo "Cleaned branch name: $cleanedBranchName"
echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT"
compute-version:
needs: [ "generate-build-information" ]
uses: ./.github/workflows/gradle.version.yaml
with:
suffix: -${{ needs.generate-build-information.outputs.branch_suffix }}
build:
needs: [ "compute-version" ]
name: "🏗️ Build"
runs-on: ubuntu-latest
steps:
- id: checkout
name: "📦 Checkout"
uses: actions/checkout@v4
- id: setupJava
name: "🔧 Setup Java"
run: |
echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV"
- id: setupGradle
name: "🔧 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- id: build
name: "🏗️ Build"
run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} -PmodVersion=${{ needs.compute-version.outputs.mod_version }} -PmodVersionSuffix=${{ needs.compute_version.outputs.suffix }}