2020-10-28 22:01:09 +01:00
|
|
|
# Here lie dragons!
|
|
|
|
#
|
2022-11-23 20:19:31 +01:00
|
|
|
# This action either builds the server or
|
|
|
|
# builds a paperclip jar to be updated in the body
|
|
|
|
# of the PR relating to this action.
|
2020-10-28 22:01:09 +01:00
|
|
|
|
|
|
|
name: Build Paper
|
2022-11-23 20:19:31 +01:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- opened
|
|
|
|
- reopened
|
|
|
|
- synchronize
|
|
|
|
- labeled
|
2020-10-28 22:01:09 +01:00
|
|
|
|
|
|
|
jobs:
|
2022-11-23 20:19:31 +01:00
|
|
|
build:
|
2022-11-24 04:14:41 +01:00
|
|
|
# Run on all label events (won't be duplicated) or all push events or on PR syncs not from the same repo
|
|
|
|
if: (github.event_name == 'pull_request' && github.event.action == 'labeled') || github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name
|
2022-11-23 20:19:31 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
java: [17]
|
|
|
|
fail-fast: true
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: JDK ${{ matrix.java }}
|
2023-07-11 23:25:02 +02:00
|
|
|
uses: actions/setup-java@v3.11.0
|
2022-11-23 20:19:31 +01:00
|
|
|
with:
|
|
|
|
java-version: ${{ matrix.java }}
|
|
|
|
distribution: 'temurin'
|
2023-07-11 23:25:02 +02:00
|
|
|
|
|
|
|
- name: Validate Gradle wrapper
|
|
|
|
uses: gradle/wrapper-validation-action@v1
|
2022-11-23 20:19:31 +01:00
|
|
|
- name: Setup Gradle
|
|
|
|
uses: gradle/gradle-build-action@v2
|
|
|
|
|
|
|
|
- name: Configure Build
|
|
|
|
uses: actions/github-script@v6
|
|
|
|
id: determine
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const {owner, repo} = context.repo;
|
|
|
|
const event_name = "${{ github.event_name }}";
|
|
|
|
const event = ${{ toJSON(github.event) }};
|
|
|
|
const ref_type = "${{ github.ref_type }}";
|
|
|
|
const ref_name = "${{ github.ref_name }}";
|
|
|
|
const result = {
|
|
|
|
action: "build"
|
|
|
|
};
|
|
|
|
|
|
|
|
if (event_name === "push" && ref_type === "branch") {
|
|
|
|
const {data: pulls} = await github.rest.pulls.list({ owner, repo, head: `${owner}:${ref_name}`, state: "open" });
|
|
|
|
const pull = pulls.find((pr) => !!pr.labels.find((l) => l.name === "build-pr-jar"));
|
|
|
|
if (pull) {
|
|
|
|
result["pr"] = pull.number;
|
|
|
|
result["action"] = "paperclip";
|
2022-11-30 21:45:27 +01:00
|
|
|
core.notice(`This is a push action but to a branch with an open PR with the build paperclip label (${JSON.stringify(result)})`);
|
2022-11-23 20:19:31 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
} else if (event_name === "pull_request" && event.pull_request.labels.find((l) => l.name === "build-pr-jar")) {
|
|
|
|
result["pr"] = event.pull_request.number;
|
|
|
|
result["action"] = "paperclip";
|
2022-11-30 21:45:27 +01:00
|
|
|
core.notice(`This is a pull request action with a build paperclip label (${JSON.stringify(result)})`);
|
2022-11-23 20:19:31 +01:00
|
|
|
return result;
|
|
|
|
}
|
2022-11-30 21:45:27 +01:00
|
|
|
core.notice("This will not build a paperclip jar");
|
2022-11-23 20:19:31 +01:00
|
|
|
return result;
|
|
|
|
|
|
|
|
- name: Apply Patches
|
|
|
|
run: |
|
|
|
|
git config --global user.email "no-reply@github.com"
|
|
|
|
git config --global user.name "Github Actions"
|
|
|
|
./gradlew applyPatches --stacktrace
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: ./gradlew build --stacktrace
|
|
|
|
|
|
|
|
- name: Create Paperclip Jar
|
|
|
|
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
|
|
|
|
run: ./gradlew createReobfPaperclipJar --stacktrace
|
|
|
|
|
|
|
|
- name: Upload Paperclip Jar
|
|
|
|
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: paper-${{ fromJSON(steps.determine.outputs.result).pr }}
|
|
|
|
path: build/libs/paper-paperclip-*-reobf.jar
|