mirror of
https://gitea.com/Lydanne/pr-extract-issues.git
synced 2025-08-16 08:46:00 +08:00
56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
const chalk = require('chalk');
|
|
const open = require('open');
|
|
const newGithubReleaseUrl = require('new-github-release-url');
|
|
const { readFileSync } = require('fs');
|
|
const path = require('path');
|
|
const {
|
|
CHANGELOG_NAME,
|
|
user,
|
|
repo
|
|
} = require('./const');
|
|
|
|
let tag = '';
|
|
|
|
function getChangelog(content) {
|
|
const lines = content.split('\n');
|
|
const changeLog = [];
|
|
const pin = /^## /;
|
|
let begin = false;
|
|
for (let i = 0; i < lines.length; i += 1) {
|
|
const line = lines[i];
|
|
if (begin && pin.test(line)) {
|
|
break;
|
|
}
|
|
if (begin && line) {
|
|
changeLog.push(line);
|
|
}
|
|
if (!begin) {
|
|
begin = pin.test(line);
|
|
if (begin) {
|
|
tag = line.substring(3, line.length).trim();
|
|
}
|
|
}
|
|
}
|
|
return changeLog.join('\n');
|
|
}
|
|
|
|
const changelogPath = path.join(__dirname, '..', CHANGELOG_NAME);
|
|
const changelog = readFileSync(changelogPath, 'utf-8');
|
|
|
|
const body = getChangelog(changelog);
|
|
|
|
async function run() {
|
|
const url = newGithubReleaseUrl({
|
|
user,
|
|
repo,
|
|
tag,
|
|
body: body,
|
|
});
|
|
|
|
await open(url);
|
|
|
|
console.log(chalk.yellow('🚀 Please check tag and changelog. Then click publish!'));
|
|
}
|
|
|
|
run();
|