From 3e885c50401bff9203ab9263d5f9e75cc59a90c8 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Sun, 28 Jan 2018 00:27:53 +0100 Subject: [PATCH 01/16] Support ARM arch --- Dockerfile => DockerfileAMD | 2 +- DockerfileARM | 15 +++++++++++++++ Makefile | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 7 deletions(-) rename Dockerfile => DockerfileAMD (92%) create mode 100644 DockerfileARM diff --git a/Dockerfile b/DockerfileAMD similarity index 92% rename from Dockerfile rename to DockerfileAMD index 9d3a3fa..76f4956 100644 --- a/Dockerfile +++ b/DockerfileAMD @@ -1,4 +1,4 @@ -FROM golang:1.8 as builder +FROM golang:1.9 as builder ADD . /go/src/github.com/justwatchcom/github-releases-notifier WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier diff --git a/DockerfileARM b/DockerfileARM new file mode 100644 index 0000000..ec885cc --- /dev/null +++ b/DockerfileARM @@ -0,0 +1,15 @@ +FROM golang:1.9 as builder + +ADD . /go/src/github.com/justwatchcom/github-releases-notifier +WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier + +RUN make buildarm + +FROM arm32v6/alpine:3.7 +RUN apk --no-cache add ca-certificates + +COPY --from=builder \ + /go/src/github.com/justwatchcom/github-releases-notifier/github-releases-notifier \ + /bin/github-releases-notifier + +ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/Makefile b/Makefile index fe27dd7..d9ea0c0 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ GOLDFLAGS += -X "main.date=$(DATE)" GOLDFLAGS += -X "main.commit=$(SHA)" GOLDFLAGS += -extldflags '-static' -GO := CGO_ENABLED=0 go +GO := CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go +GOARM := CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go GOOS ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f1) GOARCH ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f2) @@ -23,12 +24,13 @@ PACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /tests) TAGS ?= netgo .PHONY: all -all: clean test build +all: clean test build buildarm .PHONY: clean clean: $(GO) clean -i ./... find . -type f -name "coverage.out" -delete + if [ -f Dockerfile ]; then rm Dockerfile ; fi .PHONY: fmt fmt: @@ -66,8 +68,30 @@ megacheck: test: STATUS=0; for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || STATUS=1; done; exit $$STATUS -.PHONY: build -build: $(EXECUTABLE)-$(GOOS)-$(GOARCH) - -$(EXECUTABLE)-$(GOOS)-$(GOARCH): $(wildcard *.go) +.PHONE: buildlinux +buildlinux: $(GO) build -tags '$(TAGS)' -ldflags '-s -w $(GOLDFLAGS)' -o $(EXECUTABLE) + +.PHONY: buildarm +buildarm: + $(GOARM) build -tags '$(TAGS)' -ldflags '-s -w $(GOLDFLAGS)' -o $(EXECUTABLE) + +.PHONY: build +build: buildlinux buildarm + +.PHONY: releaseamd64 +releaseamd64: + if [ -f Dockerfile ]; then rm Dockerfile ; fi + ln -s DockerfileAMD Dockerfile + docker build . -t pcarranza/github-releases-notifier:latest + docker push pcarranza/github-releases-notifier:latest + +.PHONY: releasearm +releasearm: + if [ -f Dockerfile ]; then rm Dockerfile ; fi + ln -s DockerfileARM Dockerfile + docker build . -t pcarranza/github-releases-notifier-armv6:latest + docker tag pcarranza/github-releases-notifier-armv6:latest \ + pcarranza/github-releases-notifier-armv6:$(VERSION) + docker push pcarranza/github-releases-notifier-armv6:latest + docker push pcarranza/github-releases-notifier-armv6:$(VERSION) From 61b0381cf685430033f630feb33c1364084007e2 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 22:54:55 +0200 Subject: [PATCH 02/16] Add support for goreleaser --- DockerfileAMD => Dockerfile.amd64 | 0 Dockerfile.arm64 | 15 +++++++++ DockerfileARM => Dockerfile.armv6 | 0 Makefile | 51 +++++-------------------------- 4 files changed, 22 insertions(+), 44 deletions(-) rename DockerfileAMD => Dockerfile.amd64 (100%) create mode 100644 Dockerfile.arm64 rename DockerfileARM => Dockerfile.armv6 (100%) diff --git a/DockerfileAMD b/Dockerfile.amd64 similarity index 100% rename from DockerfileAMD rename to Dockerfile.amd64 diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..98d48ce --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,15 @@ +FROM golang:1.9 as builder + +ADD . /go/src/github.com/justwatchcom/github-releases-notifier +WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier + +RUN make buildarm + +FROM arm64v8/alpine:3.7 +RUN apk --no-cache add ca-certificates + +COPY --from=builder \ + /go/src/github.com/justwatchcom/github-releases-notifier/github-releases-notifier \ + /bin/github-releases-notifier + +ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/DockerfileARM b/Dockerfile.armv6 similarity index 100% rename from DockerfileARM rename to Dockerfile.armv6 diff --git a/Makefile b/Makefile index d9ea0c0..4145ca0 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,13 @@ -DIST := dist -BIN := bin - -EXECUTABLE := github-releases-notifier - PWD := $(shell pwd) -VERSION := $(shell cat VERSION) -SHA := $(shell cat COMMIT 2>/dev/null || git rev-parse --short=8 HEAD) -DATE := $(shell date -u '+%FT%T%z') - -GOLDFLAGS += -X "main.version=$(VERSION)" -GOLDFLAGS += -X "main.date=$(DATE)" -GOLDFLAGS += -X "main.commit=$(SHA)" -GOLDFLAGS += -extldflags '-static' -GO := CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go -GOARM := CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go - -GOOS ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f1) -GOARCH ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f2) +GO := go PACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /tests) TAGS ?= netgo .PHONY: all -all: clean test build buildarm +all: clean test build .PHONY: clean clean: @@ -68,30 +51,10 @@ megacheck: test: STATUS=0; for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || STATUS=1; done; exit $$STATUS -.PHONE: buildlinux -buildlinux: - $(GO) build -tags '$(TAGS)' -ldflags '-s -w $(GOLDFLAGS)' -o $(EXECUTABLE) - -.PHONY: buildarm -buildarm: - $(GOARM) build -tags '$(TAGS)' -ldflags '-s -w $(GOLDFLAGS)' -o $(EXECUTABLE) - .PHONY: build -build: buildlinux buildarm - -.PHONY: releaseamd64 -releaseamd64: - if [ -f Dockerfile ]; then rm Dockerfile ; fi - ln -s DockerfileAMD Dockerfile - docker build . -t pcarranza/github-releases-notifier:latest - docker push pcarranza/github-releases-notifier:latest +build: + goreleaser --snapshot --rm-dist -.PHONY: releasearm -releasearm: - if [ -f Dockerfile ]; then rm Dockerfile ; fi - ln -s DockerfileARM Dockerfile - docker build . -t pcarranza/github-releases-notifier-armv6:latest - docker tag pcarranza/github-releases-notifier-armv6:latest \ - pcarranza/github-releases-notifier-armv6:$(VERSION) - docker push pcarranza/github-releases-notifier-armv6:latest - docker push pcarranza/github-releases-notifier-armv6:$(VERSION) +.PHONY: release +release: + goreleaser --rm-dist From 22312e05265ba53b36b9fa687dcbf03a4ce33d7c Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 22:58:18 +0200 Subject: [PATCH 03/16] Ignore the dist folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6f4d55d..6bd64e1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +dist From 4c1f8abdfb44eed5d458783423528364c1ccd7dc Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:02:13 +0200 Subject: [PATCH 04/16] Silly me, I forgot about hidden files --- .goreleaser.yml | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .goreleaser.yml diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..cfc824f --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,63 @@ +project_name: github-releases-notifier +release: + github: + owner: justwatchcom + name: github-releases-notifier + name_template: '{{ .Tag }}' +builds: +- goos: + - linux + - darwin + goarch: + - amd64 + - arm + - arm64 + goarm: + - "6" + main: . + binary: github-releases-notifier + ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -extldflags '-static' + +snapshot: + name_template: SNAPSHOT-{{ .Commit }} + +checksum: + name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' +dist: dist +changelog: + filters: + exclude: + - typo + - Fix + - Merge + - WIP +archive: + name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + format: tar.gz + files: + - license* + - LICENSE* + - readme* + - README* + - changelog* + - CHANGELOG* +dockers: +- image: justwatchcom/github-releases-notifier + goos: linux + goarch: amd64 + goarm: '' + binary: propaganda + dockerfile: Dockerfile.amd64 +- image: justwatchcom/github-releases-notifier-armv6 + goos: linux + goarch: arm + goarm: '6' + binary: propaganda + dockerfile: Dockerfile.armv6 +- image: justwatchcom/github-releases-notifier-arm64 + goos: linux + goarch: arm64 + binary: propaganda + dockerfile: Dockerfile.arm64 +env_files: + github_token: ~/.goreleaser.token From 5c4ad26fc10b100fcc3e8e31925df5a75609d28b Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:06:34 +0200 Subject: [PATCH 05/16] Add goreleaser to travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3413972..139481e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ language: go go: - - 1.8.x + - 1.10.x before_install: - go get -v github.com/golang/lint/golint + - curl -sL http://git.io/goreleaser | bash script: - make clean From 6c7a59342cebe72ee4383b42d2b93acf6b38ec19 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:07:34 +0200 Subject: [PATCH 06/16] Add docker as a service for travis build --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 139481e..30a4f6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ language: go go: - 1.10.x +services: + - docker + before_install: - go get -v github.com/golang/lint/golint - curl -sL http://git.io/goreleaser | bash From e9b8a8e2608c20a4efc89df9a4f68cd2054c613e Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:28:49 +0200 Subject: [PATCH 07/16] Add double dash to prevent goreleaser from trying to release --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 30a4f6e..7093de3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ services: before_install: - go get -v github.com/golang/lint/golint - - curl -sL http://git.io/goreleaser | bash + - curl -sL http://git.io/goreleaser | bash -s -- -v script: - make clean From ce01dca53b64f04cbf88bc49dcf90556f3fac4ff Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:33:42 +0200 Subject: [PATCH 08/16] mv goreleaser to a bin path after downloading --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7093de3..3d362b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ services: before_install: - go get -v github.com/golang/lint/golint - curl -sL http://git.io/goreleaser | bash -s -- -v + - mv "${TMPDIR}/goreleaser" /go/bin/ script: - make clean From 2fd9f40a2b8d2bd3e5aa0c50909c5fea93023fc1 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:34:48 +0200 Subject: [PATCH 09/16] Use the GOPATH variable in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3d362b0..b0ead57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ services: before_install: - go get -v github.com/golang/lint/golint - curl -sL http://git.io/goreleaser | bash -s -- -v - - mv "${TMPDIR}/goreleaser" /go/bin/ + - mv ${TMPDIR}/goreleaser ${GOPATH}/bin/ script: - make clean From 9b6a8decbb5f422ea92abf4faeea73f4db17fc59 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:45:21 +0200 Subject: [PATCH 10/16] Let's try this other way to get goreleaser running --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0ead57..a29bd8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,12 @@ services: - docker before_install: + - go get -u github.com/golang/dep/cmd/dep - go get -v github.com/golang/lint/golint - - curl -sL http://git.io/goreleaser | bash -s -- -v - - mv ${TMPDIR}/goreleaser ${GOPATH}/bin/ + - go get -d github.com/goreleaser/goreleaser + - cd $GOPATH/src/github.com/goreleaser/goreleaser + - dep ensure -vendor-only + - make setup build script: - make clean From ca0c88d62b6d7e4974dc027925cdf495cebad7c0 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:51:14 +0200 Subject: [PATCH 11/16] Go back to the previous dir --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a29bd8e..a4ff4e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ before_install: - cd $GOPATH/src/github.com/goreleaser/goreleaser - dep ensure -vendor-only - make setup build + - cd - script: - make clean From 6d9c551492c59481401d23a01f8d745ae73e4bb9 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Thu, 4 Oct 2018 23:55:28 +0200 Subject: [PATCH 12/16] Install goreleaser manually --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a4ff4e5..15578b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ before_install: - cd $GOPATH/src/github.com/goreleaser/goreleaser - dep ensure -vendor-only - make setup build + - go install - cd - script: From d4cd49d9ad84b1a9d6ddaff76549d259ab92ab18 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Fri, 5 Oct 2018 17:09:54 +0200 Subject: [PATCH 13/16] Silly me, not enough sedops --- .goreleaser.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index cfc824f..755791a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -46,18 +46,18 @@ dockers: goos: linux goarch: amd64 goarm: '' - binary: propaganda + binary: github-releases-notifier dockerfile: Dockerfile.amd64 - image: justwatchcom/github-releases-notifier-armv6 goos: linux goarch: arm goarm: '6' - binary: propaganda + binary: github-releases-notifier dockerfile: Dockerfile.armv6 - image: justwatchcom/github-releases-notifier-arm64 goos: linux goarch: arm64 - binary: propaganda + binary: github-releases-notifier dockerfile: Dockerfile.arm64 env_files: github_token: ~/.goreleaser.token From 7d307dc8f50625a46baef0cbc1d1a1f63fe2e708 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Fri, 5 Oct 2018 17:54:27 +0200 Subject: [PATCH 14/16] Docker images don't need to be building anymore --- Dockerfile.amd64 | 9 +-------- Dockerfile.arm64 | 11 +---------- Dockerfile.armv6 | 11 +---------- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index 76f4956..7785609 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -1,12 +1,5 @@ -FROM golang:1.9 as builder - -ADD . /go/src/github.com/justwatchcom/github-releases-notifier -WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier - -RUN make build - FROM alpine:3.6 RUN apk --no-cache add ca-certificates -COPY --from=builder /go/src/github.com/justwatchcom/github-releases-notifier /bin/ +COPY dist/linux_amd64/github-releases-notifier /bin/ ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 98d48ce..46b10b2 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -1,15 +1,6 @@ -FROM golang:1.9 as builder - -ADD . /go/src/github.com/justwatchcom/github-releases-notifier -WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier - -RUN make buildarm - FROM arm64v8/alpine:3.7 RUN apk --no-cache add ca-certificates -COPY --from=builder \ - /go/src/github.com/justwatchcom/github-releases-notifier/github-releases-notifier \ - /bin/github-releases-notifier +COPY dist/linux_arm64/github-releases-notifier /bin/ ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/Dockerfile.armv6 b/Dockerfile.armv6 index ec885cc..3e1042e 100644 --- a/Dockerfile.armv6 +++ b/Dockerfile.armv6 @@ -1,15 +1,6 @@ -FROM golang:1.9 as builder - -ADD . /go/src/github.com/justwatchcom/github-releases-notifier -WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier - -RUN make buildarm - FROM arm32v6/alpine:3.7 RUN apk --no-cache add ca-certificates -COPY --from=builder \ - /go/src/github.com/justwatchcom/github-releases-notifier/github-releases-notifier \ - /bin/github-releases-notifier +COPY dist/linux_arm_6/github-releases-notifier /bin/ ENTRYPOINT [ "/bin/github-releases-notifier" ] From 850e450aea22878551b12ac24ba3e932c4783ee2 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Sun, 7 Oct 2018 10:37:04 +0200 Subject: [PATCH 15/16] Invoke tests and only build but don't snapshot in travis --- .travis.yml | 5 +---- Makefile | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 15578b4..3d67e87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,4 @@ before_install: script: - make clean - - make vet - - make lint - - make test - - make build + - make tests diff --git a/Makefile b/Makefile index 4145ca0..5e093bb 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,11 @@ test: STATUS=0; for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || STATUS=1; done; exit $$STATUS .PHONY: build -build: +build: + go build + +.PHONY: snapshot +snapshot: goreleaser --snapshot --rm-dist .PHONY: release From b44238c66ba9df4b4e52c4367887ad83018858c1 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Sun, 7 Oct 2018 11:18:35 +0200 Subject: [PATCH 16/16] Go back to the old style of building things --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3d67e87..15578b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,7 @@ before_install: script: - make clean - - make tests + - make vet + - make lint + - make test + - make build