Skip to content

Commit

Permalink
Add release action (#7)
Browse files Browse the repository at this point in the history
* Add release action

* tweak version info

* update goreleaser config

* add release section

* disable goreleaser on PRs
  • Loading branch information
patricksanders authored Oct 19, 2020
1 parent 7a143a5 commit cbbd933
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 30 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: goreleaser

on:
push:
tags:
- '*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
flags:
- -trimpath
ldflags:
- -s -w -X github.com/netflix/weep/version.Version={{.Version}} -X github.com/netflix/weep/version.Commit={{.CommitDate}} -X github.com/netflix/weep/version.Date={{.Date}}
mod_timestamp: '{{ .CommitTimestamp }}'
hooks:
post:
- upx "{{ .Path }}"
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
release:
draft: true
prerelease: auto
2 changes: 1 addition & 1 deletion consoleme/consoleme.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/netflix/weep/version"
)

var clientVersion = fmt.Sprintf("%s-%s", version.Version, version.VersionPrerelease)
var clientVersion = fmt.Sprintf("%s", version.Version)

var userAgent = "weep/" + clientVersion + " Go-http-client/1.1"

Expand Down
41 changes: 12 additions & 29 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,42 @@ import (
)

var (
GitCommit string
GitDescribe string
BuildDate string
Version string
VersionPrerelease string
Commit string
Date string
Version string
)

// VersionInfo contains information about the program's version.
type VersionInfo struct {
Revision string
Version string
VersionPrerelease string
BuildDate string
Revision string
Version string
BuildDate string
}

// GetVersion returns the program's version information via a VersionInfo pointer.
func GetVersion() *VersionInfo {
ver := Version
rel := VersionPrerelease

if GitDescribe != "" {
ver = GitDescribe
}
if GitDescribe == "" && rel == "" && VersionPrerelease != "" {
rel = "dev"
}

return &VersionInfo{
Revision: GitCommit,
Version: ver,
VersionPrerelease: rel,
BuildDate: BuildDate,
Revision: Commit,
Version: ver,
BuildDate: Date,
}
}

func (c *VersionInfo) String() string {
var versionString bytes.Buffer

if Version == "" && VersionPrerelease == "" {
if Version == "" {
fmt.Fprintf(&versionString, "weep (version unknown)")
}
fmt.Fprintf(&versionString, "weep v%s", c.Version)

if c.VersionPrerelease != "" {
fmt.Fprintf(&versionString, "-%s", c.VersionPrerelease)

}
fmt.Fprintf(&versionString, "weep %s", c.Version)

if c.Revision != "" {
fmt.Fprintf(&versionString, " (%s)", c.Revision)
}

fmt.Fprintf(&versionString, " Built on: %s", BuildDate)
fmt.Fprintf(&versionString, " Built on: %s", Date)

if config.EmbeddedConfigFile != "" {
fmt.Fprintf(&versionString, " with embedded mTLS config %s", config.EmbeddedConfigFile)
Expand Down

0 comments on commit cbbd933

Please sign in to comment.