From e0046e95e213cf972cef91e8d38479c86c1c1761 Mon Sep 17 00:00:00 2001 From: Kilian von Pflugk Date: Thu, 15 Aug 2024 23:53:41 +0200 Subject: [PATCH] CI: update the Jellyfin Version in Readme --- .github/workflows/release.yml | 2 +- validate-and-update-manifest.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 257d23a..92e12ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/validate-and-update-manifest.js b/validate-and-update-manifest.js index 39f1a01..ce74e73 100644 --- a/validate-and-update-manifest.js +++ b/validate-and-update-manifest.js @@ -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(); }