Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Add GoReleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencejones committed Mar 6, 2019
1 parent 676b39e commit 2e36896
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,37 @@ jobs:
name: Run tests
command: ginkgo -race -r

release:
<<: *docker_golang
working_directory: /go/src/github.com/gocardless/pgreplay-go
steps:
- checkout
- run:
name: Release
command: |
CURRENT_VERSION="v$(cat VERSION)"
if [[ $(git tag -l "${CURRENT_VERSION}") == "${CURRENT_VERSION}" ]]; then
echo "Version ${CURRENT_VERSION} is already released"
exit 0
fi
curl -L -o /tmp/goreleaser_Linux_x86_64.tar.gz https://github.com/goreleaser/goreleaser/releases/download/v0.101.0/goreleaser_Linux_x86_64.tar.gz
tar zxf /tmp/goreleaser_Linux_x86_64.tar.gz -C /tmp
git log --pretty=oneline --abbrev-commit --no-decorate --no-color "$(git describe --tags --abbrev=0)..HEAD" -- pkg cmd vendor internal > /tmp/release-notes
git tag "${CURRENT_VERSION}"
git push --tags
/tmp/goreleaser --rm-dist --release-notes /tmp/release-notes
workflows:
version: 2
build-integration:
jobs:
- unit-integration
- release:
requires:
- unit-integration
filters:
branches: {only: master}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
bin/
dist/
44 changes: 44 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# View goreleaser docs for configuration settings
# https://goreleaser.com

---
project_name: pgreplay

builds:
- binary: pgreplay
main: cmd/pgreplay/main.go
goos:
- darwin
- linux
goarch:
- amd64
ldflags: >
-X github.com/gocardless/pgreplay/cmd/main.Version={{.Version}}
-X github.com/gocardless/pgreplay/cmd/main.Commit={{.Commit}}
-X github.com/gocardless/pgreplay/cmd/main.Date={{.Date}}
-a
-installsuffix cgo
env:
- CGO_ENABLED=0

nfpm:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
vendor: GoCardless
homepage: https://github.com/gocardless/pgreplay-go
maintainer: GoCardless Engineering <[email protected]>
description: &description PostgreSQL load testing tool
formats:
- deb

brew:
github:
owner: gocardless
name: homebrew-taps
commit_author:
name: GoCardless Engineering
email: [email protected]
folder: Formula
homepage: https://github.com/gocardless/pgreplay-go
description: *description
test: system "#{bin}/pgreplay version"
install: bin.install "pgreplay"
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
20 changes: 18 additions & 2 deletions cmd/pgreplay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
stdlog "log"
"net/http"
"os"
"runtime"
"time"

"github.com/alecthomas/kingpin"
Expand All @@ -19,10 +20,9 @@ import (
)

var logger kitlog.Logger
var Version string // assigned during build

var (
app = kingpin.New("pgreplay", "Replay Postgres logs against database").Version(Version)
app = kingpin.New("pgreplay", "Replay Postgres logs against database").Version(versionStanza())

// Global flags applying to every command
debug = app.Flag("debug", "Enable debug logging").Default("false").Bool()
Expand Down Expand Up @@ -185,6 +185,22 @@ func main() {
}
}

// Set by goreleaser
var (
Version = "dev"
Commit = "none"
Date = "unknown"
GoVersion = runtime.Version()
VersionStanza string
)

func versionStanza() string {
return fmt.Sprintf(
"pgreplay Version: %v\nGit SHA: %v\nGo Version: %v\nGo OS/Arch: %v/%v\nBuilt at: %v",
Version, Commit, GoVersion, runtime.GOOS, runtime.GOARCH, Date,
)
}

func checkSingleFormat(formats ...*string) (result *string) {
var supplied = 0
for _, format := range formats {
Expand Down

0 comments on commit 2e36896

Please sign in to comment.