From c612f1e54b733f0354ad67320e3ac034a021faef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Tue, 19 Sep 2023 17:40:26 +0200 Subject: [PATCH 1/2] create worktree before adding packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gaël Goinvic --- pkg/releaser/releaser.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/releaser/releaser.go b/pkg/releaser/releaser.go index 7974647e..d2932899 100644 --- a/pkg/releaser/releaser.go +++ b/pkg/releaser/releaser.go @@ -310,6 +310,12 @@ func (r *Releaser) CreateReleases() error { 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) if err != nil { @@ -346,12 +352,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 From dc494fd84b1d6d42f24ec75998a6d58dd942c2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= Date: Tue, 19 Sep 2023 18:07:26 +0200 Subject: [PATCH 2/2] push after commiting all artifacts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gaël Goinvic --- pkg/releaser/releaser.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/releaser/releaser.go b/pkg/releaser/releaser.go index d2932899..b4f5c8f9 100644 --- a/pkg/releaser/releaser.go +++ b/pkg/releaser/releaser.go @@ -309,7 +309,6 @@ 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 @@ -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 }