mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
Merge remote-tracking branch 'origin/master' into context
This commit is contained in:
commit
6c8cbeebc8
@ -48,7 +48,7 @@ archives uploaded.
|
|||||||
|
|
||||||
### Homebrew
|
### Homebrew
|
||||||
|
|
||||||
To push a basic formulae a homebrew tap repo, just add a `brew` section:
|
Add a `brew` section to push a formulae to a Homebrew tab repository:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
repo: user/repo
|
repo: user/repo
|
||||||
@ -59,6 +59,8 @@ brew:
|
|||||||
caveats: "Optional caveats to add to the formulae"
|
caveats: "Optional caveats to add to the formulae"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
See the [Homebrew docs](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md) for creating your own tap.
|
||||||
|
|
||||||
### Build customization
|
### Build customization
|
||||||
|
|
||||||
Just add a `build` section
|
Just add a `build` section
|
||||||
|
@ -23,19 +23,13 @@ func (Pipe) Name() string {
|
|||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
func (Pipe) Run(config config.ProjectConfig) error {
|
func (Pipe) Run(config config.ProjectConfig) error {
|
||||||
log.Println("Creating release", config.Git.CurrentTag, "on", config.Repo, "...")
|
|
||||||
ts := oauth2.StaticTokenSource(
|
ts := oauth2.StaticTokenSource(
|
||||||
&oauth2.Token{AccessToken: config.Token},
|
&oauth2.Token{AccessToken: config.Token},
|
||||||
)
|
)
|
||||||
tc := oauth2.NewClient(context.Background(), ts)
|
tc := oauth2.NewClient(context.Background(), ts)
|
||||||
client := github.NewClient(tc)
|
client := github.NewClient(tc)
|
||||||
|
|
||||||
owner, repo := split.OnSlash(config.Repo)
|
r, err := getOrCreateRelease(client, config)
|
||||||
r, _, err := client.Repositories.CreateRelease(owner, repo, &github.RepositoryRelease{
|
|
||||||
Name: github.String(config.Git.CurrentTag),
|
|
||||||
TagName: github.String(config.Git.CurrentTag),
|
|
||||||
Body: github.String(description(config.Git.Diff)),
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -52,6 +46,24 @@ func (Pipe) Run(config config.ProjectConfig) error {
|
|||||||
return g.Wait()
|
return g.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getOrCreateRelease(client *github.Client, config config.ProjectConfig) (*github.RepositoryRelease, error) {
|
||||||
|
owner, repo := split.OnSlash(config.Repo)
|
||||||
|
data := &github.RepositoryRelease{
|
||||||
|
Name: github.String(config.Git.CurrentTag),
|
||||||
|
TagName: github.String(config.Git.CurrentTag),
|
||||||
|
Body: github.String(description(config.Git.Diff)),
|
||||||
|
}
|
||||||
|
r, res, err := client.Repositories.GetReleaseByTag(owner, repo, config.Git.CurrentTag)
|
||||||
|
if err != nil && res.StatusCode == 404 {
|
||||||
|
log.Println("Creating release", config.Git.CurrentTag, "on", config.Repo, "...")
|
||||||
|
r, _, err = client.Repositories.CreateRelease(owner, repo, data)
|
||||||
|
return r, err
|
||||||
|
}
|
||||||
|
log.Println("Updating existing release", config.Git.CurrentTag, "on", config.Repo, "...")
|
||||||
|
r, _, err = client.Repositories.EditRelease(owner, repo, *r.ID, data)
|
||||||
|
return r, err
|
||||||
|
}
|
||||||
|
|
||||||
func description(diff string) string {
|
func description(diff string) string {
|
||||||
result := "## Changelog\n" + diff + "\n\n--\nAutomated with @goreleaser"
|
result := "## Changelog\n" + diff + "\n\n--\nAutomated with @goreleaser"
|
||||||
cmd := exec.Command("go", "version")
|
cmd := exec.Command("go", "version")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user