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:
Родитель
b6b19fc13a
Коммит
9c6030bd1c
|
@ -4,3 +4,4 @@
|
|||
/data/
|
||||
coverage.out
|
||||
sloop.iml
|
||||
dist
|
|
@ -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
|
22
Dockerfile
22
Dockerfile
|
@ -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"]
|
||||
|
|
22
Makefile
22
Makefile
|
@ -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
|
Загрузка…
Ссылка в новой задаче