Skip to content

Commit

Permalink
Fix version replacer
Browse files Browse the repository at this point in the history
  • Loading branch information
Gellipapa authored Jan 30, 2024
1 parent 387642a commit f15af93
Showing 1 changed file with 6 additions and 48 deletions.
54 changes: 6 additions & 48 deletions .github/actions/bump-manifest-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,11 @@ const replace = require('replace-in-file');

const version = process.env.TGT_RELEASE_VERSION;
const newVersion = version.replace("v", "");
const defaultFolderPath = process.env.GITHUB_WORKSPACE;
const targetFile = 'fxmanifest.lua';
const allResults = [];

const replaceInFiles = (folderPath) => {
fs.readdir(folderPath, { withFileTypes: true }, (err, entries) => {
if (err) {
console.error(err);
return;
}

entries.forEach(entry => {
const entryPath = path.join(folderPath, entry.name);

if (entry.isDirectory()) {
replaceInFiles(entryPath);
} else if (entry.isFile() && entry.name === targetFile) {
const options = {
files: entryPath,
from: /\bversion\s+(.*)$/gm,
to: `version '${newVersion}'`,
};

try {
const results = replace.sync(options);
results.forEach(result => {
if (result.hasChanged) {
allResults.push(result);
}
});
} catch (error) {
console.error(error);
}
}
});
});
};

replaceInFiles(defaultFolderPath);

process.on('exit', () => {
const changedFiles = allResults.map(result => result.file);
console.log(changedFiles)
console.log(defaultFolderPath)
if (changedFiles.length > 0) {
console.log(`echo "FXMANIFEST_FILE_CHANGES=${JSON.stringify(changedFiles)}" >> $GITHUB_ENV`);
} else {
console.log('No changes!');
}
const results = replace.sync({
files: "./**/fxmanifest.lua",
from: /\bversion\s+(.*)$/gm,
to: `version '${newVersion}'`,
});

console.log(results)

0 comments on commit f15af93

Please sign in to comment.