Skip to content

Commit

Permalink
Update version system
Browse files Browse the repository at this point in the history
- Remove script templates
- Modify script to make the necessary changes
- Bump version to 1.3.2
  • Loading branch information
AgustinSRG committed Apr 14, 2023
1 parent a15bec6 commit f2e060b
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 224 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ call cmake -DCMAKE_BUILD_TYPE=Release -A x64 -Ssrc -Brelease

call cmake --build release --config Release

call zip -r release/ImageToMapMC-1.3.1-Windows-x64.zip release/Release
call zip -r release/ImageToMapMC-1.3.2-Windows-x64.zip release/Release
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ cmake --build release --config Release

rm -rf release/bin || true

rm -rf release/ImageToMapMC-1.3.1-linux-x64.tar.gz || true
rm -rf release/ImageToMapMC-1.3.2-linux-x64.tar.gz || true

mkdir release/bin

cp release/mcmap release/bin/mcmap
cp release/mcmap-gui release/bin/mcmap-gui

tar -cvzf release/ImageToMapMC-1.3.1-linux-x64.tar.gz release/bin
tar -cvzf release/ImageToMapMC-1.3.2-linux-x64.tar.gz release/bin

echo "DONE: Created release ImageToMapMC-1.3.1-linux-x64.tar.gz"
echo "DONE: Created release ImageToMapMC-1.3.2-linux-x64.tar.gz"
2 changes: 1 addition & 1 deletion build32.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ call cmake -DCMAKE_BUILD_TYPE=Release -A Win32 -Ssrc -Brelease32

call cmake --build release32 --config Release

call zip -r release32/ImageToMapMC-1.3.1-Windows-Win32.zip release32/Release
call zip -r release32/ImageToMapMC-1.3.2-Windows-Win32.zip release32/Release
159 changes: 0 additions & 159 deletions script-templates/Product.wxs

This file was deleted.

7 changes: 0 additions & 7 deletions script-templates/build.bat

This file was deleted.

20 changes: 0 additions & 20 deletions script-templates/build.sh

This file was deleted.

7 changes: 0 additions & 7 deletions script-templates/build32.bat

This file was deleted.

9 changes: 0 additions & 9 deletions script-templates/make-wix-installer.bat

This file was deleted.

77 changes: 62 additions & 15 deletions update-version.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,73 @@
// This script updates the version for
// the build scripts
// Script to update the version number
// Usage: node update-version.js A.B.C

// Run with NodeJS
"use strict";

const Path = require("path");
const FS = require("fs");
const Path = require("path");

function updateFile(file, callback) {
const contents = FS.readFileSync(file).toString();
const newContents = callback(contents);
FS.writeFileSync(file, newContents);
console.log("UPDATED: " + file);
}

function main () {
const version = process.argv[2];
function main() {
const arg = process.argv[2] || "";

if (!version) {
console.error("Usage: node update-version.js A.B.C");
return;
if (!arg) {
console.log("Usage: node update-version.js A.B.C");
return 1;
}

const templates = FS.readdirSync(Path.resolve(__dirname, "script-templates"));
const parts = arg.split(".");

for (let templateFile of templates) {
const contents = FS.readFileSync(Path.resolve(__dirname, "script-templates", templateFile)).toString();
FS.writeFileSync(Path.resolve(__dirname, templateFile), contents.replace(/\{VERSION\}/g, version));
console.log("UPDATED: " + templateFile);
if (parts.length !== 3) {
console.log("Usage: node update-version.js A.B.C");
return 1;
}

const MAJOR = parseInt(parts[0], 10);
const MINOR = parseInt(parts[1], 10);
const REVISION = parseInt(parts[2], 10);

if (isNaN(MAJOR) || isNaN(MINOR) || isNaN(REVISION) || MAJOR < 0 || MINOR < 0 || REVISION < 0) {
console.log("Usage: node update-version.js A.B.C");
return 1;
}

const VERSION = MAJOR + "." + MINOR + "." + REVISION;
const DATE = (new Date()).toISOString().split("T")[0];

console.log(`Changing version to ${VERSION} | Date: ${DATE}`);

updateFile(Path.resolve(__dirname, "build.bat"), contents => {
return contents
.replace(/ImageToMapMC\-[0-9]+\.[0-9]+\.[0-9]+\-Windows\-x64\.zip/g, `ImageToMapMC-${VERSION}-Windows-x64.zip`);
});

updateFile(Path.resolve(__dirname, "build32.bat"), contents => {
return contents
.replace(/ImageToMapMC\-[0-9]+\.[0-9]+\.[0-9]+\-Windows\-Win32\.zip/g, `ImageToMapMC-${VERSION}-Windows-Win32.zip`);
});

updateFile(Path.resolve(__dirname, "build.sh"), contents => {
return contents
.replace(/ImageToMapMC\-[0-9]+\.[0-9]+\.[0-9]+\-linux\-x64\.tar\.gz/g, `ImageToMapMC-${VERSION}-linux-x64.tar.gz`);
});

updateFile(Path.resolve(__dirname, "wix", "make-wix-installer.bat"), contents => {
return contents
.replace(/ImageToMapMC\-[0-9]+\.[0-9]+\.[0-9]+\-x64\.msi/g, `ImageToMapMC-${VERSION}-x64.msi`);
});

updateFile(Path.resolve(__dirname, "wix", "Product.wxs"), contents => {
return contents
.replace(/Name=\"ImageToMapMC\" Version=\"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\"/, `Name="ImageToMapMC" Version="${VERSION}.0"`);
});

console.log("DONE!");
}

main();
process.exit(main() || 0);
2 changes: 1 addition & 1 deletion wix/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<!-- Use * to generate product ID on every build -->
<Product Id="*" Name="ImageToMapMC" Version="1.3.1.0" Language="1033" Manufacturer="AgustinSRG" UpgradeCode="1a73ad10-cffe-462a-ab4e-aefc9a2bd53b">
<Product Id="*" Name="ImageToMapMC" Version="1.3.2.0" Language="1033" Manufacturer="AgustinSRG" UpgradeCode="1a73ad10-cffe-462a-ab4e-aefc9a2bd53b">

<Package Compressed="yes" InstallScope="perMachine" Manufacturer="AgustinSRG" Description="Converts images to Minecraft maps." Platform="x64" />

Expand Down
2 changes: 1 addition & 1 deletion wix/make-wix-installer.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ call candle -ext WixUIExtension -ext WixUtilExtension -arch x64 "HeatFile.wxs" -

call candle -ext WixUIExtension -ext WixUtilExtension -arch x64 "Product.wxs" -o "Product.wixobj"

call light "Product.wixobj" -spdb "HeatFile.wixobj" -b ImageToMapMC -o "ImageToMapMC-1.3.1-x64.msi" -ext WixUIExtension -ext WixUtilExtension
call light "Product.wixobj" -spdb "HeatFile.wixobj" -b ImageToMapMC -o "ImageToMapMC-1.3.2-x64.msi" -ext WixUIExtension -ext WixUtilExtension

0 comments on commit f2e060b

Please sign in to comment.