Extract replacing versions for a private plugin to a function
[MAILPOET-6097]
This commit is contained in:
committed by
Rostislav Wolný
parent
3898b3dccb
commit
18dc3daa78
@ -2,48 +2,9 @@
|
||||
|
||||
require_once __DIR__ . '/helpers.php';
|
||||
|
||||
// Read the GitHub token from environment variable
|
||||
$token = getenv('GH_TOKEN');
|
||||
if (!$token) {
|
||||
die("GitHub token not found. Make sure it's set in the environment variable 'GH_TOKEN'.");
|
||||
}
|
||||
|
||||
|
||||
function replaceLatestVersion($previousVersion) {
|
||||
replaceVersionInFile(
|
||||
__DIR__ . './../../../.circleci/config.yml',
|
||||
'/(.\/do download:automate-woo-zip )\d+\.\d+\.\d+/',
|
||||
'${1}' . $previousVersion
|
||||
);
|
||||
}
|
||||
|
||||
function replacePreviousVersion($previousVersion) {
|
||||
replaceVersionInFile(
|
||||
__DIR__ . './../../../.circleci/config.yml',
|
||||
'/(automate_woo_version: )\d+\.\d+\.\d+/',
|
||||
'${1}' . $previousVersion
|
||||
);
|
||||
}
|
||||
|
||||
$repository = 'woocommerce/automatewoo';
|
||||
$downloadCommand = 'download:automate-woo-zip';
|
||||
$configParameterName = 'automate_woo_version';
|
||||
$versionsFilename = 'automate_woo_versions.txt';
|
||||
|
||||
$allVersions = fetchGitHubTags($repository, $token);
|
||||
$stableVersions = filterStableVersions($allVersions);
|
||||
[$latestVersion, $previousVersion] = getLatestAndPreviousMinorMajorVersions($stableVersions);
|
||||
|
||||
echo "Latest Automate Woo version: $latestVersion\n";
|
||||
echo "Previous Automate Woo version: $previousVersion\n";
|
||||
|
||||
if ($latestVersion) {
|
||||
echo "Replacing the latest version in the config file...\n";
|
||||
replaceLatestVersion($latestVersion);
|
||||
} else {
|
||||
echo "No latest version found.\n";
|
||||
}
|
||||
|
||||
if ($previousVersion) {
|
||||
echo "Replacing the previous version in the config file...\n";
|
||||
replacePreviousVersion($previousVersion);
|
||||
} else {
|
||||
echo "No previous version found.\n";
|
||||
}
|
||||
replacePrivatePluginVersion($repository, $downloadCommand, $configParameterName, $versionsFilename);
|
||||
|
Reference in New Issue
Block a user