From c850b6df890ed9fc9efe3687bd7166f1f5aee449 Mon Sep 17 00:00:00 2001 From: Jordan McClintock Date: Wed, 30 Oct 2024 00:20:59 -0400 Subject: [PATCH] feat: enable github tag signing by skipping manually created tags (#22) --- src/platforms/github/release.go | 22 +--------------------- src/platforms/gitlab/release.go | 2 +- src/utils/git.go | 12 ++++++------ 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/src/platforms/github/release.go b/src/platforms/github/release.go index 9dc9254..20e84b1 100644 --- a/src/platforms/github/release.go +++ b/src/platforms/github/release.go @@ -15,7 +15,7 @@ import ( type Platform struct{} func (Platform) TagAndRelease(flavor types.Flavor, tokenVarName string) error { - remoteURL, _, ref, err := utils.GetRepoInfo() + remoteURL, _, err := utils.GetRepoInfo() if err != nil { return err } @@ -40,26 +40,6 @@ func (Platform) TagAndRelease(flavor types.Flavor, tokenVarName string) error { tagName := fmt.Sprintf("%s-%s", flavor.Version, flavor.Name) releaseName := fmt.Sprintf("%s %s", zarfPackageName, tagName) - tag := createGitHubTag(tagName, releaseName, ref.Hash().String()) - - createdTag, _, err := githubClient.Git.CreateTag(context.Background(), owner, repoName, tag) - if err != nil { - return err - } - - // Create a reference for the tag - tagRef := &github.Reference{ - Ref: github.String("refs/tags/" + tagName), - Object: &github.GitObject{ - SHA: createdTag.SHA, - }, - } - - _, _, err = githubClient.Git.CreateRef(context.Background(), owner, repoName, tagRef) - if err != nil { - return err - } - // Create the release release := &github.RepositoryRelease{ TagName: github.String(tagName), diff --git a/src/platforms/gitlab/release.go b/src/platforms/gitlab/release.go index 599c821..5083984 100644 --- a/src/platforms/gitlab/release.go +++ b/src/platforms/gitlab/release.go @@ -14,7 +14,7 @@ import ( type Platform struct{} func (Platform) TagAndRelease(flavor types.Flavor, tokenVarName string) error { - remoteURL, defaultBranch, _, err := utils.GetRepoInfo() + remoteURL, defaultBranch, err := utils.GetRepoInfo() if err != nil { return err } diff --git a/src/utils/git.go b/src/utils/git.go index 5b06997..9027d0b 100644 --- a/src/utils/git.go +++ b/src/utils/git.go @@ -30,24 +30,24 @@ func OpenRepo() (*git.Repository, error) { return git.PlainOpen(".") } -func GetRepoInfo() (remoteURL string, defaultBranch string, ref *plumbing.Reference, err error) { +func GetRepoInfo() (remoteURL string, defaultBranch string, err error) { repo, err := OpenRepo() if err != nil { - return "", "", ref, err + return "", "", err } remote, err := repo.Remote("origin") if err != nil { - return "", "", ref, err + return "", "", err } remoteURL = remote.Config().URLs[0] - ref, err = repo.Head() + ref, err := repo.Head() if err != nil { - return "", "", ref, err + return "", "", err } defaultBranch = ref.Name().Short() - return remoteURL, defaultBranch, ref, nil + return remoteURL, defaultBranch, nil }