Skip to content

Commit

Permalink
🐛 assets are uploaded to oci registry with every publish (#158)
Browse files Browse the repository at this point in the history
* added: gitignore IDE specific files

Signed-off-by: Danny Eiselt <[email protected]>

* added: check if hash release exists in OCI and reject push

Signed-off-by: Danny Eiselt <[email protected]>

---------

Signed-off-by: Danny Eiselt <[email protected]>
  • Loading branch information
DEiselt authored Sep 26, 2024
1 parent fe7c931 commit 67ba98a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ releases/
.release
.envrc
dist/
.idea/
15 changes: 10 additions & 5 deletions pkg/cmd/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

0 comments on commit 67ba98a

Please sign in to comment.