Skip to content

Commit

Permalink
Merge pull request #28 from ernoaapa/cleanup-ci
Browse files Browse the repository at this point in the history
Cleanup CI build, test & release pipeline
  • Loading branch information
ernoaapa authored Feb 12, 2018
2 parents 41b038d + 1cfe743 commit f7d445c
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 451 deletions.
100 changes: 14 additions & 86 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
defaults: &defaults
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/ernoaapa/eliot

version: 2
jobs:
test:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/ernoaapa/eliot
<<: *defaults
steps:
- checkout

Expand All @@ -12,84 +15,22 @@ jobs:
- run: go test -v ./...

build:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/ernoaapa/eliot
<<: *defaults
steps:
- checkout

- setup_remote_docker

- run:
name: Install tools
command: go get github.com/mitchellh/gox

- run:
name: Build binaries
command: |
export VERSION=$(git describe --tags --always --dirty)
export CGO_ENABLED=0
gox -osarch="darwin/amd64 linux/amd64 linux/arm64" -ldflags "-X github.com/ernoaapa/eliot/pkg/version.VERSION=${VERSION}" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/...
- run:
name: Verify binaries
command: |
./dist/eliotd_linux_amd64 -h
- run: go get github.com/goreleaser/goreleaser
- run: goreleaser --snapshot --skip-publish

- run:
name: Build images
command: ./.circleci/scripts/docker-build.sh

- save_cache:
key: binaries-{{ .Revision }}
paths:
- dist

publish-binaries:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/ernoaapa/eliot
steps:

- restore_cache:
key: binaries-{{ .Revision }}

- run:
name: Install tools
command: go get github.com/tcnksm/ghr

- run:
name: Push binaries to GitHub
command: |
ghr -token $GITHUB_TOKEN -username $CIRCLE_PROJECT_USERNAME -repository $CIRCLE_PROJECT_REPONAME $CIRCLE_TAG dist/
publish-images:
docker:
- image: circleci/golang:1.9
working_directory: /go/src/github.com/ernoaapa/eliot
publish:
<<: *defaults
steps:
- checkout

- setup_remote_docker

- restore_cache:
key: binaries-{{ .Revision }}

- run:
name: Install tools
command: go get github.com/estesp/manifest-tool

- run:
name: Login Docker hub
command: echo $DOCKER_PASS | docker login --username $DOCKER_USER --password-stdin

- run:
name: Build images
command: ./.circleci/scripts/docker-build.sh

- run:
name: Push images
command: ./.circleci/scripts/docker-push.sh
- run: go get github.com/goreleaser/goreleaser
- run: goreleaser

workflows:
version: 2
Expand All @@ -109,20 +50,7 @@ workflows:
tags:
only: /.*/

- publish-binaries:
requires:
- test
- build

# Don't run when branches updates, only when tags get created
filters:
branches:
ignore: /.*/
tags:
only:
- /v.*/

- publish-images:
- publish:
requires:
- test
- build
Expand Down
48 changes: 0 additions & 48 deletions .circleci/scripts/docker-build.sh

This file was deleted.

28 changes: 0 additions & 28 deletions .circleci/scripts/docker-push.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/dist
/bin
/.go
/.push-*
/.container-*
/.dockerfile-*

node_modules
# Ignore because just used with gitbook
Expand Down
58 changes: 58 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
builds:
- binary: eli
main: ./cmd/eli
goos:
- darwin
- linux
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0

- binary: eliotd
main: ./cmd/eliotd
goos:
- linux
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=0

archive:
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

brew:
github:
owner: ernoaapa
name: homebrew-eliot
homepage: "http://eliot.run"
description: "Container management system for IoT devices"
test: |
system "#{bin}/eli --version"
dockers:
- binary: eli
goos: linux
goarch: amd64
image: ernoaapa/eli
dockerfile: Dockerfile.eli
tag_templates:
- "v{{ .Version }}"

- binary: eliotd
goos: linux
goarch: amd64
image: ernoaapa/eliotd
dockerfile: Dockerfile.eliotd
tag_templates:
- "v{{ .Version }}-amd64"

- binary: eliotd
goos: linux
goarch: arm64
image: ernoaapa/eliotd
dockerfile: Dockerfile.eliotd
tag_templates:
- "v{{ .Version }}-arm64"
4 changes: 2 additions & 2 deletions Dockerfile.in → Dockerfile.eli
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

LABEL maintainer="Erno Aapa <[email protected]>"

ADD bin/ARG_OS-ARG_ARCH/ARG_BIN /ARG_BIN
COPY eli /

ENTRYPOINT ["/ARG_BIN"]
ENTRYPOINT ["/eli"]
4 changes: 2 additions & 2 deletions Dockerfile.tmpl → Dockerfile.eliotd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

LABEL maintainer="Erno Aapa <[email protected]>"

ADD dist/ARG_BIN_ARG_OS_ARG_ARCH /ARG_BIN
COPY eliotd /

ENTRYPOINT ["/ARG_BIN"]
ENTRYPOINT ["/eliotd"]
Loading

0 comments on commit f7d445c

Please sign in to comment.