Skip to content

Commit

Permalink
cleaning up release notes
Browse files Browse the repository at this point in the history
Signed-off-by: James Strong <[email protected]>
  • Loading branch information
James Strong committed Dec 18, 2022
1 parent 29823a3 commit b3ac246
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 80 deletions.
25 changes: 25 additions & 0 deletions Changelog.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

### {{ template current_version }}

{{ template important_updates }}

Images:

{{ template controller_image_digests }}

### All Changes:

{{ template all_updates }}

### Dependencies updates:

{{ template dependency_updates }}

## New Contributors

{{ template new_contributors }}

**Full Changelog**: https://github.com/kubernetes/ingress-nginx/compare/controller-{{ template previous_version }}...controller-{{ template current_version }}

{{ template previous_changelog }}
64 changes: 0 additions & 64 deletions magefiles/release-notes.go

This file was deleted.

114 changes: 98 additions & 16 deletions magefiles/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
package main

import (
"context"
"fmt"

gogithub "github.com/google/go-github"
"github.com/magefile/mage/mg"
gh_release "github.com/mysteriumnetwork/go-ci/github"
"os"
"strings"
)

type Release mg.Namespace

var ORG = "strongjz" // the owner so we can test from forks
var REPO = "ingress-nginx" // the repo to pull from
var RELEASE_BRANCH = "main" //we only release from main
var GITHUB_TOKEN string // the google/gogithub lib needs an PAT to access the GitHub API
var GITHUB_TOKEN string // the Google/gogithub lib needs an PAT to access the GitHub API

func init() {
GITHUB_TOKEN = os.Getenv("GITHUB_TOKEN")
Expand All @@ -37,23 +36,106 @@ func (Release) Release(version string) {
//git commit TODO
//make Pull Request TODO
//make release
mg.Deps(mg.F(Release.CreateRelease, version))
//mg.Deps(mg.F(Release.CreateRelease, version))
}

//// CreateRelease Creates a new GitHub Release
//func (Release) CreateRelease(name string) {
// releaser, err := gh_release.NewReleaser(ORG, REPO, GITHUB_TOKEN)
// CheckIfError(err, "GitHub Release Client error")
// newRelease, err := releaser.Create(fmt.Sprintf("controller-%s", name))
// CheckIfError(err, "Create release error")
// Info("New Release: Tag %v, ID: %v", newRelease.TagName, newRelease.ID)
//}

type ControllerImage struct {
Digest string
}

type ReleaseNote struct {
CurrentVersion string
PreviousVersion string
ControllerImages []ControllerImage
ImportantUpdates []string
AllOtherUpdates []string
NewContributors []string
PreviousReleaseNotes *ReleaseNote
}

// LatestCommitLogs Retrieves the commit log between the latest two controller versions.
func (Release) LatestCommitLogs() {
commitsBetweenTags()
}

func commitsBetweenTags() {
tags := getAllControllerTags()
Info("Getting Commits between %v and %v", tags[0], tags[1])
commitLog, err := git("log", fmt.Sprintf("%v..%v", tags[1], tags[0]))
if commitLog == "" {
Warning("All Controller Tags is empty")
}
CheckIfError(err, "Retrieving Commit log")
temp := strings.Split(commitLog, "\n")
Info("There are %v commits", len(commitLog))
Info("Commits between %v..%v", tags[1], tags[0])
for i, s := range temp {
Info("#%v Version %v", i, s)
}
}

// Generate Release Notes
func (Release) ReleaseNotes() {
makeReleaseNotes()
}

// CreateRelease Creates a new GitHub Release
func (Release) CreateRelease(name string) {
releaser, err := gh_release.NewReleaser(ORG, REPO, GITHUB_TOKEN)
CheckIfError(err, "Github Release Client error")
newRelease, err := releaser.Create(fmt.Sprintf("controller-%s", name))
CheckIfError(err, "Create release error")
Info("New Release: Tag %v, ID: %v", newRelease.TagName, newRelease.ID)
type GitHubClient struct {
client *gogithub.Client
owner, repository string
}

// CurrentRelease retrieves the current Ingress Nginx Controller Release
func (Release) CurrentRelease() {
func (Release) Latest() (*RepositoryRelease, error) {
gh, err := githubClient()
CheckIfError(err, "Get Latest Release Client error")
if err != nil {
ErrorF("Error creating github client %s", err)
return nil, error
}

release, _, err := gh.client.Repositories.GetLatestRelease(context.Background(), gh.owner, gh.repository)
CheckIfError(err, "Get Latest Release")
if err != nil {
ErrorF("retrieving latest release %s", err)
return nil, error
}

Info("Latest Release %v", release.String())
return release, nil
}

func (Release) GithubReleaseNotes() {

}

func githubClient() (*GitHubClient, error) {
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: GITHUB_TOKEN},
)
oauthClient := oauth2.NewClient(context.Background(), ts)
return &GitHubClient{
client: gogithub.NewClient(oauthClient),
owner: ORG,
repository: REPO,
}, nil
}
func makeReleaseNotes() {
//previousReleaseNotes := ReleaseNote{}
//newReleaseNotes := ReleaseNote{}

//populate previous release note

//current version
//previous version
//new contributors list
//dependency_updates
//all_updates
//controller_image_digests
//important_updates
}

0 comments on commit b3ac246

Please sign in to comment.