PHP Classes

File: .changelog

Recommend this page to a friend!
  Classes of Marco Cesarato   PHP Malware Scanner Free Tool   .changelog   Download  
File: .changelog
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Malware Scanner Free Tool
Scan PHP files to find malicious code
Author: By
Last change: Update of .changelog
Date: 2 years ago
Size: 2,061 bytes
 

Contents

Class file image Download
<?php

namespace ConventionalChangelog;

use
ConventionalChangelog\Git\Repository;
use
ConventionalChangelog\Helper\SemanticVersion;

$releaseMessagePrefix = 'chore(release): ';

return [
   
// Ignore changelogs
   
'ignorePatterns' => [
       
'/' . preg_quote($releaseMessagePrefix, '/') . '.*/i',
       
'/chore\(changelog\)[:].*/i',
    ],
   
'releaseCommitMessageFormat' => "{$releaseMessagePrefix}{{currentTag}}",
   
'postRun' => function () use ($releaseMessagePrefix) {
       
$lastTag = Repository::getLastTag();
       
$lastTagCommit = Repository::getLastTagCommit();
       
$lastCommit = Repository::getLastCommit();

        if (
$lastTagCommit !== $lastCommit) {
            return;
        }

       
$binFile = __DIR__ . '/src/Scanner.php';
       
$distFile = __DIR__ . '/dist/scanner';
       
$versionFile = __DIR__ . '/dist/version';
       
$readmeFile = __DIR__ . '/README.md';
       
$semverRegex = SemanticVersion::PATTERN;

       
// Get version
       
$version = new SemanticVersion($lastTag);
       
$versionString = $version->getVersion();

       
// Update version on readme
       
$readme = file_get_contents($readmeFile);
       
$readme = preg_replace("/(https:\/\/img\.shields\.io\/badge\/version)-({$semverRegex})-/m", '$1-' . $versionString . '-', $readme);
       
file_put_contents($readmeFile, $readme);

       
// Update version on bin
       
$bin = file_get_contents($binFile);
       
$bin = preg_replace("/(public static \\\$version = )('{$semverRegex})'/m", '$1\'' . $version->getVersion() . '\'', $bin);
       
file_put_contents($binFile, $bin);

       
// Update version file
       
file_put_contents($versionFile, $versionString);

       
// Build
       
include __DIR__ . '/bin/build';

       
// Delete tag
       
Repository::deleteTag($lastTag);

       
// Commit and tag
       
$message = $releaseMessagePrefix . $version->getVersion();
       
Repository::commit($message, [$binFile, $readmeFile, $versionFile, $distFile], true, true, true);
       
Repository::tag($lastTag);
    },
];