Skip to content

Commit

Permalink
Setup Gradle as a composite action (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
turikhay authored Nov 12, 2024
1 parent ab4f1b6 commit b0cd568
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
19 changes: 19 additions & 0 deletions .github/actions/setup_gradle/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Setup Gradle

inputs:
dependency-graph:
required: false
default: generate-and-upload

runs:
using: composite
steps:
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
dependency-graph: ${{ inputs.dependency-graph }}
15 changes: 9 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Gradle build

on:
workflow_call:
Expand All @@ -11,6 +11,9 @@ on:
task:
type: string
default: build
dependency-graph:
type: string
default: generate-and-upload
outputs:
artifact:
description: Path to the jar artifact
Expand All @@ -27,7 +30,7 @@ permissions:

jobs:
build:
name: Gradle build
name: Run Gradle
env:
ARTIFACT: packages/single/build/libs/MapModCompanion.jar
outputs:
Expand All @@ -36,16 +39,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: ./.github/actions/setup_gradle
with:
dependency-graph: generate-and-submit
dependency-graph: ${{ inputs.dependency-graph }}
- name: Determine target Spigot version
id: target
run: |
TARGET=${{ inputs.spigot-target }}
[[ -z "$TARGET" ]] && TARGET=$(tail -n1 VERSIONS.txt)
echo "spigot-version=$TARGET" >> $GITHUB_OUTPUT
- name: Run the build
- name: Run the task
run: |
./gradlew \
${{ inputs.task }} \
Expand All @@ -55,7 +58,7 @@ jobs:
env:
HANGAR_TOKEN: ${{ secrets.hangar-token }}
MODRINTH_TOKEN: ${{ secrets.modrinth-token }}
- name: Force original path preservation (for upload-artifact@v3)
- name: Force original path preservation
run: touch .empty
- uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ jobs:
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.prepare.outputs.version }}
dependency-graph: generate-and-submit
4 changes: 1 addition & 3 deletions .github/workflows/update-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: ./.github/actions/setup_gradle
- name: Run tasks
run: |
./gradlew \
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/update-versions-cf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: ./.github/actions/setup_gradle
- name: Run tasks
run: |
./gradlew \
Expand Down

0 comments on commit b0cd568

Please sign in to comment.