9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-29 20:09:23 +00:00

Enable ci workflow

This commit is contained in:
Lumine1909
2025-07-04 17:25:20 -07:00
parent 4a4b07177b
commit 4d364ef7c5
3 changed files with 0 additions and 0 deletions

100
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,100 @@
name: Leaves CI
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: github.repository == 'LeavesMC/Leaves'
steps:
- name: Get repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "zulu"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
add-job-summary: never
generate-job-summary: false
cache-read-only: false
- name: Setup Git Config
run: |
git config --global user.email "ci@leavesmc.org"
git config --global user.name "LeavesMC CI"
- name: Get Build Number
run: bash scripts/GetBuildNumber.sh
- name: Apply Patches
run: ./gradlew applyAllPatches
- name: Create Leavesclip Jar
run: ./gradlew createMojmapLeavesclipJar
env:
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
- name: Publish to Maven repo
run: |
./gradlew :leaves-api:publish
./gradlew :leaves-server:publishDevBundlePublicationToLeavesRepository -PpublishDevBundle=true
env:
LEAVES_USERNAME: ${{ secrets.NEW_REPO_USERNAME }}
LEAVES_PASSWORD: ${{ secrets.NEW_REPO_PASSWORD }}
- name: Create Configuration
continue-on-error: true
run: ./gradlew createLeavesConfig
- name: Push Configuration
continue-on-error: true
run: |
mkdir --parents "$HOME/.ssh"
ssh-keyscan -H "github.com" > "$HOME/.ssh/known_hosts"
echo "${{ secrets.CONFIG_DEPLOY_KEY }}" > "$HOME/.ssh/deploy.key"
chmod 400 "$HOME/.ssh/deploy.key"
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy.key"
git clone git@github.com:LeavesMC/Configuration.git configuration -b Leaves
cp run/leaves.yml configuration/leaves.yml -f
cd configuration
git add leaves.yml
git commit leaves.yml -m "$(date -u +"%Y-%m-%dT%H:%M:%SZ")
https://github.com/LeavesMC/Leaves/commit/$(cd .. && git rev-parse HEAD)"
git push origin HEAD:Leaves
- name: Get Release Info
run: bash scripts/GetReleaseInfo.sh
env:
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.jar }}
path: ${{ env.jar }}
- name: Create Release
if: "!contains(github.event.commits[0].message, '[release-skip]')"
continue-on-error: true
uses: ncipollo/release-action@v1
with:
artifacts: ${{ env.jar }}
bodyFile: ${{ env.info }}
tag: ${{ env.tag }}
name: ${{ env.name }}
prerelease: ${{ env.pre }}
token: ${{ secrets.GITHUB_TOKEN }}
makeLatest: ${{ env.make_latest }}
- name: Github Releases To Discord
if: "!contains(github.event.commits[0].message, '[release-skip]')"
continue-on-error: true
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
raw-data: ${{ env.discordmes }}
- name: Push to API
if: "!contains(github.event.commits[0].message, '[release-skip]')"
continue-on-error: true
env:
secret: ${{ secrets.API_PUSH_TOKEN }}
secret_v2: ${{ secrets.API_V2_PUSH_TOKEN }}
tag: ${{ env.tag }}
run: sh scripts/PushToAPI.sh

View File

