mirror of
https://github.com/ditkrg/project-version-check.git
synced 2026-01-22 22:06:42 +00:00
Increase nodejs project version
Signed-off-by: Shakar <5h4k4r.b4kr@gmail.com>
This commit is contained in:
parent
43984c923b
commit
666e5bd430
34
index.js
34
index.js
@ -8,8 +8,40 @@ try {
|
||||
core.setOutput("label", label);
|
||||
|
||||
const version = require('./package.json').version;
|
||||
// the version is in semantic format, so we can split it by dot
|
||||
const versionParts = version.substring(1).split('.');
|
||||
if (label === 'major')
|
||||
versionParts[0] = parseInt(versionParts[0]) + 1;
|
||||
else if (label == 'minor')
|
||||
versionParts[1] = parseInt(versionParts[1]) + 1;
|
||||
else if (label == 'patch')
|
||||
versionParts[2] = parseInt(versionParts[2]) + 1;
|
||||
|
||||
|
||||
|
||||
// increment the patch version
|
||||
// join the parts back together
|
||||
const newVersion = `v${versionParts.join('.')}`;
|
||||
|
||||
// Parse XML to JS Obj
|
||||
xml2js.parseString(data, function (err, result) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
// Convert JS obj to JSON
|
||||
const json = JSON.stringify(result, null, 2);
|
||||
|
||||
// Write JSON to file
|
||||
fs.writeFile('./project.json', json, 'utf8', function (err) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
console.log('Created project.json from project.csproj');
|
||||
});
|
||||
});
|
||||
|
||||
console.log(`Old version: ${version}. New version: ${newVersion}`)
|
||||
|
||||
console.log(`Version: ${version}`)
|
||||
|
||||
const payload = JSON.stringify(github.context.payload, undefined, 2)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user