Skip to content

Commit 4480afc

Browse files
Initial Commit
0 parents  commit 4480afc

28 files changed

Lines changed: 1313 additions & 0 deletions

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# These are explicitly windows files and should use crlf
5+
*.bat text eol=crlf
6+

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gradle"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
reviewers:
8+
- "Gamebuster19901"
9+
assignees:
10+
- "Gamebuster19901"
11+
labels:
12+
- "Category - Enhancement"
13+
- "Priority - Normal ↓"
14+
open-pull-requests-limit: 98
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Rebuild Approved PR
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
rebuild_approved_pr:
9+
runs-on: ubuntu-latest
10+
if: >
11+
github.event.comment.user.login == 'Gamebuster19901' &&
12+
github.event.comment.body == '@WilderForge rebuild' &&
13+
github.event.issue.pull_request != null
14+
steps:
15+
- name: Fetch Approval Workflow Run
16+
id: fetch_approval_run
17+
run: |
18+
# Fetch the pull request details
19+
PR_URL=$(jq -r '.pull_request.url' <<< '${{ toJson(github.event.issue) }}')
20+
echo "PR URL: $PR_URL"
21+
22+
PR_DETAILS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "$PR_URL")
23+
# echo "PR Details: $PR_DETAILS" # Debugging: output PR details to see its contents
24+
25+
PR_NUMBER=$(echo "$PR_DETAILS" | jq -r '.number')
26+
echo "PR Number: $PR_NUMBER" # Debugging: output the PR number
27+
28+
# Get the commit SHA directly from the pull request head object
29+
PR_SHA=$(echo "$PR_DETAILS" | jq -r '.head.sha')
30+
echo "PR SHA: $PR_SHA" # Debugging: output the PR SHA
31+
32+
if [ -z "$PR_SHA" ]; then
33+
echo "Pull request head commit SHA is null. Exiting."
34+
exit 1
35+
fi
36+
37+
# Get the list of workflow runs for the repository
38+
WORKFLOWS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
39+
"https://api.github.com/repos/${{ github.repository }}/actions/runs")
40+
# echo "Workflow Runs: $WORKFLOWS" # Debugging: output workflow runs data
41+
42+
# Find the latest completed run of the 'Validate Approval' workflow that matches the head SHA
43+
APPROVAL_RUN=$(echo "$WORKFLOWS" | jq -r \
44+
'.workflow_runs[] | select(.name == "Validate Approval" and .head_sha == "'$PR_SHA'" and .status == "completed") | .id' | head -n 1)
45+
echo "Approval Run: $APPROVAL_RUN" # Debugging: output the approval run ID
46+
47+
if [ -z "$APPROVAL_RUN" ]; then
48+
echo "The head of this PR has not been validated. Exiting."
49+
exit 1
50+
fi
51+
52+
# Save the approval run ID to environment variable for use in later steps
53+
echo "APPROVAL_RUN=$APPROVAL_RUN" >> $GITHUB_ENV
54+
55+
- name: Check Approval
56+
id: check_approval_status
57+
run: |
58+
# Fetch the details of the approval workflow run using the saved APPROVAL_RUN ID
59+
APPROVAL_STATUS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
60+
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ env.APPROVAL_RUN }}")
61+
62+
CONCLUSION=$(echo "$APPROVAL_STATUS" | jq -r '.conclusion')
63+
STATUS=$(echo "$APPROVAL_STATUS" | jq -r '.status')
64+
65+
echo "Approval Workflow Status: $STATUS" # Debugging: output the workflow status
66+
echo "Approval Workflow Conclusion: $CONCLUSION" # Debugging: output the workflow conclusion
67+
68+
if [[ "$CONCLUSION" != "success" || "$STATUS" != "completed" ]]; then
69+
echo "The head of this PR has not been validated. Exiting."
70+
exit 1
71+
fi
72+
73+
echo "The head of this PR has been validated."
74+
75+
- name: Trigger Build Commit Workflow
76+
if: success()
77+
run: |
78+
# Get the source branch of the PR (from the pull_request object)
79+
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
80+
81+
# Define the API endpoint for dispatching the workflow
82+
WORKFLOW_URL="https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
83+
84+
# Trigger the workflow for the branch of the pull request
85+
echo "Triggering workflow for branch: $PR_BRANCH"
86+
RESPONSE=$(curl -s -w "%{http_code}" -o response.json -X POST \
87+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
88+
-d '{"ref": "refs/heads/'${PR_BRANCH}'", "inputs": {"sha": "${{ github.event.review.commit_id }}"}}' \
89+
"$WORKFLOW_URL")
90+
91+
# Check if the HTTP status code is 2xx (successful)
92+
if [[ "$RESPONSE" -lt 200 || "$RESPONSE" -ge 300 ]]; then
93+
echo "Error triggering the workflow: HTTP $RESPONSE"
94+
cat response.json
95+
exit 1
96+
else
97+
echo "Successfully triggered the workflow."
98+
fi
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Validate Approval
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
jobs:
8+
approve_and_run:
9+
runs-on: ubuntu-latest
10+
if: |
11+
(
12+
github.event.review.state == 'approved' &&
13+
github.event.review.user.login == 'Gamebuster19901'
14+
) ||
15+
(
16+
(
17+
github.event.pull_request != null &&
18+
github.event.sender.login == 'Gamebuster19901' &&
19+
github.event.pull_request.user.login == 'Gamebuster19901'
20+
) &&
21+
(
22+
startsWith(github.event.review.body, 'approved') ||
23+
startsWith(github.event.review.body, 'reject')
24+
)
25+
)
26+
steps:
27+
- name: Checking Approval
28+
id: "checking_approval"
29+
run: |
30+
DESC="null"
31+
if [[ "${{ github.event.review.state }}" == "approved" || "${{ github.event.review.body }}" == approved* ]]; then
32+
DESC="${{ github.event.review.user.login }} APPROVED build for ${{ github.event.review.commit_id }}"
33+
echo $DESC
34+
echo "conclusion=success" >> "$GITHUB_ENV"
35+
echo "description=$DESC" >> "$GITHUB_ENV"
36+
exit 0
37+
elif [[ "${{ github.event.review.body }}" == reject* ]]; then
38+
DESC="${{ github.event.review.user.login }} REJECTED build for ${{ github.event.review.commit_id }}"
39+
echo $DESC
40+
echo "conclusion=failure" >> "$GITHUB_ENV"
41+
echo "description=$DESC" >> "$GITHUB_ENV"
42+
exit 1
43+
else
44+
DESC="Assertion Error: Review body expected start with 'approved' or 'reject'. This step should have been skipped but it ran anyway!"
45+
echo $DESC
46+
echo "conclusion=failure" >> "$GITHUB_ENV"
47+
echo "description=$DESC" >> "$GITHUB_ENV"
48+
exit 1
49+
fi
50+
51+
- name: Post Status Check
52+
if:
53+
always()
54+
run: |
55+
echo "${{ env.approved_sha }}"
56+
57+
STATUS="${{ env.conclusion }}"
58+
DESCRIPTION="${{ env.description }}"
59+
60+
CONTEXT="Approval Validation"
61+
APPROVED_SHA="${{ github.event.review.commit_id }}"
62+
63+
TARGET_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
64+
65+
# Post the status using GitHub API
66+
curl -s -X POST \
67+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
68+
-H "Content-Type: application/json" \
69+
-d "{
70+
\"state\": \"$STATUS\",
71+
\"description\": \"$DESCRIPTION\",
72+
\"context\": \"Approval Validation\",
73+
\"target_url\": \"$TARGET_URL\"
74+
}" \
75+
"https://api.github.com/repos/${{ github.repository }}/statuses/$APPROVED_SHA"
76+
77+
- name: Trigger Build Commit Workflow
78+
if: success()
79+
run: |
80+
# Get the source branch of the PR (from the pull_request object)
81+
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
82+
83+
# Define the API endpoint for dispatching the workflow
84+
WORKFLOW_URL="https://api.github.com/repos/${{ github.repository }}/actions/workflows/build.yml/dispatches"
85+
86+
# Trigger the workflow for the branch of the pull request
87+
echo "Triggering workflow for branch: $PR_BRANCH"
88+
RESPONSE=$(curl -s -w "%{http_code}" -o response.json -X POST \
89+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
90+
-d '{"ref": "refs/heads/'${PR_BRANCH}'", "inputs": {"sha": "${{ github.event.review.commit_id }}"}}' \
91+
"$WORKFLOW_URL")
92+
93+
# Check if the HTTP status code is 2xx (successful)
94+
if [[ "$RESPONSE" -lt 200 || "$RESPONSE" -ge 300 ]]; then
95+
echo "Error triggering the workflow: HTTP $RESPONSE"
96+
cat response.json
97+
exit 1
98+
else
99+
echo "Successfully triggered the workflow."
100+
fi