@@ -0,0 +1,107 @@
name: "Issues: Check version"
on:
issues:
types: [opened]
jobs:
check-version:
runs-on: ubuntu-latest
if: ${{ !github.event.issue.pull_request }}
steps:
- name: Check version
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
if (
issue.labels.some((label) => label.name === "status: needs triage") &&
issue.state === "open"
) {
const { createComment, addLabels, update } = github.rest.issues;
const { owner, repo } = context.repo;
const issueNumber = context.issue.number;
const body = issue.body;
if (
body.includes("### 服务端版本 Leaves Version")
) {
const versionMatch = body.match(/(\d+\.\d+\.\d+)-(\d+)/);
const gitVersionMatch = body.match(/git-Leaves-"[a-z0-9]{7}"/);
if (versionMatch) {
const version = versionMatch[1];
const buildId = versionMatch[2];
console.log(`This server is running Leaves ${version} (${buildId}).`);
try {
const response = await fetch(
`https://api.leavesmc.org/v2/projects/leaves/versions/${version}/latestGroupBuildId`
);
const latestBuildId = await response.text();
console.log(
`The latest build id of Leaves ${version} is ${latestBuildId}.`
);
if (buildId === latestBuildId) {
console.log("This server is running the latest Leaves.");
return;
}
console.log("This server is running the old Leaves.");
createComment({
issue_number: issueNumber,
owner,
repo,
body: `## :wave: Hi, The LeavesMC Team here.\n:warning: You're using an outdated Leaves build.\nPlease update to the latest version from [our website](https://leavesmc.org/downloads/leaves) and try reproducing the issue.\n\n---\n## :wave: 嗨,这里是 LeavesMC 团队。\n:warning: 你正在使用旧版 Leaves 构建。\n请从[我们的网站](https://leavesmc.org/downloads/leaves)更新至最新版本并尝试复现此问题。`,
});
addLabels({
issue_number: issueNumber,
owner,
repo,
labels: ["resolution: awaiting response"],
});
} catch (error) {
console.error("Failed to fetch API: ", error);
}
return;
} else if (gitVersionMatch) {
console.log("This server is running the unsupported Leaves.");
createComment({
issue_number: issueNumber,
owner,
repo,
body: `## :wave: Hi, The LeavesMC Team here.\n:x: The version you are using is no longer supported, therefore this issue will be closed.\nIt is highly recommended that you upgrade to the latest version to continue to receive updates and support.\n\n---\n## :wave: 嗨,这里是 LeavesMC 团队。\n:x: 你正在使用的版本已不受支持,因此问题将被关闭。\n强烈推荐你升级至最新版本以继续获取更新和支持。`,
});
addLabels({
issue_number: issueNumber,
owner,
repo,
labels: ["resolution: unsupported"],
});
update({
owner,
repo,
issue_number: issueNumber,
state: "closed",
state_reason: "not_planned",
});
return;
} else {
createComment({
issue_number: issueNumber,
owner,
repo,
body: `## :wave: Hi, The LeavesMC Team here.\n:information_source: Please make sure you have filled in the Leaves version correctly. (e.g. \`1.21.4-16\`).\nYou can generate pre-populated issue templates via \`/leaves report\`.\n\n---\n## :wave: 嗨,这里是 LeavesMC 团队。\n:information_source: 请确保你已正确填写 Leaves 版本字段(例如:\`1.21.4-16\`)。 \n你可以通过 \`/leaves report\` 生成预填充的问题模板。`,
});
addLabels({
issue_number: issueNumber,
owner,
repo,
labels: ["version: invalid"],
});
return;
}
}
}

47
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,47 @@
name: Leaves Test CI
on:
push:
branches-ignore: [ master ]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get repository
uses: actions/checkout@v4
- name: Get JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "zulu"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
add-job-summary: never
generate-job-summary: false
cache-read-only: false
- name: Setup Git Config
run: |
git config --global user.email "ci-test@leavesmc.org"
git config --global user.name "LeavesMC Test CI"
- name: Apply Patches
run: ./gradlew applyAllPatches
- name: Create Leavesclip Jar
run: ./gradlew createMojmapLeavesclipJar
- name: Move Jar
run: |
prop() {
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
}
jarName="leaves-$(prop mcVersion).jar"
mv leaves-server/build/libs/leaves-leavesclip-"$(prop version)"-mojmap.jar "$jarName"
echo "jar=$jarName" >> "$GITHUB_ENV"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.jar }}
path: ${{ env.jar }}