CI: update the Jellyfin Version in Readme

This commit is contained in:
Kilian von Pflugk 2024-08-15 23:53:41 +02:00
parent 8ac4afa11d
commit e0046e95e2
2 changed files with 30 additions and 1 deletions

View File

@ -57,6 +57,6 @@ jobs:
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add manifest.json ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj
git add README.md manifest.json ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj
git commit -m "release v${{ env.NEW_FILE_VERSION }}"
git push

View File

@ -13,6 +13,14 @@ if (!fs.existsSync(manifestPath)) {
console.error('manifest.json file not found');
process.exit(1);
}
// Read README.md
const readmePath = './README.md';
if (!fs.existsSync(readmePath)) {
console.error('README.md file not found');
process.exit(1);
}
const jsonData = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const newVersion = {
@ -33,6 +41,7 @@ async function updateManifest() {
// Write the updated manifest to file if validation is successful
fs.writeFileSync(manifestPath, JSON.stringify(jsonData, null, 4));
console.log('Manifest updated successfully.');
updateReadMeVersion();
process.exit(0); // Exit with no error
}
@ -94,6 +103,26 @@ function getMD5FromFile() {
return crypto.createHash('md5').update(fileBuffer).digest('hex');
}
function getReadMeVersion() {
let parts = targetAbi.split('.').map(Number);
parts.pop();
return parts.join(".");
}
function updateReadMeVersion() {
const newVersion = getReadMeVersion();
const readMeContent = fs.readFileSync(readmePath, 'utf8');
const updatedContent = readMeContent
.replace(/Jellyfin.*\(or newer\)/, `Jellyfin ${newVersion} (or newer)`)
if (readMeContent != updatedContent) {
fs.writeFileSync(readmePath, updatedContent);
console.log('Updated README with new Jellyfin version.');
} else {
console.log('README has already newest Jellyfin version.');
}
}
async function run() {
await updateManifest();
}