From 16b29ff42766ee61d62e17d77f9495ad5c0380c1 Mon Sep 17 00:00:00 2001 From: Mari023 <38946771+Mari023@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:56:37 +0200 Subject: [PATCH] use gradle action instead of doing it manually --- .github/workflows/build.yml | 54 +++++++++-------------------------- .github/workflows/publish.yml | 13 ++++----- 2 files changed, 20 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4074537c..f1b38dd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,3 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - name: build neoforge on: push: @@ -14,33 +11,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: adopt java-version: 21 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Use gradle cache for faster builds - uses: actions/cache@v4 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. - # Restoring these files from a GitHub Actions cache might cause problems for future builds. - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties - - name: Setup Gradle Wrapper Cache - uses: actions/cache@v4 - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + - name: Build with Gradle - run: ./gradlew build + run: gradle assemble env: HASH: $(git rev-parse --short "$GITHUB_SHA") + - name: Upload a Build Artifact uses: actions/upload-artifact@v4 with: @@ -50,28 +35,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: adopt java-version: 21 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Use gradle cache for faster builds - uses: actions/cache@v4 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. - # Restoring these files from a GitHub Actions cache might cause problems for future builds. - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties - - name: Setup Gradle Wrapper Cache - uses: actions/cache@v4 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + cache-read-only: true + - name: format - run: ./gradlew spotlessCheck + run: gradle spotlessCheck diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5e95157f..55f0378a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,3 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - name: publish to modrinth and curseforge on: @@ -19,11 +16,13 @@ jobs: distribution: adopt java-version: 21 - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: true - name: Build with Gradle - run: ./gradlew build + run: gradle build env: TAG: ${{ github.event.release.tag_name }} @@ -34,7 +33,7 @@ jobs: name: neoforge retention-days: 2 - publish_neoforge: + publish: runs-on: ubuntu-latest needs: build steps: