From 01c1565344efabc8ddcae6f43e8fdb3cc6533174 Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Sat, 20 May 2023 14:13:43 +0300 Subject: [PATCH] Add a script for bumping the version number WIP, needs more testing. --- .gitattributes | 1 + build/bump-version.php | 125 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 .gitattributes create mode 100644 build/bump-version.php diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ba74e78 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +/build export-ignore diff --git a/build/bump-version.php b/build/bump-version.php new file mode 100644 index 0000000..19c883a --- /dev/null +++ b/build/bump-version.php @@ -0,0 +1,125 @@ +isFile() ) { + updateVersionNumbers($file->getPathname(), $oldVersion, $newVersion); + } + } +} + +//Replace the old version infix in the readme file. +updateVersionNumbers($repositoryRoot . '/README.md', $oldVersion, $newVersion); + +//Rename the loader file and update the version numbers. +$oldLoaderFileName = "load-$oldVersionInfix.php"; +$newLoaderFileName = "load-$newVersionInfix.php"; +exec("git mv $oldLoaderFileName $newLoaderFileName"); +updateVersionNumbers($repositoryRoot . '/' . $newLoaderFileName, $oldVersion, $newVersion); + +//Replace old loader file name with new one in plugin-update-checker.php. +$pluginUpdateCheckerFilePath = $repositoryRoot . '/plugin-update-checker.php'; +$content = file_get_contents($pluginUpdateCheckerFilePath); +$content = str_replace($oldLoaderFileName, $newLoaderFileName, $content); +file_put_contents($pluginUpdateCheckerFilePath, $content); + +// Commit the changes +exec('git add .'); +exec("git commit -m 'Bump version number to $newVersion'"); + +//Switch back to the original branch. +//exec('git checkout -'); + +//Switch back to the original directory. +chdir($oldDir); +