From 26813612e3f8811c8de38583035f6a36ec4c6567 Mon Sep 17 00:00:00 2001 From: Lawrence Jones Date: Thu, 9 May 2019 11:29:09 +0100 Subject: [PATCH] Use goreleaser to publish GC releases While we work on stolon, it will be important for us to use pre-release candidates of our own changes. This commit adds goreleaser to automatically create these on our own forks build. --- .dockerignore | 1 + .gitignore | 2 ++ Dockerfile | 33 +++++++++++++++++++++++++++++++++ VERSION | 1 + circle.yml | 33 +++++++++++++++++++++++++++++++++ goreleaser.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+) create mode 120000 .dockerignore create mode 100644 Dockerfile create mode 100644 VERSION create mode 100644 circle.yml create mode 100644 goreleaser.yml diff --git a/.dockerignore b/.dockerignore new file mode 120000 index 000000000..3e4e48b0b --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.gitignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index e543dc6a7..9d87fcfd8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ bin/ /release/ .idea + +dist/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d778eea28 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +################################################################################ +# build +################################################################################ + +FROM golang:1.12 AS build +COPY . /go/src/github.com/sorintlab/stolon +WORKDIR /go/src/github.com/sorintlab/stolon + +# If we're running goreleaser, then our binaries will already be copied into our +# work directory. Otherwise we should build them. +RUN set -x \ + && \ + if [ ! -f stolonctl ]; then \ + ./build; \ + mv -v bin/* ./; \ + fi + +################################################################################ +# release +################################################################################ + +FROM ubuntu:18.04 AS release +RUN set -x \ + && apt-get update -y \ + && apt-get install -y curl gpg \ + && sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main\ndeb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg 11" > /etc/apt/sources.list.d/pgdg.list' \ + && curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ + && apt-get update -y \ + && apt-get install -y software-properties-common pgbouncer postgresql-client \ + && mkdir -pv /var/run/postgresql /var/log/postgresql + +COPY --from=build /go/src/github.com/sorintlab/stolon/stolon* /usr/local/bin/ +USER postgres diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..3ceaf8093 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.13.0-gc-rc1 diff --git a/circle.yml b/circle.yml new file mode 100644 index 000000000..b6667109c --- /dev/null +++ b/circle.yml @@ -0,0 +1,33 @@ +--- +version: 2 + +jobs: + release: + working_directory: /go/src/github.com/sorintlab/stolon + docker: + - image: golang:1.12 + steps: + - checkout + - run: + name: Release + command: | + CURRENT_VERSION="v$(cat VERSION)" + + if [[ $(git tag -l "${CURRENT_VERSION}") == "${CURRENT_VERSION}" ]]; then + echo "Version ${CURRENT_VERSION} is already released" + exit 0 + fi + + curl -L -o /tmp/goreleaser_Linux_x86_64.tar.gz https://github.com/goreleaser/goreleaser/releases/download/v0.106.0/goreleaser_Linux_x86_64.tar.gz + tar zxf /tmp/goreleaser_Linux_x86_64.tar.gz -C /tmp + + git tag "${CURRENT_VERSION}" + git push --tags + + /tmp/goreleaser --rm-dist + +workflows: + version: 2 + build-integration: + jobs: + - release diff --git a/goreleaser.yml b/goreleaser.yml new file mode 100644 index 000000000..fba17497e --- /dev/null +++ b/goreleaser.yml @@ -0,0 +1,44 @@ +# View goreleaser docs for configuration settings +# https://goreleaser.com + +--- +project_name: stolon + +release: + github: + owner: gocardless + name: stolon + +builds: + - binary: stolonctl + main: cmd/stolonctl/main.go + goos: &goos + - linux + goarch: &goarch + - amd64 + ldflags: &ldflags > + -X cmd.Version={{.Version}} + -X cmd.Commit={{.Commit}} + -X cmd.Date={{.Date}} + -a + -installsuffix cgo + env: &env + - CGO_ENABLED=0 + - binary: stolon-keeper + main: cmd/keeper/main.go + goos: *goos + goarch: *goarch + ldflags: *ldflags + env: *env + - binary: stolon-proxy + main: cmd/proxy/main.go + goos: *goos + goarch: *goarch + ldflags: *ldflags + env: *env + - binary: stolon-sentinel + main: cmd/sentinel/main.go + goos: *goos + goarch: *goarch + ldflags: *ldflags + env: *env