Compare commits
No commits in common. "main" and "0.10.0" have entirely different histories.
30
CHANGELOG.md
30
CHANGELOG.md
@ -1,33 +1,3 @@
|
|||||||
## 0.13.0 (2024-10-25)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- :sparkles: use time.Time.Before() instead of Sub()
|
|
||||||
|
|
||||||
## 0.12.0 (2024-10-25)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- :sparkles: use tagger.when to find latest tag
|
|
||||||
|
|
||||||
## 0.11.1 (2024-07-11)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- :bug: append newline after success message, use logger [CI SKIP]
|
|
||||||
|
|
||||||
## 0.11.0 (2024-07-11)
|
|
||||||
|
|
||||||
### Feat
|
|
||||||
|
|
||||||
- :sparkles: use log.textformatter
|
|
||||||
|
|
||||||
## 0.10.1 (2024-07-11)
|
|
||||||
|
|
||||||
### Fix
|
|
||||||
|
|
||||||
- revert: :rewind: fix: 🐛 use latest instead of last (oldest) tag - Add logs
|
|
||||||
|
|
||||||
## 0.10.0 (2024-07-11)
|
## 0.10.0 (2024-07-11)
|
||||||
|
|
||||||
### Feat
|
### Feat
|
||||||
|
2
cz.yaml
2
cz.yaml
@ -5,5 +5,5 @@ commitizen:
|
|||||||
name: cz_conventional_commits
|
name: cz_conventional_commits
|
||||||
tag_format: $version
|
tag_format: $version
|
||||||
update_changelog_on_bump: true
|
update_changelog_on_bump: true
|
||||||
version: 0.13.0
|
version: 0.10.0
|
||||||
version_scheme: semver
|
version_scheme: semver
|
||||||
|
24
main.go
24
main.go
@ -24,7 +24,6 @@ func init() {
|
|||||||
tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file")
|
tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file")
|
||||||
notes *string = flag.String("notes", "", "Notes to use in release")
|
notes *string = flag.String("notes", "", "Notes to use in release")
|
||||||
notesFile *string = flag.String("notes-file", "", "File to use for release notes")
|
notesFile *string = flag.String("notes-file", "", "File to use for release notes")
|
||||||
logLevel *string = flag.String("log-level", "", "Level for logging")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -48,21 +47,17 @@ func init() {
|
|||||||
if notesFile != nil && *notesFile != "" {
|
if notesFile != nil && *notesFile != "" {
|
||||||
args.NotesFile = *notesFile
|
args.NotesFile = *notesFile
|
||||||
}
|
}
|
||||||
|
|
||||||
if logLevel != nil && *logLevel != "" {
|
|
||||||
args.Level = *logLevel
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFormatter(&log.TextFormatter{
|
log.SetFormatter(new(formatter))
|
||||||
DisableTimestamp: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
switch args.Level {
|
switch args.Level {
|
||||||
case "debug":
|
case "debug":
|
||||||
|
log.SetFormatter(textFormatter)
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
case "trace":
|
case "trace":
|
||||||
|
log.SetFormatter(textFormatter)
|
||||||
log.SetLevel(log.TraceLevel)
|
log.SetLevel(log.TraceLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,3 +65,16 @@ func main() {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default formatter that writes logs without including timestamp
|
||||||
|
// or level information.
|
||||||
|
type formatter struct{}
|
||||||
|
|
||||||
|
func (*formatter) Format(entry *log.Entry) ([]byte, error) {
|
||||||
|
return []byte(entry.Message), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// text formatter that writes logs with level information
|
||||||
|
var textFormatter = &log.TextFormatter{
|
||||||
|
DisableTimestamp: true,
|
||||||
|
}
|
||||||
|
@ -96,8 +96,6 @@ func Exec(ctx context.Context, args Args) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error getting git tag %w", err)
|
return fmt.Errorf("error getting git tag %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.WithField("tag", tag).Info("Fetched latest git tag")
|
|
||||||
} else if args.TagFile != "" {
|
} else if args.TagFile != "" {
|
||||||
log.WithField("file", args.TagFile).Info("Reading tag from file")
|
log.WithField("file", args.TagFile).Info("Reading tag from file")
|
||||||
|
|
||||||
@ -172,7 +170,7 @@ func Exec(ctx context.Context, args Args) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
releaseURL := fmt.Sprintf("%s/%s/%s/releases/tag/%s", args.GiteaUrl, args.Owner, args.Repo, release.TagName)
|
releaseURL := fmt.Sprintf("%s/%s/%s/releases/tag/%s", args.GiteaUrl, args.Owner, args.Repo, release.TagName)
|
||||||
log.WithField("url", releaseURL).Info("Successfully created release")
|
fmt.Printf("Successfully created release at %s", releaseURL)
|
||||||
|
|
||||||
writeCard(
|
writeCard(
|
||||||
args.Pipeline.Card.Path,
|
args.Pipeline.Card.Path,
|
||||||
|
@ -9,14 +9,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing/transport/client"
|
"github.com/go-git/go-git/v5/plumbing/transport/client"
|
||||||
githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
|
githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetLatestGitTagOption func(repo *git.Repository) error
|
type GetLatestGitTagOption func(repo *git.Repository) error
|
||||||
@ -50,7 +50,7 @@ func SetBasicAuth(username, password string) func(repo *git.Repository) error {
|
|||||||
|
|
||||||
func FetchTags() func(repo *git.Repository) error {
|
func FetchTags() func(repo *git.Repository) error {
|
||||||
return func(repo *git.Repository) error {
|
return func(repo *git.Repository) error {
|
||||||
log.Info("Fetching git tags")
|
log.Println("Fetching latest git tags")
|
||||||
|
|
||||||
err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags})
|
err := repo.Fetch(&git.FetchOptions{Tags: git.AllTags})
|
||||||
|
|
||||||
@ -62,56 +62,40 @@ func FetchTags() func(repo *git.Repository) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLatestGitTag(options ...GetLatestGitTagOption) (string, error) {
|
func getLatestGitTag(options ...GetLatestGitTagOption) (tag string, err error) {
|
||||||
var (
|
r, err := git.PlainOpen(".")
|
||||||
tag string
|
|
||||||
tagDate *time.Time
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
repo, err := git.PlainOpen(".")
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error opening git repo at %s: %w", ".", err)
|
return "", fmt.Errorf("error opening git repo at %s: %w", ".", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
err := opt(repo)
|
err := opt(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tags, err := repo.TagObjects()
|
tagRefs, err := r.Tags()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error getting git tags %w", err)
|
return "", fmt.Errorf("error getting git tag refs %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
ref, err := tagRefs.Next()
|
||||||
t, err := tags.Next()
|
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
break
|
return tag, fmt.Errorf("couldn't find any git tags %w", err)
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("error iterating tags %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if tagDate != nil && t.Tagger.When.Before(*tagDate) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
tagDate = &t.Tagger.When
|
|
||||||
tag = t.Name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tag == "" {
|
if err != nil {
|
||||||
return tag, fmt.Errorf("couldn't find any git tags")
|
return tag, fmt.Errorf("error iterating tags %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return tag, err
|
parts := strings.Split(string(ref.Name()), "/")
|
||||||
|
tag = strings.Join(parts[2:], "/")
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeCard(path, schema string, card interface{}) {
|
func writeCard(path, schema string, card interface{}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user