mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-26 01:32:02 -07:00
[ci skip] Publish PR API and dev bundles (#12672)
* Setup PR publishing also remove the JDK matrix, it's pointless with one value and other parts of the workflow depend on a single value... * Use PaperMC action * Change base PR maven url * Update action * Update action * Update action * Update action * Update action * Re-enable javadoc...? * Delete PR comment workflow * Rename publish tag * comment broken jd link * update bot name
This commit is contained in:
23
.github/workflows/build.yml
vendored
23
.github/workflows/build.yml
vendored
@@ -19,18 +19,16 @@ jobs:
|
||||
# The goal of the build workflow is split into multiple requirements.
|
||||
# 1. Run on pushes to same repo.
|
||||
# 2. Run on PR open/reopen/syncs from repos that are not the same (PRs from the same repo are covered by 1)
|
||||
# 3. Run on labeled PRs that have the build-pr-jar flag.
|
||||
# 3. Run on labeled PRs that have the publish-pr flag.
|
||||
if: >
|
||||
(
|
||||
(github.event_name == 'push')
|
||||
|| (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name && contains(fromJSON('["opened", "reopened", "synchronize"]'), github.event.action))
|
||||
|| (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'build-pr-jar')
|
||||
|| (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'publish-pr')
|
||||
)
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [21]
|
||||
fail-fast: true
|
||||
steps:
|
||||
- if: ${{ github.event_name == 'push' }}
|
||||
@@ -43,10 +41,10 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: JDK ${{ matrix.java }}
|
||||
- name: JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
java-version: 21
|
||||
distribution: 'zulu'
|
||||
|
||||
- name: Setup Gradle
|
||||
@@ -73,14 +71,14 @@ jobs:
|
||||
|
||||
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"));
|
||||
const pull = pulls.find((pr) => !!pr.labels.find((l) => l.name === "publish-pr"));
|
||||
if (pull) {
|
||||
result["pr"] = pull.number;
|
||||
result["action"] = "paperclip";
|
||||
core.notice(`This is a push action but to a branch with an open PR with the build paperclip label (${JSON.stringify(result)})`);
|
||||
return result;
|
||||
}
|
||||
} else if (event_name === "pull_request" && event.pull_request.labels.find((l) => l.name === "build-pr-jar")) {
|
||||
} else if (event_name === "pull_request" && event.pull_request.labels.find((l) => l.name === "publish-pr")) {
|
||||
result["pr"] = event.pull_request.number;
|
||||
result["action"] = "paperclip";
|
||||
core.notice(`This is a pull request action with a build paperclip label (${JSON.stringify(result)})`);
|
||||
@@ -102,7 +100,7 @@ jobs:
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Test Results (${{ matrix.java }})
|
||||
name: Test Results
|
||||
path: |
|
||||
**/build/test-results/test/TEST-*.xml
|
||||
|
||||
@@ -116,6 +114,13 @@ jobs:
|
||||
with:
|
||||
name: paper-${{ fromJSON(steps.determine.outputs.result).pr }}
|
||||
path: paper-server/build/libs/paper-paperclip-*-mojmap.jar
|
||||
|
||||
- name: Publish Artifacts
|
||||
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
|
||||
uses: PaperMC/action-pr-publishing/upload@paper
|
||||
with:
|
||||
# TODO fallback for failing javadoc
|
||||
publishing-task: ":paper-api:publishAllPublicationsTo_githubPackages_PRsRepository publishDevBundlePublicationTo_githubPackages_PRsRepository -PpublishDevBundle"
|
||||
event_file:
|
||||
name: "Event File"
|
||||
# Only run on PRs if the source branch is on someone else's repo
|
||||
|
84
.github/workflows/pr_comment.yml
vendored
84
.github/workflows/pr_comment.yml
vendored
@@ -1,84 +0,0 @@
|
||||
# This workflow run on the completion of the
|
||||
# build workflow but only does anything if the
|
||||
# triggering workflow uploaded an artifact.
|
||||
#
|
||||
# Do note that it is then the trigger workflow that
|
||||
# determines if this will update the PR text body. All
|
||||
# this workflow does is check if an uploaded artifact
|
||||
# exists and there is a PR tied to the previous workflow.
|
||||
|
||||
name: Comment on pull request
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ['Build Paper']
|
||||
types: [completed]
|
||||
jobs:
|
||||
pr_comment:
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v7
|
||||
env:
|
||||
BRANCH_NAME: "${{ github.event.workflow_run.head_branch }}"
|
||||
PR_OWNER: "${{ github.event.workflow_run.head_repository.owner.login }}"
|
||||
PR_SHA: "${{ github.event.workflow_run.head_sha }}"
|
||||
RUN_ID: "${{ github.event.workflow_run.id }}"
|
||||
REPO_ID: "${{ github.event.repository.id }}"
|
||||
EVENT_TYPE: "${{ github.event.workflow_run.event}}"
|
||||
PULL_REQUESTS: "${{ toJSON(github.event.workflow_run.pull_requests) }}"
|
||||
with:
|
||||
# This snippet is public-domain, taken from
|
||||
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
|
||||
# Modified extensively by Machine_Maker
|
||||
script: |
|
||||
async function updatePR(owner, repo, issue_number, purpose, body) {
|
||||
const { data } = await github.rest.issues.get({ owner, repo, issue_number });
|
||||
core.debug(JSON.stringify(data, null, 2));
|
||||
|
||||
const marker = `<!-- bot: ${purpose} -->`;
|
||||
|
||||
let new_body = data.body ? data.body.trim().split(marker)[0].trim() : "";
|
||||
new_body += `\n${marker}\n---\n${body}`;
|
||||
|
||||
core.info(`Updating the text body of PR #${issue_number} in ${owner}/${repo}`);
|
||||
await github.rest.issues.update({ owner, repo, issue_number, body: new_body });
|
||||
}
|
||||
|
||||
const { owner, repo } = context.repo;
|
||||
const run_id = `${process.env.RUN_ID}`;
|
||||
const repo_id = `${process.env.REPO_ID}`;
|
||||
|
||||
let pulls = [];
|
||||
const event_type = `${process.env.EVENT_TYPE}`;
|
||||
if (event_type === "push") { // if push, it's from the same repo which means `pull_requests` is populated
|
||||
pulls = JSON.parse(`${process.env.PULL_REQUESTS}`);
|
||||
} else {
|
||||
const pr_branch = `${process.env.BRANCH_NAME}`;
|
||||
const pr_sha = `${process.env.PR_SHA}`;
|
||||
const pr_owner = `${process.env.PR_OWNER}`;
|
||||
const { data } = await github.rest.pulls.list({ owner, repo, head: `${pr_owner}:${pr_branch}`, state: "open" });
|
||||
core.debug(JSON.stringify(data, null, 2));
|
||||
pulls = data.filter((pr) => pr.head.sha === pr_sha && pr.labels.find((l) => l.name === "build-pr-jar"));
|
||||
}
|
||||
|
||||
if (!pulls.length) {
|
||||
return core.notice("This workflow doesn't have any pull requests!");
|
||||
} else if (pulls.length > 1) {
|
||||
core.info(JSON.stringify(pulls, null, 2));
|
||||
return core.error("Found multiple matching PRs");
|
||||
}
|
||||
const pull_request = pulls[0];
|
||||
|
||||
const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, { owner, repo, run_id });
|
||||
if (!artifacts.length) {
|
||||
return core.info("Skipping comment due to no artifact found");
|
||||
}
|
||||
const artifact = artifacts.find((art) => art.name === `paper-${pull_request.number}`);
|
||||
if (!artifact) {
|
||||
return core.info("Skipping comment to no matching artifact found");
|
||||
}
|
||||
|
||||
const link = `https://nightly.link/${owner}/${repo}/actions/artifacts/${artifact.id}.zip`;
|
||||
const body = `Download the paperclip jar for this pull request: [${artifact.name}.zip](${link})`;
|
||||
core.info(`Adding a link to ${link}`);
|
||||
await updatePR(owner, repo, pull_request.number, "paperclip-pr-build", body);
|
36
.github/workflows/publish_pr.yml
vendored
Normal file
36
.github/workflows/publish_pr.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Publish PR
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [ "Build Paper" ]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
packages: write # To upload the PR
|
||||
actions: write # To get information about the uploading workflow run and to delete the run artifacts
|
||||
contents: write # To download the `maven-publish` artifact, and to be able to create commit comments
|
||||
issues: write # To be able to create PR comments
|
||||
pull-requests: write # To be able to create PR comments
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Generate an Application repository access token
|
||||
id: gen_repo_token
|
||||
uses: kattecon/gh-app-access-token-gen@v1
|
||||
with:
|
||||
app_id: 1408328
|
||||
private_key: ${{ secrets.PR_PUBLISHING_GH_APP_KEY }}
|
||||
repository: ${{ github.repository }}
|
||||
- name: Publish PR
|
||||
uses: PaperMC/action-pr-publishing@paper
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.gen_repo_token.outputs.token }}
|
||||
with:
|
||||
publishing-token: ${{ github.token }}
|
||||
uploader-workflow-name: Build Paper
|
||||
artifacts-base-path: io/papermc/paper
|
||||
base-maven-url: 'https://maven-prs.papermc.io'
|
||||
self-name: 'papermc-pr-publishing[bot]'
|
7
.github/workflows/test_results.yml
vendored
7
.github/workflows/test_results.yml
vendored
@@ -21,12 +21,13 @@ jobs:
|
||||
uses: dawidd6/action-download-artifact@v6
|
||||
with:
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
path: artifacts
|
||||
path: test_artifacts
|
||||
name: Test Results
|
||||
- name: Publish Test Results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||
with:
|
||||
commit: ${{ github.event.workflow_run.head_sha }}
|
||||
event_file: artifacts/Event File/event.json
|
||||
event_file: test_artifacts/Event File/event.json
|
||||
event_name: ${{ github.event.workflow_run.event }}
|
||||
files: "artifacts/**/*.xml"
|
||||
files: "test_artifacts/**/*.xml"
|
||||
comment_mode: off
|
||||
|
@@ -184,7 +184,7 @@ tasks.withType<Javadoc> {
|
||||
"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
|
||||
"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
|
||||
"https://javadoc.io/doc/org.slf4j/slf4j-api/$slf4jVersion/",
|
||||
"https://logging.apache.org/log4j/2.x/javadoc/log4j-api/",
|
||||
// "https://logging.apache.org/log4j/2.x/javadoc/log4j-api/", // TODO: Broken
|
||||
"https://javadoc.io/doc/org.apache.maven.resolver/maven-resolver-api/1.7.3",
|
||||
)
|
||||
options.tags("apiNote:a:API Note:")
|
||||
|
Reference in New Issue
Block a user