.github/workflows/build.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build Specific Commit
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
sha:
7+
description: 'The commit SHA to checkout and build'
8+
required: true
9+
publish:
10+
description: 'Whether to publish after building'
11+
required: false
12+
push:
13+
branches:
14+
- master
15+
16+
jobs:
17+
build_commit:
18+
runs-on: [self-hosted, linux]
19+
20+
steps:
21+
- name: Determine Commit SHA
22+
id: determine_sha
23+
run: |
24+
if [ -z "${{ github.event.inputs.sha }}" ]; then
25+
echo "COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
26+
else
27+
echo "COMMIT_SHA=${{ github.event.inputs.sha }}" >> $GITHUB_ENV
28+
fi
29+
30+
- name: Set Commit Status to Pending
31+
run: |
32+
STATUS="pending"
33+
DESCRIPTION="Build in progress for commit ${{ env.COMMIT_SHA }}"
34+
TARGET_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
35+
36+
curl -s -X POST \
37+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
38+
-H "Content-Type: application/json" \
39+
-d "{
40+
\"state\": \"$STATUS\",
41+
\"description\": \"$DESCRIPTION\",
42+
\"context\": \"Build Status\",
43+
\"target_url\": \"$TARGET_URL\"
44+
}" \
45+
"https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }}"
46+
47+
- name: Checkout the repository at SHA
48+
uses: actions/checkout@v3
49+
with:
50+
ref: ${{ env.COMMIT_SHA }}
51+
52+
- name: Set up JDK 17
53+
uses: actions/setup-java@v4.5.0
54+
with:
55+
java-version: '17'
56+
distribution: 'adopt'
57+
58+
- name: Setup Gradle
59+
uses: gradle/actions/setup-gradle@v4
60+
61+
- name: Clear Game Files
62+
run: ./gradlew clearLocalRuntime
63+
64+
- name: Setup Decompiled Workspace
65+
run: ./gradlew setupDecompWorkspace
66+
67+
- name: Build With Gradle
68+
run: ./gradlew build
69+
70+
- name: Publish Build
71+
if: ${{ github.event.inputs.publish == 'true' }}
72+
run: |
73+
echo "Publishing build..."
74+
./gradlew publish -PmavenRepoUrl=${{ secrets.MAVEN_REPO }}
75+
76+
- name: Post Build Status
77+
if: always()
78+
run: |
79+
STATUS="success"
80+
DESCRIPTION="Build successful"
81+
82+
if [ ${{ job.status }} != "success" ]; then
83+
STATUS="failure"
84+
DESCRIPTION="Build failed"
85+
fi
86+
87+
TARGET_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
88+
89+
curl -s -X POST \
90+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
91+
-H "Content-Type: application/json" \
92+
-d "{
93+
\"state\": \"$STATUS\",
94+
\"description\": \"$DESCRIPTION\",
95+
\"context\": \"Build Status\",
96+
\"target_url\": \"$TARGET_URL\"
97+
}" \
98+
"https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.COMMIT_SHA }}"

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# eclipse
2+
bin
3+
*.launch
4+
.metadata
5+
.classpath
6+
.project
7+
.settings
8+
9+
# idea
10+
out
11+
*.ipr
12+
*.iws
13+
*.iml
14+
.idea
15+
16+
# gradle
17+
build
18+
.gradle
19+
20+
#JVM
21+
hs_err_pid*.log
22+
23+
# secrets
24+
**.secret
25+
26+
#ModLauncher
27+
logs/*
28+
29+
#WilderForge
30+
crashes/*
31+
32+
#WilderWorkspace
33+
libs/
34+
providerSettings.json
35+
36+
#Logs
37+
*.log

LICENSE.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
MIT No Attribution
2+
3+
Copyright 2025 Gamebuster
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+
software and associated documentation files (the "Software"), to deal in the Software
7+
without restriction, including without limitation the rights to use, copy, modify,
8+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)