Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Skip repositories we've already tagged #260

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Model/Modules/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,20 @@ public function getTags()
return $this->tags;
}

/**
* Check if a tag exists in the repository
*/
public function hasTag(string $tag): bool
{
$repo = $this->getRepository();
if ($this->getProject()->getFetchTags()) {
// Fetch remote tags from origin first
$repo->run('fetch', ['--tags']);
}

return (bool) $repo->run('tag', ['--list', $tag]);
}

/**
* Tag this module
*
Expand Down
14 changes: 14 additions & 0 deletions src/Steps/Release/PublishRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ protected function releaseLibrary(
die();
}

if ($this->hasTag($releasePlanNode)) {
$this->log($output, "Library <info>{$name}</info> has already been released. <comment>Skipping.</comment>");
return;
}

$versionName = $releasePlanNode->getVersion()->getValue();
$this->log($output, "Releasing library <info>{$name}</info> at version <info>{$versionName}</info>");

Expand Down Expand Up @@ -163,6 +168,15 @@ protected function publishTag(OutputInterface $output, LibraryRelease $releasePl
$this->log($output, 'Tagging complete');
}

/**
* Check if this release node already has the tag we're going to release
*/
protected function hasTag(LibraryRelease $releasePlan): bool
{
$library = $releasePlan->getLibrary();
$tag = $releasePlan->getVersion()->getValue();
return $library->hasTag($tag);
}

/**
* Update github release notes via github API
Expand Down
Loading