You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-17 01:42:37 +02:00
Merge remote-tracking branch 'origin/master' into 28
This commit is contained in:
15
.travis.yml
15
.travis.yml
@ -1,11 +1,24 @@
|
|||||||
language: go
|
language: go
|
||||||
go: 1.7.4
|
go: 1.7.4
|
||||||
install:
|
install:
|
||||||
|
- go get github.com/alecthomas/gometalinter
|
||||||
- go get github.com/Masterminds/glide
|
- go get github.com/Masterminds/glide
|
||||||
- glide install
|
- glide install
|
||||||
script:
|
script:
|
||||||
- go test -cover `glide nv`
|
- go test -cover `glide nv`
|
||||||
|
- gometalinter --vendor --disable-all \
|
||||||
|
--enable=deadcode \
|
||||||
|
--enable=ineffassign \
|
||||||
|
--enable=gosimple \
|
||||||
|
--enable=staticcheck \
|
||||||
|
--enable=gofmt \
|
||||||
|
--enable=goimports \
|
||||||
|
--enable=dupl \
|
||||||
|
--enable=misspell \
|
||||||
|
--enable=errcheck \
|
||||||
|
--deadline=2m \
|
||||||
|
./...
|
||||||
after_success:
|
after_success:
|
||||||
test ! -z "$TRAVIS_TAG" && go run main.go
|
test ! -z "$TRAVIS_TAG" && go run main.go
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
74
CODE_OF_CONDUCT.md
Normal file
74
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity and
|
||||||
|
orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at root@carlosbecker.com. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
@ -5,6 +5,10 @@ Deliver Go binaries as fast and easily as possible.
|
|||||||
GoReleaser builds Go binaries for several platforms, creates a github release and then
|
GoReleaser builds Go binaries for several platforms, creates a github release and then
|
||||||
push a homebrew formulae to a repository. All that wrapped in your favorite CI.
|
push a homebrew formulae to a repository. All that wrapped in your favorite CI.
|
||||||
|
|
||||||
|
|
||||||
|
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
|
||||||
|
By participating, you are expected to uphold this code. Please report unacceptable behavior to root@carlosbecker.com.
|
||||||
|
|
||||||
## How it works?
|
## How it works?
|
||||||
|
|
||||||
The idea started with a [simple shell script](https://github.com/goreleaser/old-go-releaser),
|
The idea started with a [simple shell script](https://github.com/goreleaser/old-go-releaser),
|
||||||
@ -74,7 +78,7 @@ files:
|
|||||||
|
|
||||||
## Wire it with travis-ci
|
## Wire it with travis-ci
|
||||||
|
|
||||||
You may want to wire this to auto-deploy your new tags on travis, for examepl:
|
You may want to wire this to auto-deploy your new tags on travis, for example:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
after_success:
|
after_success:
|
||||||
|
@ -54,7 +54,9 @@ func Load(file string) (config ProjectConfig, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return config, err
|
return config, err
|
||||||
}
|
}
|
||||||
err = yaml.Unmarshal(data, &config)
|
if err := yaml.Unmarshal(data, &config); err != nil {
|
||||||
|
return config, err
|
||||||
|
}
|
||||||
config.fillBasicData()
|
config.fillBasicData()
|
||||||
if err := config.fillFiles(); err != nil {
|
if err := config.fillFiles(); err != nil {
|
||||||
return config, err
|
return config, err
|
||||||
|
@ -29,73 +29,23 @@ func TestFillFilesMissingFiles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesUSENMarkdown(t *testing.T) {
|
func TestFillFilesUSENMarkdown(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/1", []string{"LICENSE.md", "README.md"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/1")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENSE.md", "README.md"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesRealENMarkdown(t *testing.T) {
|
func TestFillFilesRealENMarkdown(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/2", []string{"LICENCE.md", "README.md"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/2")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENCE.md", "README.md"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesArbitratryENTXT(t *testing.T) {
|
func TestFillFilesArbitratryENTXT(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/3", []string{"LICENCE.txt", "README.txt"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/3")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENCE.txt", "README.txt"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesArbitratryENNoSuffix(t *testing.T) {
|
func TestFillFilesArbitratryENNoSuffix(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/4", []string{"LICENCE"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/4")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"LICENCE"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFillFilesChangelog(t *testing.T) {
|
func TestFillFilesChangelog(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assertFiles(t, "./.test/5", []string{"CHANGELOG", "CHANGELOG.md"})
|
||||||
|
|
||||||
cwd, _ := os.Getwd()
|
|
||||||
os.Chdir("./.test/5")
|
|
||||||
defer os.Chdir(cwd)
|
|
||||||
|
|
||||||
config := ProjectConfig{}
|
|
||||||
err := config.fillFiles()
|
|
||||||
|
|
||||||
assert.NoError(err)
|
|
||||||
assert.Equal([]string{"CHANGELOG", "CHANGELOG.md"}, config.Files)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidadeMissingBinaryName(t *testing.T) {
|
func TestValidadeMissingBinaryName(t *testing.T) {
|
||||||
@ -118,3 +68,23 @@ func TestValidadeMinimalConfig(t *testing.T) {
|
|||||||
config := ProjectConfig{BinaryName: "asd", Repo: "asd/asd"}
|
config := ProjectConfig{BinaryName: "asd", Repo: "asd/asd"}
|
||||||
assert.NoError(config.validate())
|
assert.NoError(config.validate())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertFiles(t *testing.T, dir string, files []string) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
cwd, _ := os.Getwd()
|
||||||
|
if err := os.Chdir(dir); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := os.Chdir(cwd); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
config := ProjectConfig{}
|
||||||
|
err := config.fillFiles()
|
||||||
|
|
||||||
|
assert.NoError(err)
|
||||||
|
assert.Equal(files, config.Files)
|
||||||
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCurrentTag(t *testing.T) {
|
func TestCurrentTag(t *testing.T) {
|
||||||
|
4
main.go
4
main.go
@ -49,5 +49,7 @@ func main() {
|
|||||||
log.Println("Done!")
|
log.Println("Done!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.Run(os.Args)
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,16 +84,13 @@ func (Pipe) Run(config config.ProjectConfig) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
func sha(client *github.Client, owner, repo, name string, out bytes.Buffer) (*string, error) {
|
func sha(client *github.Client, owner, repo, name string, out bytes.Buffer) (*string, error) {
|
||||||
var sha *string
|
|
||||||
file, _, _, err := client.Repositories.GetContents(
|
file, _, _, err := client.Repositories.GetContents(
|
||||||
owner, repo, name, &github.RepositoryContentGetOptions{},
|
owner, repo, name, &github.RepositoryContentGetOptions{},
|
||||||
)
|
)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
sha = file.SHA
|
return file.SHA, err
|
||||||
} else {
|
|
||||||
sha = github.String(fmt.Sprintf("%s", sha256.Sum256(out.Bytes())))
|
|
||||||
}
|
}
|
||||||
return sha, err
|
return github.String(fmt.Sprintf("%s", sha256.Sum256(out.Bytes()))), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFormulae(config config.ProjectConfig, client *github.Client) (bytes.Buffer, error) {
|
func buildFormulae(config config.ProjectConfig, client *github.Client) (bytes.Buffer, error) {
|
||||||
|
@ -41,31 +41,32 @@ func create(system, arch string, config config.ProjectConfig) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
|
||||||
gw := gzip.NewWriter(file)
|
gw := gzip.NewWriter(file)
|
||||||
defer gw.Close()
|
|
||||||
tw := tar.NewWriter(gw)
|
tw := tar.NewWriter(gw)
|
||||||
defer tw.Close()
|
defer func() {
|
||||||
|
_ = file.Close()
|
||||||
|
_ = gw.Close()
|
||||||
|
_ = tw.Close()
|
||||||
|
}()
|
||||||
for _, f := range config.Files {
|
for _, f := range config.Files {
|
||||||
if err := addFile(tw, f, f); err != nil {
|
if err := addFile(tw, f, f); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := addFile(tw, config.BinaryName+ext(system), binaryPath(system, arch, config.BinaryName)); err != nil {
|
return addFile(tw, config.BinaryName+ext(system), binaryPath(system, arch, config.BinaryName))
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addFile(tw *tar.Writer, name, path string) error {
|
func addFile(tw *tar.Writer, name, path string) (err error) {
|
||||||
file, err := os.Open(path)
|
file, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
_ = file.Close()
|
||||||
|
}()
|
||||||
stat, err := file.Stat()
|
stat, err := file.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
header := new(tar.Header)
|
header := new(tar.Header)
|
||||||
header.Name = name
|
header.Name = name
|
||||||
@ -78,7 +79,7 @@ func addFile(tw *tar.Writer, name, path string) error {
|
|||||||
if _, err := io.Copy(tw, file); err != nil {
|
if _, err := io.Copy(tw, file); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func nameFor(system, arch, binary string) string {
|
func nameFor(system, arch, binary string) string {
|
||||||
|
@ -69,10 +69,16 @@ func upload(client *github.Client, releaseID int, owner, repo, system, arch, bin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer func() {
|
||||||
|
_ = file.Close()
|
||||||
|
}()
|
||||||
log.Println("Uploading", file.Name(), "...")
|
log.Println("Uploading", file.Name(), "...")
|
||||||
_, _, err = client.Repositories.UploadReleaseAsset(owner, repo, releaseID, &github.UploadOptions{
|
_, _, err = client.Repositories.UploadReleaseAsset(
|
||||||
Name: name,
|
owner,
|
||||||
}, file)
|
repo,
|
||||||
|
releaseID,
|
||||||
|
&github.UploadOptions{Name: name},
|
||||||
|
file,
|
||||||
|
)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,9 @@ package release
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDescription(t *testing.T) {
|
func TestDescription(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user