mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-08 11:43:21 -04:00
Un-broke version release
This commit is contained in:
parent
818655f928
commit
25c74addfd
@ -8,14 +8,25 @@ const fs = require("fs");
|
|||||||
|
|
||||||
//region Executed Code
|
//region Executed Code
|
||||||
(async () => {
|
(async () => {
|
||||||
const nextVersion = await createChangeLog();
|
versionAndChangelog = await parseCommits();
|
||||||
const nextIncrementalVersion = updateBuildConfig(nextVersion);
|
const newVersionString = versionAndChangelog[0]
|
||||||
updateGameVersion(nextVersion, nextIncrementalVersion);
|
const changelogString = versionAndChangelog[1]
|
||||||
|
|
||||||
|
writeChangelog(newVersionString, changelogString)
|
||||||
|
|
||||||
|
const newAppCodeNumber = updateBuildConfig(newVersionString);
|
||||||
|
if (newAppCodeNumber){ // is false if buildConfig already contains the newVersionString
|
||||||
|
createFastlaneFile(newAppCodeNumber, changelogString)
|
||||||
|
updateGameVersion(newVersionString, newAppCodeNumber);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
||||||
//region Function Definitions
|
//region Function Definitions
|
||||||
async function createChangeLog() {
|
|
||||||
|
// Returns: [nextVersionString, changelogString]
|
||||||
|
async function parseCommits() {
|
||||||
// no need to add auth: token since we're only reading from the commit list, which is public anyway
|
// no need to add auth: token since we're only reading from the commit list, which is public anyway
|
||||||
const octokit = new Octokit({});
|
const octokit = new Octokit({});
|
||||||
|
|
||||||
@ -65,8 +76,11 @@ async function createChangeLog() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(commitSummary);
|
console.log(commitSummary);
|
||||||
|
return [nextVersionString, commitSummary];
|
||||||
|
}
|
||||||
|
|
||||||
var textToAddToChangelog = "## " + nextVersionString + commitSummary + "\n\n";
|
function writeChangelog(nextVersionString, changelogString){
|
||||||
|
var textToAddToChangelog = "## " + nextVersionString + changelogString + "\n\n";
|
||||||
|
|
||||||
var changelogPath = 'changelog.md';
|
var changelogPath = 'changelog.md';
|
||||||
var currentChangelog = fs.readFileSync(changelogPath).toString();
|
var currentChangelog = fs.readFileSync(changelogPath).toString();
|
||||||
@ -74,7 +88,6 @@ async function createChangeLog() {
|
|||||||
var newChangelog = textToAddToChangelog + currentChangelog;
|
var newChangelog = textToAddToChangelog + currentChangelog;
|
||||||
fs.writeFileSync(changelogPath, newChangelog);
|
fs.writeFileSync(changelogPath, newChangelog);
|
||||||
}
|
}
|
||||||
return nextVersionString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBuildConfig(nextVersionString) {
|
function updateBuildConfig(nextVersionString) {
|
||||||
@ -90,38 +103,40 @@ function updateBuildConfig(nextVersionString) {
|
|||||||
const curVersion = appVersionMatch[1];
|
const curVersion = appVersionMatch[1];
|
||||||
if (curVersion !== nextVersionString) {
|
if (curVersion !== nextVersionString) {
|
||||||
buildConfigString = buildConfigString.replace(appVersionMatch[0], appVersionMatch[0].replace(curVersion, nextVersionString));
|
buildConfigString = buildConfigString.replace(appVersionMatch[0], appVersionMatch[0].replace(curVersion, nextVersionString));
|
||||||
var incrementalVersionMatch = buildConfigString.match(/appCodeNumber = (\d*)/);
|
var appCodeNumberMatch = buildConfigString.match(/appCodeNumber = (\d*)/);
|
||||||
let curIncrementalVersion = incrementalVersionMatch[1];
|
let currentAppCodeNumber = appCodeNumberMatch[1];
|
||||||
console.log("Current incremental version: " + curIncrementalVersion);
|
console.log("Current incremental version: " + currentAppCodeNumber);
|
||||||
const nextIncrementalVersion = Number(curIncrementalVersion) + 1;
|
const nextAppCodeNumber = Number(currentAppCodeNumber) + 1;
|
||||||
console.log("Next incremental version: " + nextIncrementalVersion);
|
console.log("Next incremental version: " + nextAppCodeNumber);
|
||||||
buildConfigString = buildConfigString.replace(incrementalVersionMatch[0],
|
buildConfigString = buildConfigString.replace(appCodeNumberMatch[0],
|
||||||
incrementalVersionMatch[0].replace(curIncrementalVersion, nextIncrementalVersion));
|
appCodeNumberMatch[0].replace(currentAppCodeNumber, nextAppCodeNumber));
|
||||||
|
|
||||||
console.log("Final: " + buildConfigString);
|
console.log("Final: " + buildConfigString);
|
||||||
fs.writeFileSync(buildConfigPath, buildConfigString);
|
fs.writeFileSync(buildConfigPath, buildConfigString);
|
||||||
|
return nextAppCodeNumber;
|
||||||
// A new, discrete changelog file for fastlane (F-Droid support):
|
|
||||||
var fastlaneChangelogPath = "fastlane/metadata/android/en-US/changelogs/" + nextIncrementalVersion + ".txt";
|
|
||||||
fs.writeFileSync(fastlaneChangelogPath, textToAddToChangelog);
|
|
||||||
return nextIncrementalVersion;
|
|
||||||
}
|
}
|
||||||
return appVersionMatch;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateGameVersion(nextVersion, nextIncrementalVersion) {
|
function createFastlaneFile(newAppCodeNumber, changelogString){
|
||||||
|
// A new, discrete changelog file for fastlane (F-Droid support):
|
||||||
|
var fastlaneChangelogPath = "fastlane/metadata/android/en-US/changelogs/" + newAppCodeNumber + ".txt";
|
||||||
|
fs.writeFileSync(fastlaneChangelogPath, changelogString);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateGameVersion(newVersionString, newAppCodeNumber) {
|
||||||
const gameInfoPath = "core/src/com/unciv/UncivGame.kt";
|
const gameInfoPath = "core/src/com/unciv/UncivGame.kt";
|
||||||
const gameInfoSource = fs.readFileSync(gameInfoPath).toString();
|
const gameInfoSource = fs.readFileSync(gameInfoPath).toString();
|
||||||
const regexp = /(\/\/region AUTOMATICALLY GENERATED VERSION DATA - DO NOT CHANGE THIS REGION, INCLUDING THIS COMMENT)[\s\S]*(\/\/endregion)/;
|
const regexp = /(\/\/region AUTOMATICALLY GENERATED VERSION DATA - DO NOT CHANGE THIS REGION, INCLUDING THIS COMMENT)[\s\S]*(\/\/endregion)/;
|
||||||
const withNewVersion = gameInfoSource.replace(regexp, function(match, grp1, grp2) {
|
const withNewVersion = gameInfoSource.replace(regexp, function(match, grp1, grp2) {
|
||||||
const versionClassStr = createVersionClassString(nextVersion, nextIncrementalVersion);
|
const versionClassStr = createVersionClassString(newVersionString, newAppCodeNumber);
|
||||||
return `${grp1}\n val VERSION = ${versionClassStr}\n ${grp2}`;
|
return `${grp1}\n val VERSION = ${versionClassStr}\n ${grp2}`;
|
||||||
})
|
})
|
||||||
fs.writeFileSync(gameInfoPath, withNewVersion);
|
fs.writeFileSync(gameInfoPath, withNewVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createVersionClassString(nextVersion, nextIncrementalVersion) {
|
function createVersionClassString(newVersionString, newAppCodeNumber) {
|
||||||
return `Version("${nextVersion}", ${nextIncrementalVersion})`;
|
return `Version("${newVersionString}", ${newAppCodeNumber})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user