Skip to content

Commit

Permalink
ci: added goreleaser config and CI action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hetjagani committed Jul 31, 2021
1 parent 1d1975e commit 2dcd1b0
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 22 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release CI
on:
push:
tags:
- '*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Go
uses: actions/setup-go@v2
id: setup_go
with:
go-version: '1.16.2'
- name: Cache go-modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Login Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u deshetti --password-stdin
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
project_name: kavach

builds:
- id: kavach-server
dir: server
binary: kavach-server
env:
- CGO_ENABLED=0
- GO386=softfloat
goos:
- linux
- darwin
- windows

archives:
- id: kavach-server
builds:
- kavach-server
name_template: "kavach-server_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

dockers:
- dockerfile: server/Dockerfile.prod
image_templates:
- "factly/kavach-server:{{ .Tag }}"
use: docker
build_flag_templates:
- "--platform=linux/amd64"

docker_manifests:
-
image_templates:
- "factly/kavach-server:{{ .Version }}"

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
25 changes: 3 additions & 22 deletions server/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
FROM golang:1.13-alpine AS build_base

RUN apk add --no-cache git

# Set the Current Working Directory inside the container
WORKDIR /tmp/kavach-server

# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

# Unit tests
# RUN CGO_ENABLED=0 go test -v

# Build the Go app
RUN go build -o ./out/kavach-server .

# Start fresh from a smaller image
FROM alpine:3.9
RUN apk add ca-certificates

COPY --from=build_base /tmp/kavach-server/out/kavach-server /app/kavach-server
RUN apk add gcc musl-dev
WORKDIR /app
COPY kavach-server .

# Run the binary program produced by `go install`
ENTRYPOINT ["/app/kavach-server"]
Expand Down

0 comments on commit 2dcd1b0

Please sign in to comment.