Skip to content

Commit 7cb40a7

Browse files
authored
featre: New notification system and folia support (#178)
2 parents ba33dc7 + 10b181d commit 7cb40a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1908
-576
lines changed

.github/workflows/build-pr.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: Build PR
22
on: [pull_request]
3+
permissions:
4+
contents: write
5+
checks: write
6+
issues: write
7+
pull-requests: write
38
jobs:
49
build_pr:
510
if: github.repository_owner == 'OneLiteFeatherNET'
@@ -41,4 +46,56 @@ jobs:
4146
if: always() && matrix.os == 'ubuntu-latest'
4247
with:
4348
name: coverage-report
44-
path: build/reports/jacoco/test/
49+
path: build/reports/jacoco/test/
50+
upload_jar_and_comment:
51+
name: Upload JAR and comment PR
52+
permissions:
53+
contents: write
54+
pull-requests: write
55+
runs-on: ubuntu-latest
56+
needs: build_pr
57+
if: contains(github.event.pull_request.labels.*.name, 'publish-pr')
58+
steps:
59+
- name: Checkout Repository
60+
uses: actions/checkout@v5
61+
- name: Setup Java
62+
uses: actions/setup-java@v5
63+
with:
64+
distribution: temurin
65+
java-version: 24
66+
- name: Setup Gradle
67+
uses: gradle/actions/setup-gradle@v4
68+
- name: Build
69+
run: ./gradlew clean build test
70+
- name: Upload JAR for PR
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: pr-jar
74+
path: build/libs/*.jar
75+
- name: Get JAR Artifact Download URL
76+
id: get-artifact-url
77+
uses: actions/github-script@v7
78+
with:
79+
script: |
80+
const runId = context.runId;
81+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
run_id: runId
85+
});
86+
const jarArtifact = artifacts.data.artifacts.find(a => a.name === 'pr-jar');
87+
if (!jarArtifact) throw new Error('pr-jar artifact not found');
88+
const url = jarArtifact.archive_download_url;
89+
core.setOutput('jar_url', url);
90+
- name: Create or Update PR Comment with direct JAR download link
91+
uses: peter-evans/create-or-update-comment@v4
92+
with:
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
issue-number: ${{ github.event.pull_request.number }}
95+
body: |
96+
:package: A new JAR build is available!
97+
[Download the JAR directly](${{ steps.get-artifact-url.outputs.jar_url }})
98+
99+
Note: The download link is valid for a limited time and requires GitHub authentication.
100+
edit-mode: replace
101+
comment-id: pr-jar-artifact-link
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: PR Label Listener
2+
permissions:
3+
issues: write
4+
actions: write
5+
pull-requests: write
6+
on:
7+
pull_request:
8+
types: [labeled, unlabeled]
9+
jobs:
10+
handle_label:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check for publish-pr label event
14+
uses: actions/github-script@v7
15+
with:
16+
script: |
17+
const label = context.payload.label?.name;
18+
const prNumber = context.payload.pull_request?.number;
19+
if (label === 'publish-pr' && context.payload.action === 'labeled') {
20+
github.rest.issues.createComment({
21+
...context.repo,
22+
issue_number: prNumber,
23+
body: ':label: The `publish-pr` label was added. The JAR will be attached on next build.'
24+
});
25+
}
26+
if (label === 'publish-pr' && context.payload.action === 'unlabeled') {
27+
// Find workflow runs for this PR
28+
const runs = await github.rest.actions.listWorkflowRunsForRepo({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
event: 'pull_request',
32+
branch: context.payload.pull_request.head.ref
33+
});
34+
// Find latest run for this PR
35+
const run = runs.data.workflow_runs.find(r => r.head_branch === context.payload.pull_request.head.ref && r.status === 'completed');
36+
if (run) {
37+
// List artifacts for the run
38+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
run_id: run.id
42+
});
43+
const jarArtifact = artifacts.data.artifacts.find(a => a.name === 'pr-jar');
44+
if (jarArtifact) {
45+
await github.rest.actions.deleteArtifact({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
artifact_id: jarArtifact.id
49+
});
50+
github.rest.issues.createComment({
51+
...context.repo,
52+
issue_number: prNumber,
53+
body: ':wastebasket: The `publish-pr` label was removed. The JAR artifact has been deleted.'
54+
});
55+
} else {
56+
github.rest.issues.createComment({
57+
...context.repo,
58+
issue_number: prNumber,
59+
body: ':warning: The `publish-pr` label was removed, but no JAR artifact was found to delete.'
60+
});
61+
}
62+
} else {
63+
github.rest.issues.createComment({
64+
...context.repo,
65+
issue_number: prNumber,
66+
body: ':warning: The `publish-pr` label was removed, but no completed workflow run was found.'
67+
});
68+
}
69+
}
70+

.github/workflows/sematic-releases.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ name: Release
55
- main
66
- next
77
- beta
8+
- alpha
89
- "*.x"
910

1011
permissions:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build/
1515
out/
1616
!**/src/main/**/out/
1717
!**/src/test/**/out/
18+
.idea/*
1819

1920
### Eclipse ###
2021
.apt_generated

.idea/.gitignore

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copilot.data.migration.agent.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copilot.data.migration.ask.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copilot.data.migration.ask2agent.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copilot.data.migration.edit.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)