diff --git a/pkg/releaser/releaser.go b/pkg/releaser/releaser.go index 7974647e..b4f5c8f9 100644 --- a/pkg/releaser/releaser.go +++ b/pkg/releaser/releaser.go @@ -309,6 +309,11 @@ func (r *Releaser) CreateReleases() error { if len(packages) == 0 { return errors.Errorf("no charts found at %s", r.config.PackagePath) } + worktree, err := r.git.AddWorktree("", r.config.Remote+"/"+r.config.PagesBranch) + if err != nil { + return err + } + defer r.git.RemoveWorktree("", worktree) //nolint: errcheck for _, p := range packages { ch, err := loader.LoadFile(p) @@ -346,12 +351,6 @@ func (r *Releaser) CreateReleases() error { } if r.config.PackagesWithIndex { - worktree, err := r.git.AddWorktree("", r.config.Remote+"/"+r.config.PagesBranch) - if err != nil { - return err - } - defer r.git.RemoveWorktree("", worktree) //nolint: errcheck - pkgTargetPath := filepath.Join(worktree, filepath.Base(p)) if err := copyFile(p, pkgTargetPath); err != nil { return err @@ -364,13 +363,13 @@ func (r *Releaser) CreateReleases() error { if err := r.git.Commit(worktree, fmt.Sprintf("Publishing chart package for %s", releaseName)); err != nil { return err } - - if err := r.pushToPagesBranch(worktree); err != nil { - return err - } } } + if err := r.pushToPagesBranch(worktree); err != nil { + return err + } + return nil }