Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoReleaser #80

Merged
merged 25 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: 2.1
jobs:
release:
docker:
- image: circleci/golang:1.13
steps:
- checkout
- run: curl -sL https://git.io/goreleaser | bash
build:
docker:
- image: circleci/golang:1.13
environment:
GO111MODULE: "on"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is GO111MODULE: "on" still necessary for go 1.13?

The GO111MODULE environment variable continues to default to auto, but the auto setting now activates the module-aware mode of the go command whenever the current working directory contains, or is below a directory containing, a go.mod file — even if the current directory is within GOPATH/src. This change simplifies the migration of existing code within GOPATH/src and the ongoing maintenance of module-aware packages alongside non-module-aware importers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm gonna leave it for now, but with Go 1.14 I don't mind removing it?

TEST_RESULTS: /tmp/test-results
working_directory: /go/src/github.com/sonatype-nexus-community/nancy
steps:
- checkout
- run: mkdir -p $TEST_RESULTS/gotest
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run: go mod download
- run: go mod tidy
- run: go get -u github.com/jstemmer/go-junit-report
- run: go test ./... -v 2>&1 | go-junit-report > $TEST_RESULTS/gotest/report.xml
- run: go build
- run: cd testdata/dep && ../../nancy Gopkg.lock && cd -
- run: ./nancy go.sum
- run: go list -m all | ./nancy
- save_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- store_artifacts:
path: /tmp/test-results/
- store_test_results:
path: /tmp/test-results/


workflows:
version: 2
build_and_release:
jobs:
- build
- release:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nancy
#IntelliJ
.idea
*.iml
dist/
43 changes: 43 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
before:
hooks:
- go mod download
DarthHater marked this conversation as resolved.
Show resolved Hide resolved
- go mod tidy
builds:
-
ldflags:
- -s -w -X "github.com/sonatype-nexus-community/nancy/buildversion.BuildVersion={{.Version}}"
- -s -w -X "github.com/sonatype-nexus-community/nancy/buildversion.BuildTime={{time "2006-01-02T15:04:05Z07:00"}}"
- -s -w -X "github.com/sonatype-nexus-community/nancy/buildversion.BuildCommit={{.FullCommit}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value is a one liner, https://goreleaser.com/customization/#Builds

Suggested change
- -s -w -X "github.com/sonatype-nexus-community/nancy/buildversion.BuildCommit={{.FullCommit}}"
- >-
-s -w
-X "github.com/sonatype-nexus-community/nancy/buildversion.BuildVersion={{.Version}}"
-X "github.com/sonatype-nexus-community/nancy/buildversion.BuildTime={{time "2006-01-02T15:04:05Z07:00"}}"
-X "github.com/sonatype-nexus-community/nancy/buildversion.BuildCommit={{.FullCommit}}"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not ANTI this, but I kinda like it as three separate commands (since it's doing it three different places). I don't have enough experience with goreleaser to know if one is preferable to the other. My main concern would be if one fails, etc...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readability is I THINK easier with it broken out like this, is my main pro to having them the way I have it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yours isn't bad for that either (it's just clear on the original that it's running -s -w -X on all three, at a quick glance)

env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- 386

archives:
-
name_template: "{{ .ProjectName }}-{{ .Os }}.{{ .Arch }}-v{{ .Version }}"
format: binary

checksum:
name_template: "{{ .ProjectName }}checksums.txt"
algorithm: sha256

snapshot:
name_template: "{{ .Tag }}-next-{{.FullCommit}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this pull in the previous tag value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It pulls in the current tag value. The way GoReleaser works, is someone creates a tag, then CircleCI would start a build and release it. I preferred this a tiny bit to what we had before because it makes doing major and minor releases possible. Goreleaser also has a ton of functionality related to Docker, rpms, etc... that we could leverage.


changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

release:
github:
owner: sonatype-nexus-community
name: nancy
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
</p>

<p align="center">
<a href="https://gitter.im/sonatype-nexus-community/nancy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge">
<img src="https://badges.gitter.im/sonatype-nexus-community/nancy.svg" alt="Gitter"></img></a>
<a href="https://travis-ci.org/sonatype-nexus-community/nancy"><img src="https://travis-ci.org/sonatype-nexus-community/nancy.svg?branch=master" alt="Build Status"></img></a>
<a href="https://circleci.com/gh/sonatype-nexus-community/nancy"><img src="https://circleci.com/gh/sonatype-nexus-community/nancy.svg?style=svg" alt="Circle CI Build Status"></img></a>
<a href="https://gitter.im/sonatype-nexus-community/nancy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/sonatype-nexus-community/nancy.svg" alt="Gitter"></img></a>
</p>

# Nancy
Expand Down Expand Up @@ -257,6 +256,8 @@ Count,Package,Is Vulnerable,Num Vulnerabilities,Vulnerabilities

You can see an example of using `nancy` in Travis-CI at [this intentionally vulnerable repo we made](https://github.com/sonatype-nexus-community/intentionally-vulnerable-golang-project).

Nancy as well runs on it self (delicious dog food!) in CircleCI, in a myriad of fashions. You can see how we do that here in [our repo's CircleCI config](https://github.com/sonatype-nexus-community/nancy/blob/master/.circleci/config.yml).

### DISCLAIMER

A portion of the golang ecosystem doesn't use proper versions, and instead uses a commit hash to resolve your dependency. Dependencies like this will not work with
Expand Down Expand Up @@ -285,11 +286,11 @@ At current time you have a few options:

### Download release binary

Each commit to master creates a new release binary, and if you'd like to skip building from source, you can download a binary similar to:
Each tag pushed to this repo creates a new release binary, and if you'd like to skip building from source, you can download a binary similar to:

```console
$ curl -o /path/where/you/want/nancy \
https://github.com/sonatype-nexus-community/nancy/releases/download/0.0.4/nancy-linux.amd64-0.0.4
https://github.com/sonatype-nexus-community/nancy/releases/download/v0.0.44/nancy-darwin.amd64-v0.0.44
```

## Development
Expand Down
15 changes: 0 additions & 15 deletions bumpver.sh

This file was deleted.