Skip to content

Commit 8832af1

Browse files
authored
Merge pull request #840 from XMOJ-Script-dev/dev
sync: dev to extern-contrib
2 parents 06acb73 + d3bd686 commit 8832af1

File tree

8 files changed

+42
-7
lines changed

8 files changed

+42
-7
lines changed

.github/workflows/UpdateToRelease.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- opened
66
- reopened
77
- synchronize
8+
- edited
89
branches:
910
- master
1011
jobs:
@@ -24,7 +25,8 @@ jobs:
2425
gh pr comment ${{ github.event.pull_request.number }} --body "请向\`dev\`分支提交pull request, 本pull request将被自动关闭"
2526
gh pr close ${{ github.event.pull_request.number }}
2627
else
27-
node ./Update/UpdateToRelease.js ${{ secrets.GITHUB_TOKEN }} ${{ github.event.number }}
28+
node ./Update/UpdateToRelease.js ${{ secrets.GITHUB_TOKEN }} ${{ github.event.number }} "$PR_BODY"
2829
fi
2930
env:
3031
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
PR_BODY: ${{ github.event.pull_request.body }}

.github/workflows/UpdateVersion.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ jobs:
2323
private-key: ${{ secrets.APP_PRIVATE_KEY }}
2424
- uses: actions/checkout@v5
2525
- name: Update version
26-
run: node ./Update/UpdateVersion.js ${{ steps.generate_token.outputs.token }} ${{ github.event.number }} "${{ github.event.pull_request.title }}"
26+
env:
27+
PR_BODY: ${{ github.event.pull_request.body }}
28+
run: node ./Update/UpdateVersion.js ${{ steps.generate_token.outputs.token }} ${{ github.event.number }} "${{ github.event.pull_request.title }}" "$PR_BODY"

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ We believe that you must be excited to contribute to our repo, but first, please
1818
- Be patient. We are a small team and may not be able to review your PR immediately.
1919
- Please be considerate towards the developers and other users when raising issues or presenting pull requests.
2020
- Respect our decision(s), and do not be upset or abusive if your submission is not used.
21+
- For release pull requests, include an HTML comment block starting with `<!-- release-notes` and ending with `-->` in the PR description. The automation will extract that block into the release notes.

Update.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,6 +3021,17 @@
30213021
}
30223022
],
30233023
"Notes": "No release notes were provided for this release."
3024+
},
3025+
"2.2.1": {
3026+
"UpdateDate": 1756003502262,
3027+
"Prerelease": true,
3028+
"UpdateContents": [
3029+
{
3030+
"PR": 839,
3031+
"Description": "Fix formatting in feedback card text"
3032+
}
3033+
],
3034+
"Notes": "No release notes were provided for this release."
30243035
}
30253036
}
30263037
}

Update/UpdateToRelease.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import {execSync} from "child_process";
33

44
var GithubToken = process.argv[2];
55
var PRNumber = process.argv[3];
6+
function extractReleaseNotes(body) {
7+
const match = body
8+
.replace(/\r\n/g, "\n")
9+
.match(/<!--\s*release[- ]notes\s*([\s\S]*?)-->/i);
10+
return match ? match[1].trim() : "";
11+
}
12+
var CurrentNotes = extractReleaseNotes(String(process.argv[4] || ""));
613
process.env.GITHUB_TOKEN = GithubToken;
714
execSync("gh pr checkout " + PRNumber);
815
console.info("PR #" + PRNumber + " has been checked out.");
@@ -45,6 +52,7 @@ console.log("Last JSON version : " + LastJSONVersion);
4552
console.log("Last PR : " + LastPR);
4653
console.log("Last type : " + LastType);
4754
console.log("npm version : " + NpmVersion);
55+
console.log("Current notes : " + (CurrentNotes || "No release notes were provided for this release."));
4856

