Skip to content

Commit

Permalink
chore: add goreleaser (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
StewartJingga authored Jan 3, 2022
1 parent a0c1a23 commit 70ff3f7
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
file: "./Dockerfile.dev"
tags: |
odpf/columbus:dev
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: release

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.16'
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.6.1
with:
distribution: goreleaser
version: latest
args: --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }}
79 changes: 79 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
project_name: columbus

release:
prerelease: auto
draft: true

before:
hooks:
- go mod tidy
- make clean

builds:
- main: ./main.go
binary: columbus
flags: [-a]
ldflags:
- -X github.com/odpf/columbus/cmd.Version={{.Tag}}
- -X github.com/odpf/columbus/cmd.BuildCommit={{.FullCommit}}
- -X github.com/odpf/columbus/cmd.BuildDate={{.Date}}
goos: [linux, darwin, windows]
goarch: [amd64, 386, arm, arm64] # skip goarch 386 and arm due to conflicts with "github.com/blastrain/vitess-sqlparser" library
env:
- CGO_ENABLED=0

archives:
- replacements:
darwin: macos
linux: linux
windows: windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^build:'

dockers:
-
goos: linux
goarch: amd64
ids:
- linux
dockerfile: Dockerfile
image_templates:
- 'docker.io/odpf/{{.ProjectName}}:latest'
- 'docker.io/odpf/{{.ProjectName}}:{{ .Version }}'
- 'docker.io/odpf/{{.ProjectName}}:{{ .Version }}-amd64'

brews:
- name: columbus
homepage: "https://github.com/odpf/columbus"
description: "Metadata Discovery and Lineage Service"
tap:
owner: odpf
name: homebrew-taps
license: "Apache 2.0"
folder: Formula

dependencies:
- name: git
install: |-
bin.install "columbus"
commit_author:
name: Ravi Suhag
email: suhag.ravi@gmail.com

18 changes: 5 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
FROM golang:1.16-stretch as base
WORKDIR /build/
COPY . .
RUN ["make"]

FROM alpine:latest
WORKDIR /opt/columbus
COPY --from=base /build/columbus /opt/columbus/bin/columbus
RUN ["apk", "update"]
EXPOSE 8080

# glibc compatibility library, since go binaries
# don't work well with musl libc that alpine uses
RUN ["apk", "add", "libc6-compat"]
ENTRYPOINT ["/opt/columbus/bin/columbus"]
COPY columbus /usr/bin/columbus
RUN apk update
RUN apk add ca-certificates

CMD ["columbus"]
15 changes: 15 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.16-stretch as base
WORKDIR /build/
COPY . .
RUN ["make"]

FROM alpine:latest
WORKDIR /opt/columbus
COPY --from=base /build/columbus /opt/columbus/bin/columbus
RUN ["apk", "update"]
EXPOSE 8080

# glibc compatibility library, since go binaries
# don't work well with musl libc that alpine uses
RUN ["apk", "add", "libc6-compat"]
ENTRYPOINT ["/opt/columbus/bin/columbus"]

0 comments on commit 70ff3f7

Please sign in to comment.