mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
Merge branch 'master' into mattstratton/add-custom-release-title
This commit is contained in:
commit
973356694a
@ -31,6 +31,9 @@ type Repo struct {
|
||||
|
||||
// String of the repo, e.g. owner/name
|
||||
func (r Repo) String() string {
|
||||
if r.Owner == "" && r.Name == "" {
|
||||
return ""
|
||||
}
|
||||
return r.Owner + "/" + r.Name
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,15 @@ import (
|
||||
)
|
||||
|
||||
func TestRepo(t *testing.T) {
|
||||
r := Repo{Owner: "goreleaser", Name: "godownloader"}
|
||||
assert.Equal(t, "goreleaser/godownloader", r.String(), "not equal")
|
||||
assert.Equal(
|
||||
t,
|
||||
"goreleaser/godownloader",
|
||||
Repo{Owner: "goreleaser", Name: "godownloader"}.String(),
|
||||
)
|
||||
}
|
||||
|
||||
func TestEmptyRepoNameAndOwner(t *testing.T) {
|
||||
assert.Empty(t, Repo{}.String())
|
||||
}
|
||||
|
||||
func TestLoadReader(t *testing.T) {
|
||||
|
@ -16,3 +16,11 @@ The idea started with a
|
||||
but it quickly became more complex and I also wanted to publish binaries via
|
||||
Homebrew taps, which would have made the script even more hacky, so I let go of
|
||||
that and rewrote the whole thing in Go.
|
||||
|
||||
## Installing Goreleaser
|
||||
|
||||
There are three ways to get going.
|
||||
|
||||
1. Install Goreleaser via go get (`goreleaser` command will be globally available) `go get github.com/goreleaser/goreleaser`
|
||||
2. On a Mac use [Homebrew](https://github.com/goreleaser/homebrew-tap).
|
||||
3. Install directly [from the binaries](https://github.com/goreleaser/goreleaser/releases/latest).
|
||||
|
@ -3,7 +3,7 @@ title: GitHub Enterprise
|
||||
---
|
||||
|
||||
You can use GoReleaser with GitHub Enterprise by providing its URLs in
|
||||
the `.goreleaer.yml` configuration file:
|
||||
the `.goreleaser.yml` configuration file:
|
||||
|
||||
```yaml
|
||||
# .goreleaser.yml
|
||||
|
@ -121,7 +121,7 @@ func setReleaseDefaults(ctx *context.Context) error {
|
||||
}
|
||||
repo, err := remoteRepo()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed reading repo from git: %v", err.Error())
|
||||
return err
|
||||
}
|
||||
ctx.Config.Release.GitHub = repo
|
||||
return nil
|
||||
|
@ -1,12 +1,11 @@
|
||||
package defaults
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/testlib"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -15,6 +14,11 @@ func TestDescription(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFillBasicData(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
||||
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
@ -32,8 +36,6 @@ func TestFillBasicData(t *testing.T) {
|
||||
assert.Equal(t, "tar.gz", ctx.Config.Archive.Format)
|
||||
assert.Contains(t, ctx.Config.Brew.Install, "bin.install \"goreleaser\"")
|
||||
assert.Empty(t, ctx.Config.Dockers)
|
||||
assert.Equal(t, ctx.Config.Brew.CommitAuthor.Name, "goreleaserbot")
|
||||
assert.Equal(t, ctx.Config.Brew.CommitAuthor.Email, "goreleaser@carlosbecker.com")
|
||||
assert.NotEmpty(
|
||||
t,
|
||||
ctx.Config.Archive.NameTemplate,
|
||||
@ -43,6 +45,10 @@ func TestFillBasicData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFillPartial(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
||||
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
@ -83,6 +89,10 @@ func TestFillPartial(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFillSingleBuild(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
||||
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
@ -97,16 +107,22 @@ func TestFillSingleBuild(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNotAGitRepo(t *testing.T) {
|
||||
folder, err := ioutil.TempDir("", "goreleasertest")
|
||||
assert.NoError(t, err)
|
||||
previous, err := os.Getwd()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, os.Chdir(folder))
|
||||
defer func() {
|
||||
assert.NoError(t, os.Chdir(previous))
|
||||
}()
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.Error(t, Pipe{}.Run(ctx))
|
||||
assert.Empty(t, ctx.Config.Release.GitHub.String())
|
||||
}
|
||||
|
||||
func TestGitRepoWithoutRemote(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{},
|
||||
}
|
||||
assert.Error(t, Pipe{}.Run(ctx))
|
||||
assert.Empty(t, ctx.Config.Release.GitHub.String())
|
||||
}
|
||||
|
@ -1,19 +1,23 @@
|
||||
package defaults
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// remoteRepo gets the repo name from the Git config.
|
||||
func remoteRepo() (result config.Repo, err error) {
|
||||
if _, err = os.Stat(".git"); os.IsNotExist(err) {
|
||||
return result, errors.Wrap(err, "current folder is not a git repository")
|
||||
}
|
||||
cmd := exec.Command("git", "config", "--get", "remote.origin.url")
|
||||
bts, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return result, errors.New(err.Error() + ": " + string(bts))
|
||||
return result, errors.Wrap(err, "repository doesn't have an `origin` remote")
|
||||
}
|
||||
return extractRepoFromURL(string(bts)), nil
|
||||
}
|
||||
|
@ -3,10 +3,16 @@ package defaults
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goreleaser/goreleaser/internal/testlib"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRepoName(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
||||
repo, err := remoteRepo()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "goreleaser/goreleaser", repo.String())
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/git"
|
||||
"github.com/goreleaser/goreleaser/pipeline"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Pipe for brew deployment
|
||||
@ -54,7 +55,7 @@ func setVersion(ctx *context.Context, tag, commit string) (err error) {
|
||||
if ctx.Snapshot {
|
||||
snapshotName, err := getSnapshotName(ctx, tag, commit)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to generate snapshot name: %s", err.Error())
|
||||
return errors.Wrap(err, "failed to generate snapshot name")
|
||||
}
|
||||
ctx.Version = snapshotName
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user