diff --git a/.gitignore b/.gitignore index 0d642bd1..b5713230 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ releases/ .release .envrc dist/ +.idea/ \ No newline at end of file diff --git a/pkg/cmd/publish.go b/pkg/cmd/publish.go index 7b635921..9b511c64 100644 --- a/pkg/cmd/publish.go +++ b/pkg/cmd/publish.go @@ -347,6 +347,16 @@ func (p *PublishOptions) generateRelease(ctx context.Context) error { func pushReleaseAssets(ctx context.Context, pusher assetsclient.Pusher, clusterStackReleasePath, releaseName string, annotations map[string]string) error { releaseAssets := []assetsclient.ReleaseAsset{} + ociclient, err := oci.NewClient() + if err != nil { + return fmt.Errorf("error creating oci client: %w", err) + } + + if ociclient.FoundRelease(ctx, releaseName) { + fmt.Printf("release tag \"%s\" found in oci registry. aborting push\n", releaseName) + return nil + } + files, err := os.ReadDir(clusterStackReleasePath) if err != nil { return fmt.Errorf("failed to read directory %s: %w", clusterStackReleasePath, err) @@ -365,11 +375,6 @@ func pushReleaseAssets(ctx context.Context, pusher assetsclient.Pusher, clusterS return fmt.Errorf("failed to push release assets to oci registry: %w", err) } - ociclient, err := oci.NewClient() - if err != nil { - return fmt.Errorf("error creating oci client: %w", err) - } - fmt.Printf("successfully pushed clusterstack release: %s:%s \n", ociclient.Repository.Reference.String(), releaseName) return nil }