mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 10:15:59 +08:00
chore: fix file name
This commit is contained in:
54
scripts/release.js
Normal file
54
scripts/release.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const chalk = require('chalk');
|
||||
const open = require('open');
|
||||
const newGithubReleaseUrl = require('new-github-release-url');
|
||||
const { readFileSync } = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let tag = '';
|
||||
|
||||
const CHANGELOG_NAME = 'CHANGELOG.md';
|
||||
const user = 'actions-cool';
|
||||
const repo = 'issues-helper';
|
||||
|
||||
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();
|
Reference in New Issue
Block a user