-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.config.cjs
More file actions
87 lines (81 loc) · 2.27 KB
/
Copy pathrelease.config.cjs
File metadata and controls
87 lines (81 loc) · 2.27 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const fs = require('fs');
const xml2js = require('xml2js');
module.exports = {
branches: ['main'],
tagFormat: '${version}', // semantic-release uses vX.Y.Z by default, but cordova plugins expect X.Y.Z
plugins: [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{ "type": "refactor", "release": "patch" },
{ "type": "chore", "release": "patch" }
]
}
],
'@semantic-release/release-notes-generator',
[
'@semantic-release/changelog',
{
changelogFile: 'CHANGELOG.md',
},
],
// updates to plugin versions without npm publishing
[
'@semantic-release/npm',
{
pkgRoot: '.',
npmPublish: false
}
],
[
'@semantic-release/npm',
{
pkgRoot: 'packages/cordova-plugin',
npmPublish: false
}
],
// update plugin.xml version
{
async prepare(pluginConfig, context) {
const { nextRelease } = context;
const version = nextRelease.version;
const xmlPath = 'plugin.xml';
const xml = fs.readFileSync(xmlPath, 'utf8');
// Detect current indentation from first indented line
const match = xml.match(/^( +)\S/m);
const indent = match ? match[1].length : 2; // fallback to 2 spaces if not found
const parser = new xml2js.Parser();
const builder = new xml2js.Builder({ renderOpts: { pretty: true, indent: ' '.repeat(indent) } });
const parsed = await parser.parseStringPromise(xml);
parsed.plugin.$.version = version;
const updatedXml = builder.buildObject(parsed);
fs.writeFileSync(xmlPath, updatedXml);
console.log(`🔖 Updated plugin.xml version to ${version}`);
}
},
[
'@semantic-release/git',
{
assets: [
'package.json',
'packages/cordova-plugin/package.json',
'plugin.xml',
'CHANGELOG.md',
],
message:
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
},
],
[
'@semantic-release/github',
{
successComment: false,
failComment: false,
releasedLabels: false,
addReleases: 'bottom'
}
],
],
};