Skip to content

Commit

Permalink
Set up GoReleaser
Browse files Browse the repository at this point in the history
https://goreleaser.com

 - Removed the build step from the other go workflow as it is not needed
   now.
 - Changed the Dockerfile to just copy a binary into a scratch container
  • Loading branch information
David Tuite authored and dtuite committed Apr 10, 2020
1 parent 51a398f commit 965b42f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 37 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,6 @@ jobs:
- name: Lint the project
uses: actions-contrib/golangci-lint@v1

build:
name: Build
runs-on: ubuntu-18.04
steps:

- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v .

test:
name: Test
runs-on: ubuntu-18.04
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: goreleaser

on:
push:
branches: [ master ]
tags:
- '*'


jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2

-
name: Unshallow
run: git fetch --prune --unshallow

-
name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.14.x

-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
key: ${{ secrets.YOUR_PRIVATE_KEY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod download
builds:
- env:
- CGO_ENABLED=0
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
dockers:
-
image_templates:
- "us.gcr.io/larder-prod/kubewise:{{ .Tag }}"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
15 changes: 3 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
FROM golang:alpine AS build-env
WORKDIR /app
ADD . /app
RUN cd /app && env go build -o kubewise
FROM alpine
RUN apk update && \
apk add ca-certificates && \
update-ca-certificates && \
rm -rf /var/cache/apk/*
WORKDIR /app
COPY --from=build-env /app/kubewise /app
ENTRYPOINT ./kubewise
FROM scratch
COPY kubewise /
ENTRYPOINT ["/kubewise"]

0 comments on commit 965b42f

Please sign in to comment.