Skip to content

Commit

Permalink
add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
oleewere committed Dec 8, 2018
1 parent dcebf03 commit fdd4408
Show file tree
Hide file tree
Showing 4 changed files with 356 additions and 11 deletions.
67 changes: 67 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
builds:
- main: main.go
binary: solr-client
goos:
- linux
goarch:
- amd64
ldflags:
- -s -X main.Version={{.Version}} -X main.GitRevString={{.Commit}}
env:
- CGO_ENABLED=0
- main: main.go
binary: solr-client
goos:
- darwin
goarch:
- amd64
ldflags:
- -s -X main.Version={{.Version}} -X main.GitRevString={{.Commit}}
env:
- CGO_ENABLED=0
- main: main.go
binary: solr-client
goos:
- windows
goarch:
- amd64
ldflags:
- -s -X main.Version={{.Version}} -X main.GitRevString={{.Commit}}
env:
- CGO_ENABLED=0
archive:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
replacements:
amd64: 64-bit
386: 32-bit
darwin: macOS
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'SHA256.txt'
snapshot:
name_template: SNAPSHOT-{{.Commit}}
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
brew:
name: solr-client
github:
owner: oleewere
name: homebrew-repo
commit_author:
name: oleewere
email: [email protected]
folder: Formula
homepage: "https://github.com/oleewere"
description: "Software to manage multiple Ambari servers."
test: |
system "#{bin}/solr-client --version"
install: |
bin.install "solr-client"
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ FROM golang:1.10-alpine

ADD . /go/src/github.com/oleewere/go-solr-client
WORKDIR /go/src/github.com/oleewere/go-solr-client
RUN go build -o /go-solr-client .
RUN go build -o /solr-client .

FROM alpine:3.7
RUN apk add --no-cache ca-certificates

COPY --from=0 /go-solr-client /
COPY --from=0 /solr-client /

ENTRYPOINT ["/go-solr-client"]
ENTRYPOINT ["/solr-client"]
48 changes: 40 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,59 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION = 1.0.0
GIT_REV_SHORT = $(shell git rev-parse --short HEAD)
GITHUB_TOKEN := $(shell git config --global --get github.token || echo $$GITHUB_TOKEN)

install:
go install
ifeq ("$(shell git rev-list --tags --max-count=1)", "")
LAST_RELEASE="v0.0.0"
else
LAST_RELEASE=$(shell git describe --tags $(shell git rev-list --tags --max-count=1))
endif

SNAPSHOT_VERSION=$(shell echo $(LAST_RELEASE) | awk '{split($$0,a,"."); print "v"a[1]+1"."0"."0}')

ifeq ("$(shell git name-rev --tags --name-only $(shell git rev-parse HEAD))", "undefined")
VERSION_FOR_BUILD="$(SNAPSHOT_VERSION)-SNAPSHOT"
else
VERSION_FOR_BUILD=$(shell git name-rev --tags --name-only $(shell git rev-parse HEAD) | sed 's/\^.*$///')
endif

build-generator:
go build -ldflags "-X main.GitRevString=$(GIT_REV_SHORT) -X main.Version=$(VERSION) -X main.ActionType=generator" -o solr-docs-generator .
install:
go install -ldflags "-X main.GitRevString=$(GIT_REV_SHORT) -X main.Version=$(VERSION_FOR_BUILD)" .

build:
go build -ldflags "-X main.GitRevString=$(GIT_REV_SHORT) -X main.Version=$(VERSION)" .
go build -ldflags "-X main.GitRevString=$(GIT_REV_SHORT) -X main.Version=$(VERSION_FOR_BUILD)" -o solr-client .

test:
go test

all: build test
all: build test

clean:
rm -rf dist

last-release:
@echo "Last release version: $(LAST_RELEASE)"

version:
@echo "Release/Snapshot version: $(VERSION_FOR_BUILD)"

binary:
./scripts/release.sh --release-build-only

major-release:
./scripts/release.sh --release-major

minor-release:
./scripts/release.sh --release-minor

patch-release:
./scripts/release.sh --release-patch
Loading

0 comments on commit fdd4408

Please sign in to comment.