From a5a4f5c3eaa633ac6a1b2b569084602ee2a72958 Mon Sep 17 00:00:00 2001 From: Kas-tle <26531652+Kas-tle@users.noreply.github.com> Date: Tue, 7 Mar 2023 18:59:21 -0800 Subject: [PATCH] Properly Cache Build Dependencies, Optimize Build Action, and Save Build Action Artifacts (#3593) * Attempt cache gradle properly * Save artifacts on standard build * Dont build on bad path and standardize pr action * Don't do caching for PR builds * Correct exclusion paths * Allow manual trigger of build action --- .github/workflows/build.yml | 70 +++++++++++++++++++++++++++++-- .github/workflows/pullrequest.yml | 31 ++++++++++---- 2 files changed, 90 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f83b9a901..2d1c84670 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,18 @@ name: Build -on: [push] +on: + workflow_dispatch: + push: + paths-ignore: + - '.github/ISSUE_TEMPLATE/*.yml' + - '.github/actions/pullrequest.yml' + - '.idea/copyright/*.xml' + - '.gitignore' + - 'CONTRIBUTING.md' + - 'LICENSE' + - 'Jenkinsfile ' + - 'README.md' + - 'licenseheader.txt' jobs: build: @@ -15,12 +27,64 @@ jobs: with: java-version: 17 distribution: temurin - cache: gradle + + - name: Cache Gradle Packages + uses: actions/cache@v3 + with: + path: | + ~/.m2 + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ github.ref_name }}-gradle-${{ hashFiles('*.gradle.kts', 'gradle.properties', 'gradlew', 'gradle/*', 'gradle/**/*', 'build-logic/*', 'build-logic/**/**/**/*', '**/*.gradle.kts', '**/**/*.gradle.kts') }} + restore-keys: ${{ github.ref_name }}-gradle- - name: Build uses: gradle/gradle-build-action@v2 with: - arguments: build + arguments: build --no-daemon + + - name: Archive artifacts (Geyser Fabric) + uses: actions/upload-artifact@v3 + if: success() + with: + name: Geyser Fabric + path: bootstrap/fabric/build/libs/Geyser-Fabric.jar + if-no-files-found: error + - name: Archive artifacts (Geyser Standalone) + uses: actions/upload-artifact@v3 + if: success() + with: + name: Geyser Standalone + path: bootstrap/standalone/build/libs/Geyser-Standalone.jar + if-no-files-found: error + - name: Archive artifacts (Geyser Spigot) + uses: actions/upload-artifact@v3 + if: success() + with: + name: Geyser Spigot + path: bootstrap/spigot/build/libs/Geyser-Spigot.jar + if-no-files-found: error + - name: Archive artifacts (Geyser BungeeCord) + uses: actions/upload-artifact@v3 + if: success() + with: + name: Geyser BungeeCord + path: bootstrap/bungeecord/build/libs/Geyser-BungeeCord.jar + if-no-files-found: error + - name: Archive artifacts (Geyser Sponge) + uses: actions/upload-artifact@v3 + if: success() + with: + name: Geyser Sponge + path: bootstrap/sponge/build/libs/Geyser-Sponge.jar + if-no-files-found: error + - name: Archive artifacts (Geyser Velocity) + uses: actions/upload-artifact@v3 + if: success() + with: + name: Geyser Velocity + path: bootstrap/velocity/build/libs/Geyser-Velocity.jar + if-no-files-found: error - name: Publish to Maven Repository if: ${{ job.status == 'success' && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }} diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 8d5f5c03c..9567fb414 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -1,6 +1,16 @@ name: Build Pull Request -on: [pull_request] +on: + pull_request: + paths-ignore: + - '.github/ISSUE_TEMPLATE/*.yml' + - '.idea/copyright/*.xml' + - '.gitignore' + - 'CONTRIBUTING.md' + - 'LICENSE' + - 'Jenkinsfile ' + - 'README.md' + - 'licenseheader.txt' jobs: build: @@ -11,7 +21,6 @@ jobs: with: java-version: 17 distribution: temurin - cache: gradle - name: Check if the author has forked the API repo uses: Kas-tle/ForkFinder@v1.0.1 @@ -44,38 +53,44 @@ jobs: build-root-directory: geyser - name: Archive artifacts (Geyser Fabric) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: success() with: name: Geyser Fabric path: geyser/bootstrap/fabric/build/libs/Geyser-Fabric.jar + if-no-files-found: error - name: Archive artifacts (Geyser Standalone) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: success() with: name: Geyser Standalone path: geyser/bootstrap/standalone/build/libs/Geyser-Standalone.jar + if-no-files-found: error - name: Archive artifacts (Geyser Spigot) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: success() with: name: Geyser Spigot path: geyser/bootstrap/spigot/build/libs/Geyser-Spigot.jar + if-no-files-found: error - name: Archive artifacts (Geyser BungeeCord) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: success() with: name: Geyser BungeeCord path: geyser/bootstrap/bungeecord/build/libs/Geyser-BungeeCord.jar + if-no-files-found: error - name: Archive artifacts (Geyser Sponge) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: success() with: name: Geyser Sponge path: geyser/bootstrap/sponge/build/libs/Geyser-Sponge.jar + if-no-files-found: error - name: Archive artifacts (Geyser Velocity) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: success() with: name: Geyser Velocity path: geyser/bootstrap/velocity/build/libs/Geyser-Velocity.jar + if-no-files-found: error