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

#293: tag rancher release #315

Merged
merged 9 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
59 changes: 49 additions & 10 deletions cmd/rancher_release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Results are printed in MD, and can be pasted into Slack, but formatting is trick

**Examples**

```
```sh
rancher_release list-nonmirrored-rc-images --tag v2.8.0-rc1
```

Expand All @@ -31,7 +31,7 @@ Checks if there’s an available Helm Chart and Docker images for amd64, arm and

**Examples**

```
```sh
rancher_release check-rancher-image --tag v2.8.0-rc1
```

Expand All @@ -56,24 +56,24 @@ Optional flags can be automatically set if you are inside your rancher fork. ⚠

**Examples**

```
```sh
rancher_release set-kdm-branch-refs -n dev-v2.8-september-patches --create-pr --dry-run
```

```
```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release set-kdm-branch-refs -n dev-v2.8-september-patches -p -r
```

```
```sh
rancher_release set-kdm-branch-refs --fork-path $GOPATH/src/github.com/{YOUR_USERNAME}/rancher \
--base-branch release/v2.8 \
--current-kdm-branch dev-v2.8 \
--new-kdm-branch dev-v2.8-september-patches
```

```
```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release set-kdm-branch-refs -f $GOPATH/src/github.com/{YOUR_USERNAME}/rancher -b release/v2.8 -c dev-v2.8 -n dev-v2.8-september-patches -p -u {YOUR_USERNAME}
Expand All @@ -100,33 +100,72 @@ Non-required flags can be automatically set, if you are inside your rancher fork

**Examples**

```
```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release set-charts-branch-refs --new-charts-branch dev-v2.9 --create-pr --dry-run
```

```
```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release set-charts-branch-refs -n dev-v2.9 -p -r
```

```
```sh
rancher_release set-charts-branch-refs --fork-path $GOPATH/src/github.com/{YOUR_USERNAME}/rancher \
--base-branch release/v2.8 \
--current-charts-branch dev-v2.8 \
--new-charts-branch dev-v2.9

```

```
```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release set-charts-branch-refs -f $GOPATH/src/github.com/{YOUR_USERNAME}/rancher -b release/v2.8 -c dev-v2.8 -n dev-v2.9 -p -o {YOUR_USERNAME}

```

### tag-release
Tags releases in GitHub for Rancher.

When tagging a new release using the `tag-release` command, always prefer to use the default behavior of creating as a draft and verifying the release in the UI before publishing it.
If you are running this locally, you'll need to generate a GitHub Token, use the fine-grained personal access token, scoped to only the rancher repo and with the `contents read and write` scope.


| **Flag** | **Description** | **Required** |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| `github-token`, `g`, `GITHUB_TOKEN` | GitHub generated token as described above. | TRUE |
| `tag`, `t` | The tag that you want to create. | TRUE |
| `remote-branch`, `b` | The branch which you want to create the tag against. | TRUE |
| `repo-owner`, `o` | Username of the rancher repo owner. Default is `rancher`, only customize this for testing purposes. | FALSE |
| `repo-path`, `p` | If you already have the rancher repo cloned in your computer, it will be used to run the components script. Before running, your local changes will be stashed. If this isn't provided, the rancher repo will be cloned at `/tmp/rancher` | FALSE |
| `general-availability`, `a` | By default, the release will be created as a pre-release, before setting this as true, make sure it absolutely needs to be a GA release. | FALSE |
| `ignore-draft`, `d` | By default, the release will be created as a draft, so you can verify everything is correct before publishing it. | FALSE |
| `dry-run`, `r` | The release will not be created, just logged. | FALSE |

**Examples**

```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release tag-release --tag v2.8.0-rc1 --remote-branch release/v2.8 --dry-run
```

```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release tag-release --tag v2.8.0-rc1 --remote-branch release/v2.8 --repo-owner tashima42 --repo-path $HOME/code/tashima42/rancher --dry-run
```

```sh
export GITHUB_TOKEN={YOUR_GITHUB_TOKEN}

rancher_release tag-release -t v2.8.0 -b release/v2.8 -a -r
```


### label-issues

Given a release candidate, updates each GitHub issue belonging to its milestone with the tag `[zube]: To Test` and adds a comment with the prerelease version to test.
Expand Down
1 change: 1 addition & 0 deletions cmd/rancher_release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
setChartsBranchReferencesCommand(),
checkRancherRCDepsCommand(),
labelIssuesCommand(),
tagReleaseCommand(),
}
app.Flags = rootFlags

Expand Down
82 changes: 82 additions & 0 deletions cmd/rancher_release/tag_release.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package main

import (
"context"

"github.com/rancher/ecm-distro-tools/release/rancher"
"github.com/rancher/ecm-distro-tools/repository"
"github.com/urfave/cli/v2"
)

func tagReleaseCommand() *cli.Command {
return &cli.Command{
Name: "tag-release",
Usage: "tag a rancher release",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "github-token",
Aliases: []string{"g"},
EnvVars: []string{"GITHUB_TOKEN"},
Required: true,
},
&cli.StringFlag{
Name: "tag",
Aliases: []string{"t"},
Usage: "release tag",
Required: true,
},
&cli.StringFlag{
Name: "remote-branch",
Aliases: []string{"b"},
Usage: "rancher remote branch",
Required: true,
},
&cli.StringFlag{
Name: "repo-owner",
Aliases: []string{"o"},
Usage: "repo owner for the rancher repo, default is rancher, this is only used for testing purposes",
Value: "rancher",
Required: false,
},
&cli.StringFlag{
Name: "repo-path",
Aliases: []string{"p"},
Usage: "rancher repo path, if not provided the repo will be cloned at /tmp/rancher",
Required: false,
},
&cli.BoolFlag{
Name: "general-availability",
Aliases: []string{"a"},
Usage: "by default, the release will be created as a pre-release, make sure it absolutely needs to be a GA release before setting this",
Required: false,
},
&cli.BoolFlag{
Name: "ignore-draft",
Aliases: []string{"d"},
Usage: "by default, the release will be created as a draft, so you can verify all information is correct before publishing it",
Required: false,
},
&cli.BoolFlag{
Name: "dry-run",
Aliases: []string{"r"},
Usage: "skip all changes that have side effects, like creating a release in a remote repo.",
Required: false,
},
},
Action: tagRelease,
}
}

func tagRelease(c *cli.Context) error {
token := c.String("github-token")
tag := c.String("tag")
remoteBranch := c.String("remote-branch")
repoOwner := c.String("repo-owner")
repoPath := c.String("repo-path")
generalAvailability := c.Bool("general-availability")
ignoreDraft := c.Bool("ignore-draft")
dryRun := c.Bool("dry-run")
ctx := context.Background()
ghClient := repository.NewGithub(ctx, token)
return rancher.TagRancherRelease(ctx, ghClient, tag, remoteBranch, repoOwner, repoPath, generalAvailability, ignoreDraft, dryRun)
}
Loading