Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(packaging): Release pipeline #840

Merged
merged 3 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,6 +53,10 @@ workflows:
requires: [ lint, test ]
filters: { <<: *tag-or-master }

- publish/binaries:
requires: [ lint, test ]
filters: { <<: *only-tags }

- deploy:
requires:
- publish/loki
Expand All @@ -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
Expand Down Expand Up @@ -203,6 +211,14 @@ jobs:
name: docker-driver
command: make docker-driver-push

publish/binaries:
<<: *defaults
steps:
- checkout
- run:
name: github release
command: make BUILD_IN_CONTAINER=false publish

deploy:
<<: *defaults
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ cmd/loki-canary/loki-canary
/loki-canary
dlv
rootfs/
dist
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
#############
Expand All @@ -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
Expand Down Expand Up @@ -167,6 +169,20 @@ 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 #
#############
# 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
CGO_ENABLED=0 $(GOX) -osarch="darwin/amd64 windows/amd64 freebsd/amd64" ./cmd/promtail ./cmd/logcli
gzip dist/*
pushd dist && sha256sum * > SHA256SUMS && popd

publish: dist
./tools/release

########
# Lint #
########
Expand All @@ -192,6 +208,7 @@ clean:
rm -rf cmd/loki-canary/loki-canary
rm -rf .cache
rm -rf cmd/docker-driver/rootfs
rm -rf dist/
go clean ./...

#########
Expand Down
6 changes: 4 additions & 2 deletions loki-build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand All @@ -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

Expand Down
9 changes: 9 additions & 0 deletions tools/release
Original file line number Diff line number Diff line change
@@ -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/
25 changes: 25 additions & 0 deletions tools/release-note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
This is release `${CIRCLE_TAG}` of Loki.

### Notable changes:
:warning: **ADD RELEASE NOTES HERE** :warning:

### Installation:
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/${CIRCLE_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:${CIRCLE_TAG}"
$ docker pull "grafana/promtail:${CIRCLE_TAG}"
```