Skip to content

Commit

Permalink
feat: add goreleaser to make releases
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Goldstein <[email protected]>
  • Loading branch information
cardoe committed Apr 24, 2024
1 parent eef613f commit 6acb177
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 23 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,18 @@ jobs:
go mod tidy
git diff --exit-code go.mod
git diff --exit-code go.sum
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- uses: docker/setup-buildx-action@v3
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean --skip=publish --snapshot
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release
on:
push:
tags:
- '*'

permissions:
contents: write
id-token: write
packages: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- uses: docker/setup-buildx-action@v3
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
36 changes: 36 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
project_name: cert-manager-webhook-rackspace

builds:
- main: ./cmd/webhook
binary: cert-manager-webhook-rackspace
env:
- GCO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags:
- -X 'main.Version={{.Version}}'
- -X 'main.Gitsha={{.ShortCommit}}'

dockers:
- image_templates:
- '{{ envOrDefault "REGISTRY" "ghcr.io" }}/{{ envOrDefault "REG_ORG" "rackerlabs" }}/{{ .ProjectName }}:{{ .Version }}'
- '{{ envOrDefault "REGISTRY" "ghcr.io" }}/{{ envOrDefault "REG_ORG" "rackerlabs" }}/{{ .ProjectName }}:latest'
use: buildx
build_flag_templates:
- "--label=org.opencontainers.image.description=Rackspace Cloud DNS support for cert-manager"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"

changelog:
use: github
sort: asc
filters:
exclude:
- '^chore:'
- '^docs:'
- '^test:'
27 changes: 4 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
FROM golang:1.21-alpine3.18 AS build_deps
FROM gcr.io/distroless/static-debian12:nonroot

RUN apk add --no-cache git

WORKDIR /workspace

COPY go.mod .
COPY go.sum .

RUN go mod download

FROM build_deps AS build

COPY . .

RUN CGO_ENABLED=0 go build -o webhook -ldflags '-w -extldflags "-static"' .

FROM alpine:3.18

RUN apk add --no-cache ca-certificates

COPY --from=build /workspace/webhook /usr/local/bin/webhook

ENTRYPOINT ["webhook"]
USER 20000:20000
COPY --chmod=555 cert-manager-webhook-rackspace /usr/local/bin/cert-manager-webhook-rackspace
ENTRYPOINT ["/usr/local/bin/cert-manager-webhook-rackspace"]

0 comments on commit 6acb177

Please sign in to comment.