Skip to content

Commit 20a4114

Browse files
committed
configure build with goreleaser
1 parent cfdece8 commit 20a4114

File tree

7 files changed

+149
-192
lines changed

7 files changed

+149
-192
lines changed

.github/workflows/build.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: ^1.17
20+
- name: Build
21+
run: |
22+
go build cmd/brink/main.go
23+
- name: Tests
24+
run: |
25+
go test ./...

.github/workflows/ci.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
ci:
8+
runs-on: ubuntu-latest
9+
env:
10+
DOCKER_CLI_EXPERIMENTAL: "enabled"
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v1
18+
- name: Set up Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: ^1.17
22+
- name: Tests
23+
run: |
24+
go test ./...
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v2
27+
with:
28+
version: latest
29+
args: release --rm-dist --snapshot

.github/workflows/dev-release.yaml

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 25 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,40 @@
1-
name: "Release"
1+
name: release
22

33
on:
4-
release:
5-
types: [ created ]
6-
7-
jobs:
8-
binaries:
9-
name: "Binaries"
10-
runs-on: "ubuntu-latest"
11-
12-
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v2
15-
with:
16-
fetch-depth: 1
17-
18-
- name: Set up Go
19-
uses: actions/setup-go@v2
20-
with:
21-
go-version: ^1.17
22-
23-
- name: Build
24-
run: make dist
25-
26-
- uses: skx/github-action-publish-binaries@master
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
with:
30-
args: "./dist/*"
31-
32-
docker:
33-
name: "Docker"
34-
runs-on: "ubuntu-latest"
4+
push:
5+
tags:
6+
- '*'
357

36-
permissions:
37-
contents: read
38-
packages: write
8+
permissions:
9+
contents: write
10+
packages: write
3911

12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
env:
16+
DOCKER_CLI_EXPERIMENTAL: "enabled"
4017
steps:
41-
- name: Checkout repository
18+
- name: Checkout
4219
uses: actions/checkout@v2
4320
with:
44-
fetch-depth: 1
45-
46-
- name: Get tags
47-
id: get_tag
48-
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
49-
50-
- name: Set Username/Repo and ImagePrefix as ENV vars
51-
run: |
52-
echo "USER_REPO"=$(echo "$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV && \
53-
echo "IMAGE_PREFIX"=$(echo "ghcr.io/$GITHUB_REPOSITORY" | awk '{print tolower($1)}' | sed -e "s/:refs//") >> $GITHUB_ENV
54-
21+
fetch-depth: 0
5522
- name: Set up QEMU
5623
uses: docker/setup-qemu-action@v1
57-
58-
- name: Set up Docker Buildx
59-
uses: docker/setup-buildx-action@v1
60-
61-
- name: Login to Github Container Registry
24+
- name: Docker Login
6225
uses: docker/login-action@v1
6326
with:
6427
registry: ghcr.io
6528
username: ${{ github.repository_owner }}
6629
password: ${{ secrets.GITHUB_TOKEN }}
67-
68-
- name: Build and Push container images
69-
uses: docker/build-push-action@v2
30+
- name: Set up Go
31+
uses: actions/setup-go@v2
7032
with:
71-
context: .
72-
file: ./Dockerfile
73-
platforms: linux/amd64,linux/arm/v7,linux/arm64
74-
build-args: |
75-
VERSION=latest
76-
GIT_COMMIT=${{ github.sha }}
77-
REPO_URL=https://github.com/${{ env.USER_REPO }}
78-
push: true
79-
tags: |
80-
${{ env.IMAGE_PREFIX }}:${{ steps.get_tag.outputs.TAG }}
33+
go-version: ^1.17
34+
- name: Run GoReleaser
35+
uses: goreleaser/goreleaser-action@v2
36+
with:
37+
version: latest
38+
args: release --rm-dist
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
project_name: brink
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- main: ./cmd/brink
9+
env: [ CGO_ENABLED=0 ]
10+
goos:
11+
- linux
12+
- windows
13+
- darwin
14+
goarch:
15+
- amd64
16+
- arm64
17+
ignore:
18+
- goos: windows
19+
goarch: arm64
20+
ldflags:
21+
- -s -w -X github.com/jsiebens/brink/internal/version.Version={{.Version}} -X github.com/jsiebens/brink/internal/version.GitCommit={{.Commit}}
22+
23+
dockers:
24+
- image_templates: [ "ghcr.io/jsiebens/{{ .ProjectName }}:{{ .Version }}-amd64" ]
25+
dockerfile: Dockerfile
26+
use: buildx
27+
build_flag_templates:
28+
- --platform=linux/amd64
29+
- image_templates: [ "ghcr.io/jsiebens/{{ .ProjectName }}:{{ .Version }}-arm64" ]
30+
goarch: arm64
31+
dockerfile: Dockerfile
32+
use: buildx
33+
build_flag_templates:
34+
- --platform=linux/arm64
35+
docker_manifests:
36+
- name_template: ghcr.io/jsiebens/{{ .ProjectName }}:{{ .Version }}
37+
image_templates:
38+
- ghcr.io/jsiebens/{{ .ProjectName }}:{{ .Version }}-amd64
39+
- ghcr.io/jsiebens/{{ .ProjectName }}:{{ .Version }}-arm64
40+
- name_template: ghcr.io/jsiebens/{{ .ProjectName }}:latest
41+
image_templates:
42+
- ghcr.io/jsiebens/{{ .ProjectName }}:{{ .Version }}-amd64
43+
- ghcr.io/jsiebens/{{ .ProjectName }}:{{ .Version }}-arm64
44+
45+
archives:
46+
- format_overrides:
47+
- goos: windows
48+
format: zip
49+
50+
changelog:
51+
sort: asc
52+
filters:
53+
exclude:
54+
- '^test:'
55+
- '^chore'
56+
- Merge pull request
57+
- Merge remote-tracking branch
58+
- Merge branch
59+
- go mod tidy
60+
groups:
61+
- title: 'New Features'
62+
regexp: "^.*feat[(\\w)]*:+.*$"
63+
order: 0
64+
- title: 'Bug fixes'
65+
regexp: "^.*fix[(\\w)]*:+.*$"
66+
order: 10
67+
- title: Other work
68+
order: 999

Dockerfile

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
1-
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17.2-alpine3.14 as build
2-
3-
ARG TARGETPLATFORM
4-
ARG BUILDPLATFORM
5-
ARG TARGETOS
6-
ARG TARGETARCH
7-
8-
ENV CGO_ENABLED=0
9-
10-
WORKDIR /src
11-
COPY . .
12-
13-
RUN apk add git
14-
RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | sed 's/tags\///') \
15-
&& GIT_COMMIT=$(git rev-list -1 HEAD) \
16-
&& GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=${CGO_ENABLED} go build \
17-
--ldflags "-s -w \
18-
-X github.com/jsiebens/brink/internal/version.GitCommit=${GIT_COMMIT}\
19-
-X github.com/jsiebens/brink/internal/version.Version=${VERSION}" \
20-
-a -installsuffix cgo -o brink cmd/brink/main.go
21-
22-
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.14.2 as ship
1+
FROM alpine:3.14.2
232

243
RUN apk --no-cache add ca-certificates
254
RUN addgroup -S brink && adduser -S -g brink brink
265

27-
COPY --from=build /src/brink /usr/local/bin
6+
COPY brink /usr/local/bin/brink
287

298
USER brink
309
ENTRYPOINT ["brink"]

Makefile

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)