From e732f97523e3907c7fe8785baba38f159059ecfa Mon Sep 17 00:00:00 2001 From: xdu31 Date: Mon, 12 Feb 2024 22:42:01 -0800 Subject: [PATCH 1/2] Handle creation of RELEASE file in new Go version Release --- .../pkg/eksGoRelease/githubRelease.go | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go b/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go index 42cef76b3..d5b56078e 100644 --- a/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go +++ b/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go @@ -161,20 +161,24 @@ func bumpRelease(gClient git.Client, r *Release) error { content, err := gClient.ReadFile(releasePath) if err != nil { - logger.Error(err, "Reading file", "file", releasePath) - return err - } - // Check if there is a new line character at the end of the file, if so take all but the newline - if content[len(content)-1:] == "\n" { - content = content[0 : len(content)-1] - } - cr, err := strconv.Atoi(content) - if err != nil { - logger.Error(err, "Converting current release to int") - return err + if !strings.Contains(err.Error(), "file not found") { + logger.Error(err, "Reading file", "file", releasePath) + return err + } + r.Release = 0 + } else { + // Check if there is a new line character at the end of the file, if so take all but the newline + if content[len(content)-1:] == "\n" { + content = content[0 : len(content)-1] + } + cr, err := strconv.Atoi(content) + if err != nil { + logger.Error(err, "Converting current release to int") + return err + } + // Increment release + r.Release = cr + 1 } - // Increment release - r.Release = cr + 1 logger.V(4).Info("release bumped to", "release", r.Release) return nil @@ -187,7 +191,13 @@ func updateRelease(gClient git.Client, r *Release) error { releaseContent := fmt.Sprintf("%d", r.ReleaseNumber()) logger.V(4).Info("Update RELEASE", "path", releasePath, "content", releaseContent) if err := gClient.ModifyFile(releasePath, []byte(releaseContent)); err != nil { - return err + if !strings.Contains(err.Error(), "file not found") { + return err + } + releaseContent = fmt.Sprintf("%d", 0) + if err := gClient.CreateFile(releasePath, []byte(releaseContent)); err != nil { + return err + } } if err := gClient.Add(releasePath); err != nil { logger.Error(err, "git add", "file", releasePath) From 91609eed95b9cfc252c06109d2a8d4d3c82fe1ac Mon Sep 17 00:00:00 2001 From: xdu31 Date: Wed, 14 Feb 2024 12:51:25 -0800 Subject: [PATCH 2/2] handle creation of SPECS/golang.spec instead of SOURCES/golang.spec --- .../pkg/eksGoRelease/githubRelease.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go b/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go index d5b56078e..3e7b71279 100644 --- a/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go +++ b/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/githubRelease.go @@ -279,7 +279,7 @@ func updateGoSpec(gClient git.Client, r *Release) error { func addTempFilesForNewMinorVersion(gClient git.Client, r *Release) error { // Add golang.spec - specFilePath := fmt.Sprintf(rpmSourcePathFmt, constants.EksGoProjectPath, r.GoMinorVersion(), goSpecFile) + specFilePath := fmt.Sprintf(specPathFmt, constants.EksGoProjectPath, r.GoMinorVersion(), goSpecFile) rf, err := gClient.ReadFile(newReleaseFile) if err != nil { logger.Error(err, "Reading newRelease.txt file")