diff --git a/src/Model/Modules/Library.php b/src/Model/Modules/Library.php
index c601d8e..d55230b 100644
--- a/src/Model/Modules/Library.php
+++ b/src/Model/Modules/Library.php
@@ -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
*
diff --git a/src/Steps/Release/PublishRelease.php b/src/Steps/Release/PublishRelease.php
index 22d8e83..3d98149 100644
--- a/src/Steps/Release/PublishRelease.php
+++ b/src/Steps/Release/PublishRelease.php
@@ -118,6 +118,11 @@ protected function releaseLibrary(
die();
}
+ if ($this->hasTag($releasePlanNode)) {
+ $this->log($output, "Library {$name} has already been released. Skipping.");
+ return;
+ }
+
$versionName = $releasePlanNode->getVersion()->getValue();
$this->log($output, "Releasing library {$name} at version {$versionName}");
@@ -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