From 1fe1b6e11a377a597d40a4bdbb3858158542889b Mon Sep 17 00:00:00 2001 From: sh0rez Date: Fri, 2 Aug 2019 11:13:52 +0200 Subject: [PATCH 1/3] chore(release): build and publish artifacts Prepares to use gox to matrix-cross-compile the artifacts, compress and hash them and upload it all up to GitHub using ghr --- .gitignore | 1 + Makefile | 13 +++++++++++++ loki-build-image/Dockerfile | 4 +++- tools/release-note.md | 25 +++++++++++++++++++++++++ tools/release-note.sh | 3 +++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tools/release-note.md create mode 100755 tools/release-note.sh diff --git a/.gitignore b/.gitignore index a9a40e0fb4fe0..8d2250ea16e70 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ cmd/loki-canary/loki-canary /loki-canary dlv rootfs/ +dist diff --git a/Makefile b/Makefile index 1fffc8c9f4172..2c58d1b9ab168 100644 --- a/Makefile +++ b/Makefile @@ -167,6 +167,18 @@ cmd/promtail/promtail-debug: $(APP_GO_FILES) pkg/promtail/server/ui/assets_vfsda CGO_ENABLED=0 go build $(DEBUG_GO_FLAGS) -o $@ ./$(@D) $(NETGO_CHECK) +############# +# Releasing # +############# +GOX = gox $(GO_FLAGS) -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -arch="amd64 arm64 arm" -os="linux" -osarch="darwin/amd64" +dist: clean + CGO_ENABLED=0 $(GOX) ./cmd/loki ./cmd/promtail ./cmd/logcli + gzip dist/* + cd dist && sha256sum * > SHA256SUMS + +publish: dist + @ghr -t $(GITHUB_TOKEN) -u $(CIRCLE_PROJECT_USERNAME) -r $(CIRCLE_PROJECT_REPONAME) -c $(CIRCLE_SHA1) -b='$(shell ./tools/release-note.sh)' -delete -draft $(IMAGE_TAG) ./dist/ + ######## # Lint # ######## @@ -192,6 +204,7 @@ clean: rm -rf cmd/loki-canary/loki-canary rm -rf .cache rm -rf cmd/docker-driver/rootfs + rm -rf dist/ go clean ./... ######### diff --git a/loki-build-image/Dockerfile b/loki-build-image/Dockerfile index 9b149fda87d6d..5873165321741 100644 --- a/loki-build-image/Dockerfile +++ b/loki-build-image/Dockerfile @@ -31,7 +31,9 @@ RUN go get \ github.com/gogo/protobuf/protoc-gen-gogoslick \ github.com/gogo/protobuf/gogoproto \ github.com/go-delve/delve/cmd/dlv \ - golang.org/x/tools/cmd/goyacc && \ + golang.org/x/tools/cmd/goyacc \ + github.com/mitchellh/gox \ + github.com/tcnksm/ghr && \ rm -rf /go/pkg /go/src ENV GOCACHE=/go/cache diff --git a/tools/release-note.md b/tools/release-note.md new file mode 100644 index 0000000000000..fdf1663843d8c --- /dev/null +++ b/tools/release-note.md @@ -0,0 +1,25 @@ +This is release `${TAG}` of Loki. + +### Notable changes: +:warning: **ADD RELEASE NOTES HERE** :warning: + +### Installation: +The components of Loki are currently distrubuted in plain binary form and as Docker container images. Choose what fits your use-case best. + +#### Binary: +```bash +# download a binary (adapt app, os and arch as needed) +$ curl -fSL -o "/usr/local/bin/loki.gz" "https://github.com/grafana/loki/releases/download/${TAG}/loki-linux-amd64.gz" +$ gunzip "/usr/local/bin/loki.gz" + +# make sure it is executable +$ chmod a+x "/usr/local/bin/loki" +``` + +#### Docker container: +* https://hub.docker.com/r/grafana/loki +* https://hub.docker.com/r/grafana/promtail +```bash +$ docker pull "grafana/loki:${TAG}" +$ docker pull "grafana/promtail:${TAG}" +``` diff --git a/tools/release-note.sh b/tools/release-note.sh new file mode 100755 index 0000000000000..477216988fda9 --- /dev/null +++ b/tools/release-note.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +export TAG=$(tools/image-tag) +envsubst < tools/release-note.md From 715744b30b06735156f3ccbf713e5cbf91211819 Mon Sep 17 00:00:00 2001 From: sh0rez Date: Fri, 2 Aug 2019 11:26:56 +0200 Subject: [PATCH 2/3] chore(packaging): release artifacts to github --- .circleci/config.yml | 18 +++++++++++++++++- Makefile | 14 +++++++++----- loki-build-image/Dockerfile | 2 +- tools/release | 9 +++++++++ tools/release-note.md | 10 +++++----- tools/release-note.sh | 3 --- 6 files changed, 41 insertions(+), 15 deletions(-) create mode 100755 tools/release delete mode 100755 tools/release-note.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index a3c3d94aaaff1..c53d69986ea03 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,6 +3,10 @@ version: 2 .tags: &tags # tags need to be explicitely defined (whitelist) tags: {only: "/.*/"} +.only-tags: &only-tags + <<: *tags + branches: { ignore: "/.*/" } + .tag-or-master: &tag-or-master branches: { only: master } <<: *tags @@ -49,6 +53,10 @@ workflows: requires: [ lint, test ] filters: { <<: *tag-or-master } + - publish/binaries: + requires: [ lint, test ] + filters: { <<: *only-tags } + - deploy: requires: - publish/loki @@ -68,7 +76,7 @@ workflows: # https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/ .defaults: &defaults docker: - - image: grafana/loki-build-image:0.4.0 + - image: grafana/loki-build-image:0.5.0 working_directory: /go/src/github.com/grafana/loki .machine: &machine @@ -203,6 +211,14 @@ jobs: name: docker-driver command: make docker-driver-push + publish/binaries: + <<: *defaults + steps: + - checkout + - run: + name: github release + command: make publish + deploy: <<: *defaults steps: diff --git a/Makefile b/Makefile index 2c58d1b9ab168..9cedf94e9df34 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ .PHONY: docker-driver docker-driver-clean docker-driver-enable docker-driver-push .PHONY: push-images push-latest save-images load-images promtail-image loki-image build-image .PHONY: benchmark-store + +SHELL = /usr/bin/env bash ############# # Variables # ############# @@ -16,7 +18,7 @@ IMAGE_NAMES := $(foreach dir,$(DOCKER_IMAGE_DIRS),$(patsubst %,$(IMAGE_PREFIX)%, # make BUILD_IN_CONTAINER=false target # or you can override this with an environment variable BUILD_IN_CONTAINER ?= true -BUILD_IMAGE_VERSION := 0.4.0 +BUILD_IMAGE_VERSION := 0.5.0 # Docker image info IMAGE_PREFIX ?= grafana @@ -170,14 +172,16 @@ cmd/promtail/promtail-debug: $(APP_GO_FILES) pkg/promtail/server/ui/assets_vfsda ############# # Releasing # ############# -GOX = gox $(GO_FLAGS) -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -arch="amd64 arm64 arm" -os="linux" -osarch="darwin/amd64" +# concurrency is limited to 4 to prevent CircleCI from OOMing. Sorry +GOX = gox $(GO_FLAGS) -parallel=4 -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -arch="amd64 arm64 arm" -os="linux" dist: clean - CGO_ENABLED=0 $(GOX) ./cmd/loki ./cmd/promtail ./cmd/logcli + CGO_ENABLED=0 $(GOX) ./cmd/loki + CGO_ENABLED=0 $(GOX) -osarch="darwin/amd64 windows/amd64 freebsd/amd64" ./cmd/promtail ./cmd/logcli gzip dist/* - cd dist && sha256sum * > SHA256SUMS + pushd dist && sha256sum * > SHA256SUMS && popd publish: dist - @ghr -t $(GITHUB_TOKEN) -u $(CIRCLE_PROJECT_USERNAME) -r $(CIRCLE_PROJECT_REPONAME) -c $(CIRCLE_SHA1) -b='$(shell ./tools/release-note.sh)' -delete -draft $(IMAGE_TAG) ./dist/ + ./tools/release ######## # Lint # diff --git a/loki-build-image/Dockerfile b/loki-build-image/Dockerfile index 5873165321741..fd5cf172165c1 100644 --- a/loki-build-image/Dockerfile +++ b/loki-build-image/Dockerfile @@ -18,7 +18,7 @@ FROM golang:1.11.4-stretch RUN apt-get update && \ apt-get install -qy \ musl \ - file unzip jq \ + file unzip jq gettext\ protobuf-compiler libprotobuf-dev \ libsystemd-dev && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/tools/release b/tools/release new file mode 100755 index 0000000000000..180778a53b113 --- /dev/null +++ b/tools/release @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +ghr \ + -t "${GITHUB_TOKEN}" \ + -u "${CIRCLE_PROJECT_USERNAME}" \ + -r "${CIRCLE_PROJECT_REPONAME}" \ + -c "${CIRCLE_SHA1}" \ + -b="$(cat ./tools/release-note.md | envsubst)" \ + -delete -draft \ + "${CIRCLE_TAG}" ./dist/ diff --git a/tools/release-note.md b/tools/release-note.md index fdf1663843d8c..58317f1c0d800 100644 --- a/tools/release-note.md +++ b/tools/release-note.md @@ -1,15 +1,15 @@ -This is release `${TAG}` of Loki. +This is release `${CIRCLE_TAG}` of Loki. ### Notable changes: :warning: **ADD RELEASE NOTES HERE** :warning: ### Installation: -The components of Loki are currently distrubuted in plain binary form and as Docker container images. Choose what fits your use-case best. +The components of Loki are currently distributed in plain binary form and as Docker container images. Choose what fits your use-case best. #### Binary: ```bash # download a binary (adapt app, os and arch as needed) -$ curl -fSL -o "/usr/local/bin/loki.gz" "https://github.com/grafana/loki/releases/download/${TAG}/loki-linux-amd64.gz" +$ curl -fSL -o "/usr/local/bin/loki.gz" "https://github.com/grafana/loki/releases/download/${CIRCLE_TAG}/loki-linux-amd64.gz" $ gunzip "/usr/local/bin/loki.gz" # make sure it is executable @@ -20,6 +20,6 @@ $ chmod a+x "/usr/local/bin/loki" * https://hub.docker.com/r/grafana/loki * https://hub.docker.com/r/grafana/promtail ```bash -$ docker pull "grafana/loki:${TAG}" -$ docker pull "grafana/promtail:${TAG}" +$ docker pull "grafana/loki:${CIRCLE_TAG}" +$ docker pull "grafana/promtail:${CIRCLE_TAG}" ``` diff --git a/tools/release-note.sh b/tools/release-note.sh deleted file mode 100755 index 477216988fda9..0000000000000 --- a/tools/release-note.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -export TAG=$(tools/image-tag) -envsubst < tools/release-note.md From a3a5b1b054cf506764a619fc51f325875d706246 Mon Sep 17 00:00:00 2001 From: Edward Welch Date: Fri, 2 Aug 2019 13:49:17 -0400 Subject: [PATCH 3/3] building binaries should set `BUILD_IN_CONTAINER=false` from CI as this will already be running in the build image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c53d69986ea03..e0882e5ca3ddd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -217,7 +217,7 @@ jobs: - checkout - run: name: github release - command: make publish + command: make BUILD_IN_CONTAINER=false publish deploy: <<: *defaults