Move scripts into separate folders
This commit is contained in:
32
tools/scripts/release/createCommitChangelog.ts
Normal file
32
tools/scripts/release/createCommitChangelog.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { createCommitChangelog } from './CommitChangelog.utils.ts';
|
||||
|
||||
const { sha } = yargs(hideBin(process.argv))
|
||||
.options({
|
||||
sha: {
|
||||
description: 'The hash of the last commit of the previous release',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
},
|
||||
})
|
||||
.parseSync();
|
||||
|
||||
if (!sha) {
|
||||
throw new Error('Sha of last commit of the previous release has to be passed!');
|
||||
}
|
||||
|
||||
createCommitChangelog(sha)
|
||||
.then(console.log)
|
||||
.catch((error) => {
|
||||
console.error('Failed due to', error);
|
||||
process.exit(1);
|
||||
});
|
||||
50
tools/scripts/release/createReleaseChangelog.ts
Normal file
50
tools/scripts/release/createReleaseChangelog.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import dayjs from 'dayjs';
|
||||
import { createCommitChangelog } from './CommitChangelog.utils.ts';
|
||||
import { createTranslationChangelog } from './TranslationChangelog.utils.ts';
|
||||
import { validateWeblateDates } from '../weblate/Weblate.utils.ts';
|
||||
|
||||
const { sha, date } = yargs(hideBin(process.argv))
|
||||
.options({
|
||||
sha: {
|
||||
description: 'The hash of the last commit of the previous release',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
},
|
||||
date: {
|
||||
alias: 'ad',
|
||||
description: 'IS0-8601 formatted date of the last release (e.g. 2024-05-01)',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
},
|
||||
})
|
||||
.parseSync();
|
||||
|
||||
if (!sha) {
|
||||
throw new Error('Sha of last commit of the previous release has to be passed!');
|
||||
}
|
||||
const createReleaseChangelog = async (lastReleaseCommitSha: string, lastReleaseDate: string) => {
|
||||
validateWeblateDates(lastReleaseDate, lastReleaseDate);
|
||||
|
||||
const tomorrow = dayjs().add(1, 'day');
|
||||
|
||||
const beforeDate = tomorrow.format('YYYY-MM-DD');
|
||||
const afterDate = dayjs(lastReleaseDate).add(1, 'day').format('YYYY-MM-DD');
|
||||
|
||||
const commitChangelog = await createCommitChangelog(lastReleaseCommitSha);
|
||||
const translationChangelog = await createTranslationChangelog(afterDate, beforeDate);
|
||||
const changelog = `${translationChangelog}\n${commitChangelog}`;
|
||||
|
||||
console.log(changelog);
|
||||
};
|
||||
|
||||
createReleaseChangelog(sha, date).then(console.log);
|
||||
47
tools/scripts/release/createTranslationChangelog.ts
Normal file
47
tools/scripts/release/createTranslationChangelog.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { createTranslationChangelog } from './TranslationChangelog.utils.ts';
|
||||
import { TRANSLATION_CHANGELOG_YARG_OPTIONS_DEFAULT } from '../weblate/Weblate.constants.ts';
|
||||
|
||||
const { afterDate, beforeDate, requiredContributionCount, keepKnownContributors } = yargs(hideBin(process.argv))
|
||||
.options({
|
||||
afterDate: {
|
||||
alias: 'ad',
|
||||
description: 'IS0-8601 formatted date (included) (e.g. 2024-05-01)',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
},
|
||||
beforeDate: {
|
||||
alias: 'bd',
|
||||
description: 'IS0-8601 formatted date (excluded) (e.g. 2024-05-11)',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
},
|
||||
requiredContributionCount: {
|
||||
alias: 'rcc',
|
||||
description: 'The minimum number of contributions for a language to be considered a contributor',
|
||||
type: 'number',
|
||||
default: TRANSLATION_CHANGELOG_YARG_OPTIONS_DEFAULT.requiredContributionCount,
|
||||
},
|
||||
keepKnownContributors: {
|
||||
alias: 'kc',
|
||||
description: 'Ignore "requiredContributionCount" for known contributors of a language',
|
||||
type: 'boolean',
|
||||
default: TRANSLATION_CHANGELOG_YARG_OPTIONS_DEFAULT.keepKnownContributors,
|
||||
},
|
||||
})
|
||||
.parseSync();
|
||||
|
||||
if (!afterDate || !beforeDate) {
|
||||
throw new Error('The timespan (afterDate and beforeDate) has to be passed!');
|
||||
}
|
||||
|
||||
createTranslationChangelog(afterDate, beforeDate, requiredContributionCount, keepKnownContributors).then(console.log);
|
||||
Reference in New Issue
Block a user