-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.config.js
54 lines (47 loc) · 1.62 KB
/
release.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { writeFileSync, readFileSync } from 'fs';
const generatePatchNotes = {
generateNotes: async (pluginConfig, context) => {
const { nextRelease } = context;
// Lê o arquivo patch-notes.json existente ou cria um novo se não existir
let patchNotes;
try {
patchNotes = JSON.parse(readFileSync('public/patch-notes.json', 'utf8'));
} catch (error) {
console.error(error)
patchNotes = { versions: [] };
}
// Adiciona a nova versão no topo do array
patchNotes.versions.unshift({
version: nextRelease.version,
date: new Date().toISOString().split('T')[0],
notes: nextRelease.notes
});
// Atualiza a versão atual
patchNotes.currentVersion = nextRelease.version;
// Limita o histórico para as últimas 10 versões
patchNotes.versions = patchNotes.versions.slice(0, 10);
console.log('Gerando patch notes...');
writeFileSync('public/patch-notes.json', JSON.stringify(patchNotes, null, 2));
console.log('Patch notes gerados com sucesso em public/patch-notes.json');
},
};
export default {
branches: ['main'],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
['@semantic-release/npm', { npmPublish: false }],
'@semantic-release/github',
generatePatchNotes,
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
['@semantic-release/git', {
assets: ['CHANGELOG.md', 'package.json', 'public/patch-notes.json'],
message: 'chore(release): :bookmark: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}],
],
};