Skip to content

Commit

Permalink
Add pre-release support to release pipeline (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrodnm authored Jun 23, 2020
1 parent ca6e6fc commit b96ac35
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
9 changes: 7 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ builds:
- linux
- darwin
hooks:
pre: env MAJOR_VERSION={{ .Major }}.{{ .Minor }} env MINOR_VERSION={{ .Major }}.{{ .Minor }}.{{ .Patch }} go generate ./...
pre: env MAJOR_MINOR_VERSION={{ .Major }}.{{ .Minor }} env PRE_RELEASE_VERSION={{ .Prerelease }} env FULL_VERSION={{ .Version }} go generate ./...
ignore:
- goarch: 386
archives:
Expand All @@ -29,7 +29,12 @@ dockers:
- nri-prometheus
image_templates:
- 'newrelic/nri-prometheus:{{ .Major }}.{{ .Minor }}'
- 'newrelic/nri-prometheus:{{ .Major }}.{{ .Minor }}.{{ .Patch }}'
skip_push: auto
- dockerfile: Dockerfile.release
binaries:
- nri-prometheus
image_templates:
- 'newrelic/nri-prometheus:{{ .Version }}'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
Expand Down
2 changes: 1 addition & 1 deletion cmd/nri-prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/sirupsen/logrus"
)

//go:generate go run -ldflags "-X main.majorVersion=$MAJOR_VERSION -X main.minorVersion=$MINOR_VERSION" ../../tools/deploy-yaml/main.go
//go:generate go run -ldflags "-X main.majorMinorVersion=$MAJOR_MINOR_VERSION -X main.preReleaseVersion=$PRE_RELEASE_VERSION -X main.fullVersion=$FULL_VERSION" ../../tools/deploy-yaml/main.go
func main() {
cfg, err := loadConfig()
if err != nil {
Expand Down
15 changes: 10 additions & 5 deletions tools/deploy-yaml/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
)

var (
majorVersion = "dev"
minorVersion = "dev"
majorMinorVersion = "dev"
preReleaseVersion = ""
fullVersion = "dev"
)

func main() {
Expand All @@ -29,9 +30,13 @@ func main() {
if nil != err {
log.Fatal(err)
}
writeTemplate(tmpl, majorVersion, majorVersion)
writeTemplate(tmpl, minorVersion, minorVersion)
writeTemplate(tmpl, minorVersion, "latest")

writeTemplate(tmpl, fullVersion, fullVersion)
if preReleaseVersion != "" {
return
}
writeTemplate(tmpl, majorMinorVersion, majorMinorVersion)
writeTemplate(tmpl, fullVersion, "latest")
}

func writeTemplate(tmpl *template.Template, version string, yamlVersion string) {
Expand Down

0 comments on commit b96ac35

Please sign in to comment.