4957
if (LastJSONVersion != LastJSVersion) {
5058
console.error("XMOJ.user.js and Update.json have different patch versions.");
@@ -67,7 +75,7 @@ JSONObject.UpdateHistory[CurrentVersion] = {
6775
"UpdateDate": Date.now(),
6876
"Prerelease": false,
6977
"UpdateContents": [],
70-
"Notes": "No release notes were provided for this release."
78+
"Notes": CurrentNotes || "No release notes were provided for this release."
7179
};
7280

7381
for (var i = Object.keys(JSONObject.UpdateHistory).length - 2; i >= 0; i--) {

Update/UpdateVersion.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ execSync("git config --global user.email \"github-actions[bot]@users.noreply.git
4747
execSync("git config --global user.name \"github-actions[bot]\"");
4848
var CurrentPR = Number(PRNumber);
4949
var CurrentDescription = String(process.argv[4]);
50+
function extractReleaseNotes(body) {
51+
const match = body
52+
.replace(/\r\n/g, "\n")
53+
.match(/<!--\s*release[- ]notes\s*([\s\S]*?)-->/i);
54+
return match ? match[1].trim() : "";
55+
}
56+
var CurrentNotes = extractReleaseNotes(String(process.argv[5] || ""));
5057
if (LastJSVersion != NpmVersion) {
5158
console.warn("Assuming you manually ran npm version.");
5259
} else if (!(LastPR == CurrentPR && NpmVersion == LastJSVersion)) {
@@ -58,6 +65,7 @@ var CurrentVersion = execSync("jq -r '.version' package.json").toString().trim()
5865
console.log("Current version : " + CurrentVersion);
5966
console.log("Current PR : " + CurrentPR);
6067
console.log("Current description: " + CurrentDescription);
68+
console.log("Current notes : " + (CurrentNotes || "No release notes were provided for this release."));
6169

6270
var ChangedFileList = execSync("gh pr diff " + CurrentPR + " --name-only").toString().trim().split("\n");
6371
console.log("Changed files : " + ChangedFileList.join(", "));
@@ -67,6 +75,9 @@ if (LastPR == CurrentPR && NpmVersion == LastJSVersion) {
6775
console.warn("Warning: PR is the same as last version.");
6876
JSONObject.UpdateHistory[LastJSVersion].UpdateDate = Date.now();
6977
JSONObject.UpdateHistory[LastJSVersion].UpdateContents[0].Description = CurrentDescription;
78+
if (CurrentNotes) {
79+
JSONObject.UpdateHistory[LastJSVersion].Notes = CurrentNotes;
80+
}
7081
CommitMessage = "Update time and description of " + LastJSVersion;
7182
} else if (ChangedFileList.indexOf("XMOJ.user.js") == -1) {
7283
console.warn("XMOJ.user.js is not changed, so the version should not be updated.");
@@ -79,7 +90,7 @@ if (LastPR == CurrentPR && NpmVersion == LastJSVersion) {
7990
"PR": CurrentPR,
8091
"Description": CurrentDescription
8192
}],
82-
"Notes": "No release notes were provided for this release."
93+
"Notes": CurrentNotes || "No release notes were provided for this release."
8394
};
8495
writeFileSync(JSFileName, JSFileContent.replace(/@version(\s+)\d+\.\d+\.\d+/, "@version$1" + CurrentVersion), "utf8");
8596
console.warn("XMOJ.user.js has been updated.");

XMOJ.user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name XMOJ
3-
// @version 2.2.0
3+
// @version 2.2.1
44
// @description XMOJ增强脚本
55
// @author @XMOJ-Script-dev, @langningchen and the community
66
// @namespace https://github/langningchen
@@ -1513,7 +1513,7 @@ async function main() {
15131513
FeedbackCardBody.className = "card-body";
15141514
let FeedbackCardText = document.createElement("p");
15151515
FeedbackCardText.className = "card-text";
1516-
FeedbackCardText.innerText = "如果您有任何建议或者发现了bug,请前往本项目的GitHub页面并提交issue。提交issue前请先搜索是否有相同的issue,如果有请在该issue下留言。请在issue中尽可能详细地描述您的问题,并且附上您的浏览器版本、操作系统版本、脚本版本、复现步骤等信息。谢谢您支持本项目。";
1516+
FeedbackCardText.innerText = "如果您有任何建议或者发现了 bug,请前往本项目的 GitHub 页面并提交 issue。提交 issue 前请先搜索是否有相同的 issue,如果有请在该 issue 下留言。请在 issue 中尽可能详细地描述您的问题,并且附上您的浏览器版本、操作系统版本、脚本版本、复现步骤等信息。谢谢您支持本项目。";
15171517
FeedbackCardBody.appendChild(FeedbackCardText);
15181518
let FeedbackCardLink = document.createElement("a");
15191519
FeedbackCardLink.className = "card-link";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xmoj-script",
3-
"version": "2.2.0",
3+
"version": "2.2.1",
44
"description": "an improvement script for xmoj.tech",
55
"main": "AddonScript.js",
66
"scripts": {

0 commit comments

Comments
 (0)