From b0cd568cfb607d870a149c118db20a2efccf0e41 Mon Sep 17 00:00:00 2001 From: Artur Khusainov Date: Tue, 12 Nov 2024 10:21:29 +0300 Subject: [PATCH] Setup Gradle as a composite action (#169) --- .github/actions/setup_gradle/action.yml | 19 +++++++++++++++++++ .github/workflows/build.yml | 15 +++++++++------ .github/workflows/nightly.yml | 1 + .github/workflows/update-pages.yml | 4 +--- .github/workflows/update-versions-cf.yml | 4 +--- 5 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 .github/actions/setup_gradle/action.yml diff --git a/.github/actions/setup_gradle/action.yml b/.github/actions/setup_gradle/action.yml new file mode 100644 index 0000000..287a672 --- /dev/null +++ b/.github/actions/setup_gradle/action.yml @@ -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 }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e9d7de..82c18d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: Gradle build on: workflow_call: @@ -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 @@ -27,7 +30,7 @@ permissions: jobs: build: - name: Gradle build + name: Run Gradle env: ARTIFACT: packages/single/build/libs/MapModCompanion.jar outputs: @@ -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 }} \ @@ -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: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7d98113..f68e849 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -28,3 +28,4 @@ jobs: uses: ./.github/workflows/build.yml with: version: ${{ needs.prepare.outputs.version }} + dependency-graph: generate-and-submit diff --git a/.github/workflows/update-pages.yml b/.github/workflows/update-pages.yml index a3bd62c..46fb0c1 100644 --- a/.github/workflows/update-pages.yml +++ b/.github/workflows/update-pages.yml @@ -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 \ diff --git a/.github/workflows/update-versions-cf.yml b/.github/workflows/update-versions-cf.yml index c37e786..9318684 100644 --- a/.github/workflows/update-versions-cf.yml +++ b/.github/workflows/update-versions-cf.yml @@ -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 \