Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1048 from cloudflare/cbroglie/goreleaser
Support building/releasing binaries with goreleaser
  • Loading branch information
cbroglie committed Oct 31, 2019
2 parents 2318616 + ce0e294 commit d9af611
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 26 deletions.
279 changes: 279 additions & 0 deletions .goreleaser.yml
@@ -0,0 +1,279 @@
env:
- GO111MODULE=on
- CGO_ENABLED=1
- GOFLAGS=-mod=vendor
- GOPROXY=off
builds:
- id: cfssl-darwin
binary: cfssl
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/cfssl
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-linux
binary: cfssl
goos:
- linux
goarch:
- amd64
main: ./cmd/cfssl
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-windows
binary: cfssl
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/cfssl
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-bundle-darwin
binary: cfssl-bundle
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/cfssl-bundle
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-bundle-linux
binary: cfssl-bundle
goos:
- linux
goarch:
- amd64
main: ./cmd/cfssl-bundle
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-bundle-windows
binary: cfssl-bundle
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/cfssl-bundle
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-certinfo-darwin
binary: cfssl-certinfo
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/cfssl-certinfo
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-certinfo-linux
binary: cfssl-certinfo
goos:
- linux
goarch:
- amd64
main: ./cmd/cfssl-certinfo
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-certinfo-windows
binary: cfssl-certinfo
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/cfssl-certinfo
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-newkey-darwin
binary: cfssl-newkey
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/cfssl-newkey
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-newkey-linux
binary: cfssl-newkey
goos:
- linux
goarch:
- amd64
main: ./cmd/cfssl-newkey
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-newkey-windows
binary: cfssl-newkey
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/cfssl-newkey
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-scan-darwin
binary: cfssl-scan
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/cfssl-scan
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-scan-linux
binary: cfssl-scan
goos:
- linux
goarch:
- amd64
main: ./cmd/cfssl-scan
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssl-scan-windows
binary: cfssl-scan
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/cfssl-scan
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssljson-darwin
binary: cfssljson
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/cfssljson
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssljson-linux
binary: cfssljson
goos:
- linux
goarch:
- amd64
main: ./cmd/cfssljson
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: cfssljson-windows
binary: cfssljson
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/cfssljson
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: mkbundle-darwin
binary: mkbundle
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/mkbundle
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: mkbundle-linux
binary: mkbundle
goos:
- linux
goarch:
- amd64
main: ./cmd/mkbundle
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: mkbundle-windows
binary: mkbundle
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/mkbundle
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: multirootca-darwin
binary: multirootca
env:
- CC=o64-clang
- CXX=o64-clang++
goos:
- darwin
goarch:
- amd64
main: ./cmd/multirootca
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: multirootca-linux
binary: multirootca
goos:
- linux
goarch:
- amd64
main: ./cmd/multirootca
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
- id: multirootca-windows
binary: multirootca
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
goos:
- windows
goarch:
- amd64
main: ./cmd/multirootca
ldflags:
- -s -w -X github.com/cloudflare/cfssl/cli/version.version={{.Version}}
archives:
- format: binary
release:
github:
owner: cloudflare
name: cfssl
prerelease: auto
changelog:
sort: asc
20 changes: 20 additions & 0 deletions Makefile
Expand Up @@ -30,3 +30,23 @@ bin/goose: $(shell find . -type f -name '*.go')
.PHONY: clean
clean:
rm -rf bin

# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
#
# cf: https://stackoverflow.com/questions/10858261/abort-makefile-if-variable-not-set
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))

.PHONY: release
release:
@:$(call check_defined, GITHUB_TOKEN)
docker run -e GITHUB_TOKEN=$(GITHUB_TOKEN) --rm -v $(PWD):/workdir -w /workdir cbroglie/goreleaser-cgo:1.12.12 goreleaser --rm-dist
16 changes: 4 additions & 12 deletions cli/version/version.go
Expand Up @@ -8,17 +8,9 @@ import (
"github.com/cloudflare/cfssl/cli"
)

// Version stores the semantic versioning information for CFSSL.
var version = struct {
Major int
Minor int
Patch int
Revision string
}{1, 3, 4, "release"}

func versionString() string {
return fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch)
}
var (
version = "dev"
)

// Usage text for 'cfssl version'
var versionUsageText = `cfssl version -- print out the version of CF SSL
Expand All @@ -29,7 +21,7 @@ Usage of version:

// FormatVersion returns the formatted version string.
func FormatVersion() string {
return fmt.Sprintf("Version: %s\nRevision: %s\nRuntime: %s\n", versionString(), version.Revision, runtime.Version())
return fmt.Sprintf("Version: %s\nRuntime: %s\n", version, runtime.Version())
}

// The main functionality of 'cfssl version' is to print out the version info.
Expand Down
7 changes: 0 additions & 7 deletions cli/version/version_dev.go

This file was deleted.

7 changes: 0 additions & 7 deletions cli/version/version_test.go
Expand Up @@ -6,13 +6,6 @@ import (
"github.com/cloudflare/cfssl/cli"
)

func TestVersionString(t *testing.T) {
version := versionString()
if version != "1.3.4" {
t.Fatal("version string is not returned correctly")
}
}

func TestVersionMain(t *testing.T) {
args := []string{"cfssl", "version"}
err := versionMain(args, cli.Config{})
Expand Down

0 comments on commit d9af611

Please sign in to comment.