Merge pull request #12 from petersendev/changelog

write changelog
This commit is contained in:
Arne Petersen
2019-06-20 08:10:52 +02:00
committed by GitHub

View File

@@ -52,7 +52,9 @@ async function run(opts: { patch: boolean })
const versionRegex = config.maintenance.version_regex ? new RegExp(config.maintenance.version_regex) : null; const versionRegex = config.maintenance.version_regex ? new RegExp(config.maintenance.version_regex) : null;
const dockerFilePath = path.join(root, addon, "Dockerfile"); const addonPath = path.join(root, addon);
const changelogPath = path.join(addonPath, "CHANGELOG.md");
const dockerFilePath = path.join(addonPath, "Dockerfile");
const dockerFile = (await fs.readFileAsync(dockerFilePath)).toString(); const dockerFile = (await fs.readFileAsync(dockerFilePath)).toString();
const dockerBaseImageLine = dockerFile.split("\n")[0]; const dockerBaseImageLine = dockerFile.split("\n")[0];
const parts = dockerBaseImageLine.split(":"); const parts = dockerBaseImageLine.split(":");
@@ -109,10 +111,28 @@ async function run(opts: { patch: boolean })
console.log(chalk.yellow(`bumping version from ${chalk.cyanBright(version)} to ${chalk.cyanBright(newVersion)}`)); console.log(chalk.yellow(`bumping version from ${chalk.cyanBright(version)} to ${chalk.cyanBright(newVersion)}`));
config.version = newVersion; config.version = newVersion;
await fs.writeJSONAsync(configPath, config); await fs.writeJSONAsync(configPath, config);
let oldChangelog = "";
if (await fs.existsAsync(changelogPath))
{
oldChangelog = (await fs.readFileAsync(changelogPath)).toString();
}
let changelog = `## ${newVersion}\n\n - ${minorUpgrade ?
`Update ${config.name} to ${newAppVersion} (${image}:${releaseInfo.tag_name})` :
`Update base image to ${image}:${releaseInfo.tag_name}`}`;
if (oldChangelog)
{
changelog += `\n\n${oldChangelog}`;
}
await fs.writeFileAsync(changelogPath, changelog);
updated = true; updated = true;
} }
} }
} }
}; };
run(argv); run(argv);