mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Include version bump in release script (#9751)
* Include version bump in release script * Commit message * fix whitespace
This commit is contained in:
@@ -217,17 +217,9 @@ class GitHub
|
|||||||
|
|
||||||
public function createRelease()
|
public function createRelease()
|
||||||
{
|
{
|
||||||
// push the changelog
|
// push the changelog and version bump
|
||||||
$existing = \Requests::get($this->github . '/contents/' . $this->file, $this->getHeaders());
|
$this->pushFileContents($this->file, file_get_contents($this->file), "Changelog for $this->tag");
|
||||||
$existing_sha = json_decode($existing->body)->sha;
|
$updated_sha = $this->pushVersionBump();
|
||||||
|
|
||||||
$updated = Requests::put($this->github . '/contents/' . $this->file, $this->getHeaders(), json_encode([
|
|
||||||
'message' => 'Changelog for ' . $this->tag,
|
|
||||||
'content' => base64_encode(file_get_contents($this->file)),
|
|
||||||
'sha' => $existing_sha,
|
|
||||||
]));
|
|
||||||
|
|
||||||
$updated_sha = json_decode($updated->body)->commit->sha;
|
|
||||||
|
|
||||||
// make sure the markdown is built
|
// make sure the markdown is built
|
||||||
if (empty($this->markdown)) {
|
if (empty($this->markdown)) {
|
||||||
@@ -268,4 +260,33 @@ class GitHub
|
|||||||
$this->writeChangeLog();
|
$this->writeChangeLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function pushVersionBump()
|
||||||
|
{
|
||||||
|
$version_file = 'LibreNMS/Util/Version.php';
|
||||||
|
$contents = file_get_contents(base_path($version_file));
|
||||||
|
$updated_contents = preg_replace("/const VERSION = '[^']+';/", "const VERSION = '$this->tag';", $contents);
|
||||||
|
|
||||||
|
return $this->pushFileContents($version_file, $updated_contents, "Bump version to $this->tag");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $file Path in git repo
|
||||||
|
* @param string $contents new file contents
|
||||||
|
* @param string $message The commit message
|
||||||
|
* @return \Requests_Response
|
||||||
|
*/
|
||||||
|
private function pushFileContents($file, $contents, $message)
|
||||||
|
{
|
||||||
|
$existing = \Requests::get($this->github . '/contents/' . $file, $this->getHeaders());
|
||||||
|
$existing_sha = json_decode($existing->body)->sha;
|
||||||
|
|
||||||
|
$updated = Requests::put($this->github . '/contents/' . $file, $this->getHeaders(), json_encode([
|
||||||
|
'message' => $message,
|
||||||
|
'content' => base64_encode($contents),
|
||||||
|
'sha' => $existing_sha,
|
||||||
|
]));
|
||||||
|
|
||||||
|
return json_decode($updated->body)->commit->sha;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user