Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Golang Release go tool #1112

Merged
merged 40 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0bc5c0c
add structure for eksGo release object
rcrozean Aug 8, 2023
800ddd6
stash for go release automation
rcrozean Aug 10, 2023
e6c4e20
update goReleas pkg
rcrozean Aug 14, 2023
fcee6a9
remove projectUpdater from this pr
rcrozean Aug 14, 2023
a18f619
update README and Makefile
rcrozean Aug 14, 2023
359d374
remove binary file and update makefile make command
rcrozean Aug 14, 2023
4c6de61
fix typo in README
rcrozean Aug 14, 2023
2f69748
add artifact path to eksGoRelease object
rcrozean Aug 14, 2023
17f36f4
add openrepo for in mem editing
rcrozean Aug 15, 2023
709a141
add in memory edit functions to git client
rcrozean Aug 17, 2023
dec6fee
use in memory git client to make go minor release creation
rcrozean Aug 17, 2023
79ebf26
add pr creator and commit files for eksGoRelease
rcrozean Aug 18, 2023
8c4ce01
add ability to update upstream released patch versions
rcrozean Aug 18, 2023
8cd7f24
update readme fmt to use correct release values
rcrozean Aug 21, 2023
f14fd50
add email to build
rcrozean Sep 6, 2023
9ea59a1
update to work email
rcrozean Sep 6, 2023
0e65137
bump gitTimeout to give more time for clone
rcrozean Sep 8, 2023
dfc95a9
format structured readme for go projects
rcrozean Sep 13, 2023
f7d2859
update readme fmt
rcrozean Sep 14, 2023
39c1080
finish new release, update, and tidy up backport
rcrozean Sep 15, 2023
3abc7ef
change naming to be consistent
rcrozean Sep 15, 2023
8c55b7f
update naming to match functions
rcrozean Sep 15, 2023
4be5348
update prs to open against main repo
rcrozean Sep 15, 2023
9a4ef28
remove unfinished commands
rcrozean Sep 15, 2023
8d1767e
fix unchecked err
rcrozean Sep 15, 2023
5baddfa
remove used golang spec functions
rcrozean Sep 15, 2023
25343d1
add executables and backport patches start
rcrozean Sep 18, 2023
07a33e2
more automation!
rcrozean Oct 5, 2023
6bb591d
error check createReleasePR
rcrozean Oct 6, 2023
dfd2cf9
restructuring
rcrozean Oct 12, 2023
ca122ec
refine commands
rcrozean Oct 12, 2023
f9b7fe8
update git ignore for tools binaries
rcrozean Oct 13, 2023
1545e3c
organize updates
rcrozean Oct 19, 2023
5b0f5ea
update readme generation for new minor versions
rcrozean Oct 23, 2023
9c2c2ef
refactor
rcrozean Oct 23, 2023
f7751b4
update eksGoRelease, READMEs
rcrozean Oct 24, 2023
3ff8fa5
remove unused file
rcrozean Oct 24, 2023
999281d
add release command to bump release files
rcrozean Oct 24, 2023
7fc3feb
update golang readme with release command
rcrozean Oct 24, 2023
85be3d2
fix golang url and artifacts
rcrozean Oct 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ eks-distro-base/check-update/
eks-distro-base/*-pushed
eks-distro-base/make-tests/actual/
builder-base/tmp/
tools/eksDistroBuildToolingOpsTools/bin

35 changes: 29 additions & 6 deletions projects/golang/go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,47 @@ and executing the Kubernetes conformance tests.

EKS Go RPMs are publicly available; see [Access EKS Go Artifacts](#access-eks-go-artifacts).

## New Minor Releases and Patch Releases
### Adding Minor Version
1. Build the CLI tool by opening [eksDistroBuildToolingOpsTools](/tools/eksDistroBuildToolingOpsTools/) and run `make build-eksGoRelease`
2. Run `bin/$(GO_OS)/$(GO_ARCH)/eksGoRelease new -u <github user> -e <github email> --eksGoReleases=<new minor version of golang>`
1. example `bin/darwing/amd64/eksGoRelease new -u rcrozean -e [email protected] --eksGoReleases=1.22.0`
3. Check the PRs and update changelogs before requesting approval.
4. Once the PRs have been merged and post-submits finish and pass run `bin/$(GO_OS)/$(GO_ARCH)/eksGoRelease release -u <github user> -e <github email> --eksGoReleases=<version of EKS Go just updated>` to bump the release files and publish the new artifacts
1. example `bin/darwing/amd64/eksGoRelease release -u rcrozean -e [email protected] --eksGoReleases=1.20.11,1.21.4`

### Updating Upstream Supported Patch Versions
1. Build the CLI tool by opening [eksDistroBuildToolingOpsTools](/tools/eksDistroBuildToolingOpsTools/) and run `make build-eksGoRelease`
2. Run `bin/$(GO_OS)/$(GO_ARCH)/eksGoRelease update -u <github user> -e <github email> --eksGoReleases=<new minor version of golang>`
1. example `bin/darwing/amd64/eksGoRelease update -u rcrozean -e [email protected] --eksGoReleases=1.20.11,1.21.4`
3. Check the PRs and update changelogs before requesting approval.
4. Once the PRs have been merged and post-submits finish and pass run `bin/$(GO_OS)/$(GO_ARCH)/eksGoRelease release -u <github user> -e <github email> --eksGoReleases=<version of EKS Go just updated>` to bump the release files and publish the new artifacts
1. example `bin/darwing/amd64/eksGoRelease release -u rcrozean -e [email protected] --eksGoReleases=1.20.11,1.21.4`

### Updating Upstream Unsupported Patch Versions
Follow [Updating Upstream Supported Patch Versions](#updating-upstream-supported-patch-versions) steps. There is a WIP cli command located at [patchEksGo.go](../../../tools/eksDistroBuildToolingOpsTools/cmd/eksGoRelease/cmd/patchEksGo.go) and the tooling for the command [createPatch.go](../../../tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease/createPatch.go).

TODO for WIP:
- Add `git cherry-pick`, `git am`, and `git format-patch` to [eksDistroBuildToolingOpsTools/pkg/git](/tools/eksDistroBuildToolingOpsTools/pkg/git) or to [go-git](https://github.com/go-git/go-git/blob/master/COMPATIBILITY.md)
- Add logic to apply patches, cherry pick [upstream's](https://github.com/golang/go) fix, and format patch to [createPatch.go](/tools/eksDistroBuildToolingOpsTools/pkg/eksGoReleases/createPatch.go)

## Supported Versions
EKS currently supports the following Golang versions:
- [`v1.19`](./1.19/GIT_TAG)
- [`v1.20`](./1.20/GIT_TAG)
- [`v1.21`](./1.21/GIT_TAG)
- [`v1.20`](./1.20/GIT_TAG)
- [`v1.19`](./1.19/GIT_TAG)


## Deprecated Versions
- [`v1.15`](./1.15/GIT_TAG)
- [`v1.16`](./1.16/GIT_TAG)
- [`v1.17`](./1.16/GIT_TAG)
- [`v1.18`](./1.18/GIT_TAG)
- [`v1.17`](./1.16/GIT_TAG)
- [`v1.16`](./1.16/GIT_TAG)
- [`v1.15`](./1.15/GIT_TAG)

For versions of `EKS-Go` EKS Distro has [discontinued support](#deprecated-versions) for, there are no plans for removing artifacts from the public ECR. EKS-Distro
won’t be backporting any upcoming golang security fixes for these versions.

**Due to the increased security risk this poses, it is HIGHLY recommended that users of `EKS-GO v1.15 - v1.17` update to a supported version of EKS-Go (v1.18+) as soon as possible.**
**Due to the increased security risk this poses, it is HIGHLY recommended that users of `EKS-GO v1.15 - v1.18` update to a supported version of EKS-Go (v1.19+) as soon as possible.**


## Upstream Patches
Expand Down
5 changes: 5 additions & 0 deletions tools/eksDistroBuildToolingOpsTools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ EKS_GO_TOOLS_BINARY_NAME=eksGoTools
CONSUMER_UPDATER_BINARY_NAME=consumerUpdater
EKS_PROW_PLUGIN_BINARY_NAME=eksDistroOpsProwPlugin
EKS_DISTRO_PROW_PLUGIN_ECR_NAME=eks-distro-ops-tool
GOLANG_RELEASE_BINARY_NAME=eksGoRelease

.PHONY: build-eks-go-tools
build-eks-go-tools:
Expand All @@ -33,6 +34,10 @@ build-consumerUpdater: unit-test lint
build-binary-eksDistroOpsProwPlugin:
./scripts/create_binaries.sh ${GOLANG_VERSION} ${GO_OS} ${GO_ARCH} ${GIT_VERSION} ${EKS_PROW_PLUGIN_BINARY_NAME}

.PHONY: build-eksGoRelease
build-eksGoRelease: unit-test
CGO_ENABLED=0 GOOS=$(GO_OS) GOARCH=$(GO_ARCH) go build -ldflags "-X github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/pkg/version.gitVersion=$(GIT_VERSION) -s -w -extldflags -static" -o bin/$(GO_OS)/$(GO_ARCH)/$(GOLANG_RELEASE_BINARY_NAME) github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/cmd/$(GOLANG_RELEASE_BINARY_NAME)

.PHONY: build-eksDistroOpsProwPlugin
build-eksDistroOpsProwPlugin: build-binary-eksDistroOpsProwPlugin local-images-eksDistroOpsProwPlugin

Expand Down
29 changes: 29 additions & 0 deletions tools/eksDistroBuildToolingOpsTools/cmd/eksGoRelease/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## EKS Go Release Tool
The EKS Go Release Tool is intended as a home for all automation used to release, update, and patch EKS Go with new releases.
It is intended to eventually replace eksGoTool.

### Using the Tool
use `eksGoRelease --help` for up-to-date usage

The tool has an `release` command which creates new minor version release structure and files.
The tool has an `update` command which updates upstream supported versions for new patch releases.

The `release` command accepts a EKS Go release version via the flag `eksGoRelease`.
For example to release a new version of eksGo `1.21.0`
you would run the following:

```shell
eksGoRelease release --eksGoReleases=1.21.0
```

The `update` command accepts a comma-seperated list of EKS Go release versions via the flag `eksGoRelease`.
Updates are run for each given release version. For example, to run updaters for the EKS Go release `1.20.2` & `1.19.3`,
you would run the following:

```shell
eksGoRelease update --eksGoReleases=1.20.2,1.19.3
```

### Building the Tool
To build the Consumer Updater binary, run the build make target `make build-eksGoRelease`
from the root of the Ops Tool. This will produce a binary in `tools/eksDistroBuildToolingOpsTools/bin/$GOOS/$GOARCH/eksGoRelease`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease"
)

var newCmd = &cobra.Command{
Use: "new",
Short: "Release a new minor version of EKS Go",
Long: "Tool to release a new minor version of EKS Go",
RunE: func(cmd *cobra.Command, args []string) error {
var eksGoReleases []*eksGoRelease.Release
for _, v := range viper.GetStringSlice(eksGoReleasesFlag) {
r, err := eksGoRelease.NewEksGoReleaseObject(v)
if err != nil {
return err
}
eksGoReleases = append(eksGoReleases, r)
}

for _, r := range eksGoReleases {
err := eksGoRelease.NewMinorRelease(cmd.Context(), r, viper.GetBool(dryrunFlag), viper.GetString(emailFlag), viper.GetString(userFlag))
if err != nil {
return fmt.Errorf("you have failed this automation: %w", err)
}
}
return nil
},
}

func init() {
rootCmd.AddCommand(newCmd)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease"
)

var backportCmd = &cobra.Command{
Use: "patch",
Short: "Cherrypick a patch to versions of EKS Go",
Long: "Tool to create PR for updaing EKS Go versions that require a patch applied",
RunE: func(cmd *cobra.Command, args []string) error {
var eksGoReleases []*eksGoRelease.Release
for _, v := range viper.GetStringSlice(eksGoReleasesFlag) {
r, err := eksGoRelease.NewEksGoReleaseObject(v)
if err != nil {
return err
}
eksGoReleases = append(eksGoReleases, r)
}

for _, r := range eksGoReleases {
err := eksGoRelease.BackportToRelease(cmd.Context(), r, viper.GetBool(dryrunFlag), "CVE", "HASH", viper.GetString(emailFlag), viper.GetString(userFlag))
if err != nil {
return fmt.Errorf("you have failed this automation: %w", err)
}
}
return nil
},
}

func init() {
rootCmd.AddCommand(backportCmd)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease"
)

var releaseCmd = &cobra.Command{
Use: "release",
Short: "Release EKS Go",
Long: "Tool to create PRs for releasing EKS Go versions",
RunE: func(cmd *cobra.Command, args []string) error {
var eksGoReleases []*eksGoRelease.Release
for _, v := range viper.GetStringSlice(eksGoReleasesFlag) {
r, err := eksGoRelease.NewEksGoReleaseObject(v)
if err != nil {
return err
}
eksGoReleases = append(eksGoReleases, r)
}

for _, r := range eksGoReleases {
err := eksGoRelease.ReleaseArtifacts(cmd.Context(), r, viper.GetBool(dryrunFlag), viper.GetString(emailFlag), viper.GetString(userFlag))
if err != nil {
return fmt.Errorf("you have failed this automation: %w", err)
}
}
return nil
},
}

func init() {
rootCmd.AddCommand(releaseCmd)
}
59 changes: 59 additions & 0 deletions tools/eksDistroBuildToolingOpsTools/cmd/eksGoRelease/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package cmd

import (
"context"
"fmt"
"log"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/pkg/logger"
)

const (
eksGoReleasesFlag = "eksGoReleases"
dryrunFlag = "dryrun"
userFlag = "user"
emailFlag = "email"
)

var (
rootCmd = &cobra.Command{
Use: "eksGoRelease",
Short: "Amazon EKS Go Release and automation commands",
rcrozean marked this conversation as resolved.
Show resolved Hide resolved
Long: `Tools for updating and releasing EKS Go`,
PersistentPreRun: rootPersistentPreRun,
}
)

func init() {
rootCmd.PersistentFlags().IntP("verbosity", "v", 0, "Set the log level verbosity")
rootCmd.PersistentFlags().StringSlice(eksGoReleasesFlag, []string{}, "EKS Go releases to update")
rootCmd.PersistentFlags().BoolP(dryrunFlag, "d", false, "run without creating PR")
rootCmd.PersistentFlags().StringP(emailFlag, "e", "", "github email for git functions")
rootCmd.PersistentFlags().StringP(userFlag, "u", "", "github username for git functions")

// Bind config flags to viper
if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil {
log.Fatalf("failed to bind persistent flags for root: %v", err)
}
}

func rootPersistentPreRun(cmd *cobra.Command, args []string) {
if err := initLogger(); err != nil {
log.Fatal(err)
}
}

func initLogger() error {
if err := logger.InitZap(viper.GetInt("verbosity")); err != nil {
return fmt.Errorf("failed init zap logger in root command: %v", err)
}

return nil
}

func Execute() error {
return rootCmd.ExecuteContext(context.Background())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/pkg/eksGoRelease"
)

var updateCmd = &cobra.Command{
Use: "update",
Short: "Update new patch versions of EKS Go",
Long: "Tool to create PR for updaing EKS Go versions supported by upstream when a patch version is released",
RunE: func(cmd *cobra.Command, args []string) error {
var eksGoReleases []*eksGoRelease.Release
for _, v := range viper.GetStringSlice(eksGoReleasesFlag) {
r, err := eksGoRelease.NewEksGoReleaseObject(v)
if err != nil {
return err
}
eksGoReleases = append(eksGoReleases, r)
}

for _, r := range eksGoReleases {
err := eksGoRelease.UpdateVersion(cmd.Context(), r, viper.GetBool(dryrunFlag), viper.GetString(emailFlag), viper.GetString(userFlag))
if err != nil {
return fmt.Errorf("you have failed this automation: %w", err)
}
}
return nil
},
}

func init() {
rootCmd.AddCommand(updateCmd)
}
22 changes: 22 additions & 0 deletions tools/eksDistroBuildToolingOpsTools/cmd/eksGoRelease/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"os"
"os/signal"
"syscall"

"github.com/aws/eks-distro-build-tooling/tools/eksDistroBuildToolingOpsTools/cmd/eksGoRelease/cmd"
)

func main() {
sigChannel := make(chan os.Signal, 1)
signal.Notify(sigChannel, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigChannel
os.Exit(-1)
}()
if cmd.Execute() == nil {
os.Exit(0)
}
os.Exit(-1)
}
34 changes: 25 additions & 9 deletions tools/eksDistroBuildToolingOpsTools/pkg/constants/constants.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
package constants

const (
AwsOrgName = "aws"
EksdBuildToolingRepoName = "eks-distro-build-tooling"
EksDistroBotName = "eks-distro-bot"
EksDistroPrBotName = "eks-distro-pr-bot"
AwsOrgName = "aws"
EksdBuildToolingRepoName = "eks-distro-build-tooling"
EksDistroBotName = "eks-distro-bot"
EksDistroPrBotName = "eks-distro-pr-bot"
OwnerWriteallReadOctal = 0644
SemverRegex = `[0-9]+\.[0-9]+\.[0-9]+`
AllowAllFailRespTemplate = "@%s only [%s](https://github.com/orgs/%s/people) org members may request may trigger automated issues. You can still create the issue manually."
GitTag = "GIT_TAG"
Release = "RELEASE"
Readme = "README.md"

// Github Constants
GolangOrgName = "golang"
GoRepoName = "go"
GoRepoUrl = "https://github.com/golang/go.git"

// EKS Go Constants
EksGoRepoUrl = "https://github.com/%s/eks-distro-build-tooling.git"
EksGoProjectPath = "projects/golang/go"
EksGoAmdBuildUrl = "https://prow.eks.amazonaws.com/badge.svg?jobs=golang-%d-%d-tooling-postsubmit"
EksGoArmBuildUrl = "https://prow.eks.amazonaws.com/badge.svg?jobs=golang-%d-%d-ARM64-PROD-tooling-postsubmit"
EksGoSupportedVersionsPath = "projects/golang/go/MAINTAINED_EOL_VERSIONS"
GolangOrgName = "golang"
GoRepoName = "go"
OwnerWriteallReadOctal = 0644
SemverRegex = `[0-9]+\.[0-9]+\.[0-9]+`
AllowAllFailRespTemplate = "@%s only [%s](https://github.com/orgs/%s/people) org members may request may trigger automated issues. You can still create the issue manually."
EksGoArtifactUrl = "https://distro.eks.amazonaws.com/golang-go%d.%d.%d/releases/%d/%s/%s/%s"
EksGoTargzArtifactFmt = "go%d.%d.%d.linux-%s.tar.gz"
EksGoRpmArtifactFmt = "golang-%d.%d.%d-%d.amzn2.eks.%s.rpm"
EksGoNoarchRpmArtifactFmt = "golang-src-%d.%d.%d-%d.amzn2.eks.%s.rpm"
)
Loading
Loading