-
Notifications
You must be signed in to change notification settings - Fork 288
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
added eks-a-releaser files #8617
Open
ibix16
wants to merge
21
commits into
aws:main
Choose a base branch
from
ibix16:eks-a-releaser-push
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,793
−297
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e649269
added eks-a-releaser files
ibix16 4c4a633
Update go-build-binary.yml
ibix16 98146b4
Update go-build-binary.yml
ibix16 ea696d0
Update go-build-binary.yml
ibix16 99cc208
Update create-branch.go
ibix16 af7bc68
Update create-release.go
ibix16 a8de664
Update prod-bundle.go
ibix16 3af8b06
Update prod-cli.go
ibix16 96e94b1
Update stage-bundle.go
ibix16 77274ec
Update stage-cli.go
ibix16 35093a1
Update update-homebrew.go
ibix16 0e734de
Update update-makefile.go
ibix16 78e7126
Update update-prow.go
ibix16 ab6cc3d
Update go.mod
ibix16 86bfcf7
Update go-build-binary.yml
ibix16 779b0f6
Update go-build-binary.yml
ibix16 6da1f67
Update go.mod
ibix16 7f16939
Update go-build-binary.yml
ibix16 8f8e575
Update go-build-binary.yml
ibix16 3636b7a
Update go-build-binary.yml
ibix16 1d8bb12
Update create-release.go
ibix16 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
release/buildspecs/eks-a-releaser-buildspec/create-branch.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger create-branch |
8 changes: 8 additions & 0 deletions
8
release/buildspecs/eks-a-releaser-buildspec/create-release.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger create-release |
14 changes: 14 additions & 0 deletions
14
release/buildspecs/eks-a-releaser-buildspec/go-build-binary.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: 0.2 | ||
|
||
phases: | ||
pre_build: | ||
commands: | ||
- ./release/scripts/setup.sh | ||
|
||
build: | ||
commands: | ||
- make dev-release -C release | ||
|
||
artifacts: | ||
files: | ||
- release/bin/eks-anywhere-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger prod-bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger prod-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger stage-bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger stage-cli |
8 changes: 8 additions & 0 deletions
8
release/buildspecs/eks-a-releaser-buildspec/update-homebrew.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger update-homebrew |
8 changes: 8 additions & 0 deletions
8
release/buildspecs/eks-a-releaser-buildspec/update-makefile.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger update-makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 0.2 | ||
env: | ||
secrets-manager: | ||
SECRET_PAT: "github-eks-distro-pr-bot:github-token" | ||
phases: | ||
build: | ||
commands: | ||
- ${CODEBUILD_SRC_DIR}/release/bin/eks-anywhere-release trigger update-prow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
package cmd | ||
|
||
/* | ||
what does this command do? | ||
if release type is "minor" then : | ||
creates a new release branch in upstream eks-a repo based off "main" & build tooling repo | ||
creates a new release branch in forked repo based off newly created release branch in upstream repo | ||
else : | ||
creates a new patch branch in users forked repo based off latest release branch upstream | ||
*/ | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/google/go-github/v62/github" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
buildToolingRepoName = "eks-anywhere-build-tooling" | ||
upStreamRepoOwner = "testerIbix" // will eventually be replaced by actual upstream owner, aws | ||
) | ||
|
||
// createBranchCmd represents the createBranch command | ||
var createBranchCmd = &cobra.Command{ | ||
Use: "create-branch", | ||
Short: "Creates new release branch from updated trigger file", | ||
Long: `A longer description that spans multiple lines and likely contains examples | ||
and usage of using your command.`, | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
err := releaseDecision() | ||
if err != nil { | ||
fmt.Printf("error creating branch %s", err) | ||
} | ||
}, | ||
} | ||
|
||
func releaseDecision() error { | ||
RELEASE_TYPE := os.Getenv("RELEASE_TYPE") | ||
|
||
if RELEASE_TYPE == "minor" { | ||
err := createMinorBranches() | ||
if err != nil { | ||
fmt.Printf("error calling createMinorBranches %s", err) | ||
} | ||
return nil | ||
} | ||
// else | ||
err := createPatchBranch() | ||
if err != nil { | ||
fmt.Printf("error calling createPatchBranch %s", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about printing errors. |
||
} | ||
return nil | ||
} | ||
|
||
func createMinorBranches() error { | ||
|
||
latestRelease := os.Getenv("LATEST_RELEASE") | ||
|
||
//create client | ||
accessToken := os.Getenv("SECRET_PAT") | ||
ctx := context.Background() | ||
client := github.NewClient(nil).WithAuthToken(accessToken) | ||
|
||
// create branch in upstream repo based off main branch | ||
ref := "refs/heads/" + latestRelease | ||
baseRef := "main" | ||
|
||
// Get the reference for the base branch | ||
baseRefObj, _, err := client.Git.GetRef(ctx, upStreamRepoOwner, EKSAnyrepoName, "heads/"+baseRef) | ||
if err != nil { | ||
return fmt.Errorf("error getting base branch reference one: %v", err) | ||
} | ||
|
||
// Create a new branch | ||
newBranchRef, _, err := client.Git.CreateRef(ctx, upStreamRepoOwner, EKSAnyrepoName, &github.Reference{ | ||
Ref: &ref, | ||
Object: &github.GitObject{ | ||
SHA: baseRefObj.Object.SHA, | ||
}, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("error creating branch one: %v", err) | ||
} | ||
|
||
// branch created upstream | ||
fmt.Printf("New release branch '%s' created upstream successfully\n", *newBranchRef.Ref) | ||
|
||
// create branch in forked repo based off upstream | ||
ref = "refs/heads/" + latestRelease | ||
baseRef = latestRelease | ||
|
||
// Get the reference for the base branch from the upstream repository | ||
baseRefObj, _, err = client.Git.GetRef(ctx, upStreamRepoOwner, EKSAnyrepoName, "heads/"+baseRef) | ||
if err != nil { | ||
return fmt.Errorf("error getting base branch reference two: %v", err) | ||
} | ||
|
||
// Create a new branch | ||
newBranchRef, _, err = client.Git.CreateRef(ctx, usersForkedRepoAccount, EKSAnyrepoName, &github.Reference{ | ||
Ref: &ref, | ||
Object: &github.GitObject{ | ||
SHA: baseRefObj.Object.SHA, | ||
}, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("error creating branch two: %v", err) | ||
} | ||
|
||
// branch created upstream | ||
fmt.Printf("New user fork branch '%s' created successfully\n", *newBranchRef.Ref) | ||
|
||
// create branch in upstream build tooling repo based off main branch | ||
ref = "refs/heads/" + latestRelease | ||
baseRef = "main" | ||
|
||
// Get the reference for the base branch | ||
baseRefObj, _, err = client.Git.GetRef(ctx, upStreamRepoOwner, buildToolingRepoName, "heads/"+baseRef) | ||
if err != nil { | ||
return fmt.Errorf("error getting base branch reference three: %v", err) | ||
} | ||
|
||
// Create a new branch | ||
newBranchRef, _, err = client.Git.CreateRef(ctx, upStreamRepoOwner, buildToolingRepoName, &github.Reference{ | ||
Ref: &ref, | ||
Object: &github.GitObject{ | ||
SHA: baseRefObj.Object.SHA, | ||
}, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("error creating branch three: %v", err) | ||
} | ||
|
||
// branch created upstream | ||
fmt.Printf("New build tooling branch '%s' created successfully\n", *newBranchRef.Ref) | ||
|
||
return nil | ||
} | ||
|
||
func createPatchBranch() error { | ||
|
||
latestRelease := os.Getenv("LATEST_RELEASE") | ||
|
||
//create client | ||
accessToken := os.Getenv("SECRET_PAT") | ||
ctx := context.Background() | ||
client := github.NewClient(nil).WithAuthToken(accessToken) | ||
|
||
// create branch in forked repo based off upstream | ||
ref := "refs/heads/" + latestRelease + "-releaser-patch" | ||
baseRef := latestRelease | ||
|
||
// Get the reference for the base branch from upstream | ||
baseRefObj, _, err := client.Git.GetRef(ctx, upStreamRepoOwner, EKSAnyrepoName, "heads/"+baseRef) | ||
if err != nil { | ||
return fmt.Errorf("error getting base branch reference: %v", err) | ||
} | ||
|
||
// Create a new branch in fork | ||
newBranchRef, _, err := client.Git.CreateRef(ctx, usersForkedRepoAccount, EKSAnyrepoName, &github.Reference{ | ||
Ref: &ref, | ||
Object: &github.GitObject{ | ||
SHA: baseRefObj.Object.SHA, | ||
}, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("error creating branch: %v", err) | ||
} | ||
|
||
// branch created upstream | ||
fmt.Printf("New branch '%s' created successfully\n", *newBranchRef.Ref) | ||
|
||
return nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's return these errors to the caller instead of using Printf statements throughout.