using goreleaser for semver builds on sloop. (#121)

* using goreleaser for semver builds on sloop. Integrated with travis ci and docker.

* fix: deploy script update to ignore new lines

* fix: deploy script update to ignore new lines

* fix: using make target instead of shell script as travis having issues with new lines

* fix: removed travis environment variable from makefile

* fix: updated build script
This commit is contained in:
Sridhar Vemula 2020-07-08 12:00:58 -07:00 коммит произвёл GitHub
Родитель b6b19fc13a
Коммит 9c6030bd1c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 82 добавлений и 23 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -4,3 +4,4 @@
/data/
coverage.out
sloop.iml
dist

52
.goreleaser.yml Normal file
Просмотреть файл

@ -0,0 +1,52 @@
project_name: sloop
builds:
- id: sloop
main: ./pkg/sloop/main.go
binary: sloop
ldflags:
- -s -installsuffix=cgo
goos:
- linux
- darwin
- windows
goarch:
- amd64
archives:
- id: sloop
builds:
- sloop
files:
- ./pkg/sloop/webfiles/**/*
dockers:
- goos: linux
goarch: amd64
builds:
- sloop
binaries:
- sloop
extra_files:
- pkg/sloop/webfiles
image_templates:
- "salesforce/sloop:latest"
- "salesforce/sloop:{{ .Tag }}"
dockerfile: Dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: desc
filters:
exclude:
- typo
- fix
- '^docs:'
- '^test:'
- Merge pull request
- Merge branch

Просмотреть файл

@ -10,10 +10,12 @@ script:
- make
before_deploy:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- test -n "$TRAVIS_TAG" && echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
deploy:
provider: script
script: make docker-push
skip_cleanup: true
script:
- make release
on:
branch: master
tags: true

Просмотреть файл

@ -1,20 +1,12 @@
FROM golang:1.13 AS build
WORKDIR /sloop
COPY go.mod go.sum ./
RUN go mod download
COPY pkg ./pkg
RUN curl -o /sloop/aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/aws-iam-authenticator \
FROM alpine as build
RUN apk add --no-cache curl
RUN curl -o /aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.14.6/2019-08-22/bin/linux/amd64/aws-iam-authenticator \
&& wait \
&& chmod +x /sloop/aws-iam-authenticator
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s" -installsuffix cgo -o sloop ./pkg/sloop
&& chmod +x /aws-iam-authenticator
FROM gcr.io/distroless/base
COPY --from=build /sloop/sloop /sloop
COPY --from=build /sloop/pkg/sloop/webfiles /pkg/sloop/webfiles
COPY --from=build /sloop/aws-iam-authenticator /aws-iam-authenticator
COPY sloop /sloop
COPY pkg/sloop/webfiles /pkg/sloop/webfiles
COPY --from=build /aws-iam-authenticator /aws-iam-authenticator
ENV PATH="/:${PATH}"
CMD ["/sloop"]

Просмотреть файл

@ -13,12 +13,16 @@ run:
linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install -ldflags "-s" -installsuffix cgo -v ./pkg/...
docker:
docker build . -t sloop
goreleaser:
@if [ ! -f "$(GOPATH)/bin/goreleaser" ];then \
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh -s -- -b "$(GOPATH)/bin/"; \
fi
docker-push: docker
docker tag sloop:latest sloopimage/sloop:latest
docker push sloopimage/sloop:latest
docker-snapshot: goreleaser
$(GOPATH)/bin/goreleaser release --snapshot --rm-dist
docker: goreleaser
$(GOPATH)/bin/goreleaser release --rm-dist --skip-publish
generate:
go generate ./pkg/...
@ -35,3 +39,11 @@ protobuf:
cover:
go test ./pkg/... -coverprofile=coverage.out
go tool cover -html=coverage.out
release:
@if [ ! -z "$(GITHUB_TOKEN)" ];then \
curl -sfL https://git.io/goreleaser | sh -s -- release --rm-dist;\
else \
curl -sfL https://git.io/goreleaser | sh -s -- release --rm-dist --skip-publish && \
docker push salesforce/sloop;\
fi