Skip to content

Commit 67ba98a

Browse files
authoredSep 26, 2024··
🐛 assets are uploaded to oci registry with every publish (#158)
* added: gitignore IDE specific files Signed-off-by: Danny Eiselt <eiselt@b1-systems.de> * added: check if hash release exists in OCI and reject push Signed-off-by: Danny Eiselt <eiselt@b1-systems.de> --------- Signed-off-by: Danny Eiselt <eiselt@b1-systems.de>
1 parent fe7c931 commit 67ba98a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ releases/
2424
.release
2525
.envrc
2626
dist/
27+
.idea/

‎pkg/cmd/publish.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,16 @@ func (p *PublishOptions) generateRelease(ctx context.Context) error {
347347
func pushReleaseAssets(ctx context.Context, pusher assetsclient.Pusher, clusterStackReleasePath, releaseName string, annotations map[string]string) error {
348348
releaseAssets := []assetsclient.ReleaseAsset{}
349349

350+
ociclient, err := oci.NewClient()
351+
if err != nil {
352+
return fmt.Errorf("error creating oci client: %w", err)
353+
}
354+
355+
if ociclient.FoundRelease(ctx, releaseName) {
356+
fmt.Printf("release tag \"%s\" found in oci registry. aborting push\n", releaseName)
357+
return nil
358+
}
359+
350360
files, err := os.ReadDir(clusterStackReleasePath)
351361
if err != nil {
352362
return fmt.Errorf("failed to read directory %s: %w", clusterStackReleasePath, err)
@@ -365,11 +375,6 @@ func pushReleaseAssets(ctx context.Context, pusher assetsclient.Pusher, clusterS
365375
return fmt.Errorf("failed to push release assets to oci registry: %w", err)
366376
}
367377

368-
ociclient, err := oci.NewClient()
369-
if err != nil {
370-
return fmt.Errorf("error creating oci client: %w", err)
371-
}
372-
373378
fmt.Printf("successfully pushed clusterstack release: %s:%s \n", ociclient.Repository.Reference.String(), releaseName)
374379
return nil
375380
}

0 commit comments

Comments
 (0)
Please sign in to comment.