1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

Merge remote-tracking branch 'origin/master' into 28

This commit is contained in:
Carlos Alexandro Becker 2017-01-02 13:47:15 -02:00
commit 16e137acdb
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
11 changed files with 153 additions and 82 deletions

View File

@ -1,11 +1,24 @@
language: go
go: 1.7.4
install:
- go get github.com/alecthomas/gometalinter
- go get github.com/Masterminds/glide
- glide install
script:
- 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:
test ! -z "$TRAVIS_TAG" && go run main.go
notifications:
email: false
email: false

74
CODE_OF_CONDUCT.md Normal file
View 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/

View File

@ -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
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?
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
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
after_success:

View File

@ -54,7 +54,9 @@ func Load(file string) (config ProjectConfig, err error) {
if err != nil {
return config, err
}
err = yaml.Unmarshal(data, &config)
if err := yaml.Unmarshal(data, &config); err != nil {
return config, err
}
config.fillBasicData()
if err := config.fillFiles(); err != nil {
return config, err

View File

@ -29,73 +29,23 @@ func TestFillFilesMissingFiles(t *testing.T) {
}
func TestFillFilesUSENMarkdown(t *testing.T) {
assert := assert.New(t)
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)
assertFiles(t, "./.test/1", []string{"LICENSE.md", "README.md"})
}
func TestFillFilesRealENMarkdown(t *testing.T) {
assert := assert.New(t)
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)
assertFiles(t, "./.test/2", []string{"LICENCE.md", "README.md"})
}
func TestFillFilesArbitratryENTXT(t *testing.T) {
assert := assert.New(t)
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)
assertFiles(t, "./.test/3", []string{"LICENCE.txt", "README.txt"})
}
func TestFillFilesArbitratryENNoSuffix(t *testing.T) {
assert := assert.New(t)
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)
assertFiles(t, "./.test/4", []string{"LICENCE"})
}
func TestFillFilesChangelog(t *testing.T) {
assert := assert.New(t)
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)
assertFiles(t, "./.test/5", []string{"CHANGELOG", "CHANGELOG.md"})
}
func TestValidadeMissingBinaryName(t *testing.T) {
@ -118,3 +68,23 @@ func TestValidadeMinimalConfig(t *testing.T) {
config := ProjectConfig{BinaryName: "asd", Repo: "asd/asd"}
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)
}

View File

@ -1,8 +1,9 @@
package git
import (
"github.com/stretchr/testify/assert"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCurrentTag(t *testing.T) {

View File

@ -49,5 +49,7 @@ func main() {
log.Println("Done!")
return
}
app.Run(os.Args)
if err := app.Run(os.Args); err != nil {
log.Fatalln(err)
}
}

View File

@ -84,16 +84,13 @@ func (Pipe) Run(config config.ProjectConfig) error {
return err
}
func sha(client *github.Client, owner, repo, name string, out bytes.Buffer) (*string, error) {
var sha *string
file, _, _, err := client.Repositories.GetContents(
owner, repo, name, &github.RepositoryContentGetOptions{},
)
if err == nil {
sha = file.SHA
} else {
sha = github.String(fmt.Sprintf("%s", sha256.Sum256(out.Bytes())))
return file.SHA, err
}
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) {

View File

@ -41,31 +41,32 @@ func create(system, arch string, config config.ProjectConfig) error {
if err != nil {
return err
}
defer file.Close()
gw := gzip.NewWriter(file)
defer gw.Close()
tw := tar.NewWriter(gw)
defer tw.Close()
defer func() {
_ = file.Close()
_ = gw.Close()
_ = tw.Close()
}()
for _, f := range config.Files {
if err := addFile(tw, f, f); err != nil {
return err
}
}
if err := addFile(tw, config.BinaryName+ext(system), binaryPath(system, arch, config.BinaryName)); err != nil {
return err
}
return nil
return addFile(tw, config.BinaryName+ext(system), binaryPath(system, arch, config.BinaryName))
}
func addFile(tw *tar.Writer, name, path string) error {
func addFile(tw *tar.Writer, name, path string) (err error) {
file, err := os.Open(path)
if err != nil {
return err
return
}
defer file.Close()
defer func() {
_ = file.Close()
}()
stat, err := file.Stat()
if err != nil {
return err
return
}
header := new(tar.Header)
header.Name = name
@ -78,7 +79,7 @@ func addFile(tw *tar.Writer, name, path string) error {
if _, err := io.Copy(tw, file); err != nil {
return err
}
return nil
return
}
func nameFor(system, arch, binary string) string {

View File

@ -69,10 +69,16 @@ func upload(client *github.Client, releaseID int, owner, repo, system, arch, bin
if err != nil {
return err
}
defer file.Close()
defer func() {
_ = file.Close()
}()
log.Println("Uploading", file.Name(), "...")
_, _, err = client.Repositories.UploadReleaseAsset(owner, repo, releaseID, &github.UploadOptions{
Name: name,
}, file)
_, _, err = client.Repositories.UploadReleaseAsset(
owner,
repo,
releaseID,
&github.UploadOptions{Name: name},
file,
)
return err
}

View File

@ -2,8 +2,9 @@ package release
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDescription(t *testing.T) {