mirror of https://gitea.com/gitea/blog.git
release contrib (#142)
Merge branch 'master' into tmpl release contrib Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: jolheiser <john.olheiser@gmail.com> Reviewed-on: https://gitea.com/gitea/blog/pulls/142 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: 6543 <6543@noreply.gitea.io>
This commit is contained in:
parent
6a179d2b58
commit
ea1a85b5f4
|
@ -0,0 +1,14 @@
|
|||
# pulls release
|
||||
|
||||
This is a Go "script" to create a new release blog post from a template.
|
||||
|
||||
**NOTE:** Posts could always do with some personal touches. We really are incredibly grateful to each and every person
|
||||
who helps out the project, big or small.
|
||||
This contrib is mostly for automating getting those numbers right in all the spots.
|
||||
|
||||
### Usage
|
||||
|
||||
From the base directory
|
||||
```
|
||||
go run contrib/release/release.go --author jolheiser --milestone 1.12.5
|
||||
```
|
|
@ -0,0 +1,79 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
mergedURLFmt = "https://api.github.com/search/issues?q=repo:go-gitea/gitea+is:pr+is:merged+milestone:%s"
|
||||
tmpl = template.Must(template.ParseFiles("contrib/release/release.md"))
|
||||
|
||||
author string
|
||||
milestone string
|
||||
)
|
||||
|
||||
type Merged struct {
|
||||
TotalCount int `json:"total_count"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&author, "author", "", "The author for this blog post")
|
||||
flag.StringVar(&milestone, "milestone", "", "The milestone for this release")
|
||||
flag.Parse()
|
||||
|
||||
if author == "" {
|
||||
fmt.Println("missing --author flag")
|
||||
return
|
||||
}
|
||||
if milestone == "" {
|
||||
fmt.Println("missing --milestone flag")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := http.Get(fmt.Sprintf(mergedURLFmt, milestone))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var merged Merged
|
||||
if err := json.Unmarshal(body, &merged); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
// This will truncate if you mess up the milestone, but this is in Git so just revert it. YOLO
|
||||
fi, err := os.Create(fmt.Sprintf("content/post/release-of-%s.md", milestone))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
defer fi.Close()
|
||||
|
||||
date := time.Now()
|
||||
data := map[string]interface{}{
|
||||
"Author": author,
|
||||
"Milestone": milestone,
|
||||
"Merged": merged.TotalCount,
|
||||
"DateLong": date.Format("2006-01-02T15:04:05+07:00"),
|
||||
"DateShort": date.Format("2006-01-02"),
|
||||
}
|
||||
|
||||
if err := tmpl.Execute(fi, data); err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
date: "{{.DateLong}}"
|
||||
author: "{{.Author}}"
|
||||
title: "Gitea {{.Milestone}} is released"
|
||||
tags: ["release"]
|
||||
draft: false
|
||||
---
|
||||
|
||||
We are proud to present the release of Gitea version {{.Milestone}}.
|
||||
|
||||
We highly encourage users to update to this version for some important bug-fixes.
|
||||
|
||||
We have merged [{{.Merged}}](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+milestone%3A{{.Milestone}}+is%3Amerged) pull requests to release this version.
|
||||
|
||||
<!-- Security Thanks! -->
|
||||
|
||||
You can download one of our pre-built binaries from our [downloads page](https://dl.gitea.io/gitea/{{.Milestone}}/) - make sure to select the correct platform! For further details on how to install, follow our [installation guide](https://docs.gitea.io/en-us/install-from-binary/).
|
||||
|
||||
|
||||
We would also like to thank all of our supporters on [Open Collective](https://opencollective.com/gitea) who are helping to sustain us financially.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Changelog
|
||||
|
||||
## [{{.Milestone}}](https://github.com/go-gitea/gitea/releases/tag/v{{.Milestone}}) - {{.DateShort}}
|
||||
|
||||
<!-- Changelog Details -->
|
Loading…
Reference in New Issue