diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6c5431c..3e508e3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -21,6 +21,11 @@ on: required: false default: false type: boolean + disable-spotless-pr: + description: 'Do not run spotless PR task' + required: false + default: false + type: boolean concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -29,6 +34,10 @@ concurrency: jobs: build-and-test: runs-on: ubuntu-24.04 + + outputs: + jar_matrix: ${{ steps.expose-jars.outputs.matrix }} + steps: - name: Install Ubuntu dependencies run: | @@ -84,32 +93,26 @@ jobs: - name: Compile the mod run: ./gradlew --build-cache --info --stacktrace assemble - - name: Attach compilation artifacts - uses: actions/upload-artifact@v5 - with: - name: ${{ github.repository_id }}-build-libs - path: build/libs/ - retention-days: 90 - - name: Run post-build checks id: build_mod run: xvfb-run --server-args="-screen 0 1366x768x24" ./gradlew --build-cache --info --stacktrace build - name: Attach gradle reports if: failure() && steps.build_mod.conclusion == 'failure' - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v7 continue-on-error: true with: name: ${{ github.repository_id }}-reports path: build/reports/ - retention-days: 31 + retention-days: 90 - name: Attempt to make a PR fixing spotless errors if: >- - ${{ failure() && steps.build_mod.conclusion == 'failure' - && github.event_name == 'pull_request' - && !github.event.pull_request.draft - && github.event.pull_request.head.repo.full_name == github.repository }} + ${{ !inputs.disable-spotless-pr && + failure() && steps.build_mod.conclusion == 'failure' && + github.event_name == 'pull_request' && + !github.event.pull_request.draft && + github.event.pull_request.head.repo.full_name == github.repository }} run: | git reset --hard git checkout "${PR_BRANCH}" @@ -172,3 +175,27 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.number }} + + - name: Attach compilation artifacts as ZIP + uses: actions/upload-artifact@v7 + with: + name: ${{ github.repository_id }}-build-libs + path: build/libs/ + retention-days: 90 + + - name: Store the name of each built file + id: expose-jars + run: | + shopt -s nullglob + JAR_JSON=$(jq -n -c '$ARGS.positional' --args build/libs/*.jar) + echo "matrix=$JAR_JSON" >> "$GITHUB_OUTPUT" + + run-individual-uploads: + needs: build-and-test + strategy: + fail-fast: false + matrix: + jar: ${{ fromJson(needs.build-and-test.outputs.jar_matrix) }} + uses: ./.github/workflows/upload-individual-jar.yml + with: + jar_path: ${{ matrix.jar }} diff --git a/.github/workflows/upload-individual-jar.yml b/.github/workflows/upload-individual-jar.yml new file mode 100644 index 0000000..8c657d1 --- /dev/null +++ b/.github/workflows/upload-individual-jar.yml @@ -0,0 +1,28 @@ +name: Upload individual JAR + +on: + workflow_call: + inputs: + jar_path: + required: true + type: string + +jobs: + upload-individual-jar: + runs-on: ubuntu-24.04 + steps: + # In order to run this for all jars, we have to call it individually for each jar, on a separate job. + # Because dynamically running this workflow file requires a unique job run, we can't just grab the jars directly because they're already gone by then. + # We have to do this because unzipped upload can only be ran on one file (arbitrary restrictions 💢) + - name: Extract archive to retrieve artifact + uses: actions/download-artifact@v8 + with: + name: ${{ github.repository_id }}-build-libs + path: build/libs + + - name: Upload individual compilation artifact + uses: actions/upload-artifact@v7 + with: + path: ${{ inputs.jar_path }} + retention-days: 90 + archive: false