From 5bc17d0bd6f1e83f58ef9d6b45e9f0e6fc9ac123 Mon Sep 17 00:00:00 2001 From: user111192 <3538995003@qq.com> Date: Sat, 14 Sep 2024 17:40:45 +0800 Subject: [PATCH 1/5] Update build.yml --- .github/workflows/build.yml | 99 +++++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04283e2..e9c07dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,94 @@ -name: build -on: [pull_request, push] +name: Java CI with Gradle + +on: + push: + pull_request: + workflow_dispatch: + +permissions: + contents: read jobs: build: + strategy: matrix: minecraft: [1.16.5, 1.17.1, 1.18.2, 1.19.2, 1.19.4, 1.20.1, 1.20.4] runs-on: ubuntu-latest + permissions: + contents: read + steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - name: Make Gradle wrapper executable - run: chmod +x ./gradlew - - name: Setup Forge files - run: ./gradlew forge:setupFiles -Pminecraft_version="${{ matrix.minecraft }}" - - name: Build with Gradle - run: | + - name: Checkout Repo + uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2 + + - name: Make Gradle wrapper executable + run: chmod +x gradlew + + - name: Setup Forge files + run: ./gradlew forge:setupFiles -Pminecraft_version="${{ matrix.minecraft }}" + + - name: Build with Gradle Wrapper + run: | NOW=$(date '+%Y-%m-%d-%H.%M') ./gradlew build -Pminecraft_version="${{ matrix.minecraft }}" -Partifact_date=".artifact_$NOW" + + # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). + # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. + # + # - name: Setup Gradle + # uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2 + # with: + # gradle-version: '8.5' + # + # - name: Build with Gradle 8.5 + # run: gradle build + - name: Delete temp files + run: exit 0 + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.2 + with: + # Artifact name + name: Mod File + # A file, directory or wildcard pattern that describes what to upload + path: build/libs + # The desired behavior if no files are found using the provided path. + if-no-files-found: error + - name: Upload a Build Artifact (Resources) + uses: actions/upload-artifact@v3.1.2 + with: + # Artifact name + name: Resource File + # A file, directory or wildcard pattern that describes what to upload + path: build/resources + # The desired behavior if no files are found using the provided path. + if-no-files-found: warn + + dependency-submission: + + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. + # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2 From c761620101fe1db4b49ace7c365c0890da2d0fc2 Mon Sep 17 00:00:00 2001 From: user111192 <3538995003@qq.com> Date: Sat, 14 Sep 2024 17:50:22 +0800 Subject: [PATCH 2/5] Update build.yml --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e9c07dc..ef2a603 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,11 +61,12 @@ jobs: # Artifact name name: Mod File # A file, directory or wildcard pattern that describes what to upload - path: build/libs + path: build # The desired behavior if no files are found using the provided path. if-no-files-found: error - name: Upload a Build Artifact (Resources) - uses: actions/upload-artifact@v3.1.2 + if: false + uses: actions/upload-artifact@v3.2.1-node20 with: # Artifact name name: Resource File From 4a97704f3c40a3ccc34322cf9aff5e67c9203f95 Mon Sep 17 00:00:00 2001 From: user111192 <3538995003@qq.com> Date: Sat, 14 Sep 2024 17:54:57 +0800 Subject: [PATCH 3/5] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef2a603..9effbca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: - name: Delete temp files run: exit 0 - name: Upload a Build Artifact - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v3.2.1-node20 with: # Artifact name name: Mod File From 9c33f0f9b0d8b4496b9d5d41d8f389488b3fb1fa Mon Sep 17 00:00:00 2001 From: user111192 <3538995003@qq.com> Date: Sat, 14 Sep 2024 18:01:53 +0800 Subject: [PATCH 4/5] Update build.yml Add version display --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9effbca..c630299 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,7 +59,7 @@ jobs: uses: actions/upload-artifact@v3.2.1-node20 with: # Artifact name - name: Mod File + name: Mod File (${{ matrix.minecraft }}) # A file, directory or wildcard pattern that describes what to upload path: build # The desired behavior if no files are found using the provided path. @@ -69,7 +69,7 @@ jobs: uses: actions/upload-artifact@v3.2.1-node20 with: # Artifact name - name: Resource File + name: Resource File (${{ matrix.minecraft }}) # A file, directory or wildcard pattern that describes what to upload path: build/resources # The desired behavior if no files are found using the provided path. From 6b522c93717f7bf4a58565a6f8e212e7b86c23fe Mon Sep 17 00:00:00 2001 From: user111192 <3538995003@qq.com> Date: Sat, 14 Sep 2024 18:48:33 +0800 Subject: [PATCH 5/5] ci: use upload-artifact v4 --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c630299..6718c97 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: - name: Delete temp files run: exit 0 - name: Upload a Build Artifact - uses: actions/upload-artifact@v3.2.1-node20 + uses: actions/upload-artifact@v4 with: # Artifact name name: Mod File (${{ matrix.minecraft }}) @@ -66,7 +66,7 @@ jobs: if-no-files-found: error - name: Upload a Build Artifact (Resources) if: false - uses: actions/upload-artifact@v3.2.1-node20 + uses: actions/upload-artifact@v4 with: # Artifact name name: Resource File (${{ matrix.minecraft }})