-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,855 additions
and
297 deletions.
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) | ||
} | ||
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.