Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Added goreleaser #19

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SPDX-FileCopyrightText: 2024 Risk.Ident GmbH <contact@riskident.com>
#
# SPDX-License-Identifier: CC0-1.0

name: goreleaser

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run GoReleaser and publish
uses: goreleaser/goreleaser-action@v5
if: "startsWith(github.ref, 'refs/tags/')"
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser, but skip publish
uses: goreleaser/goreleaser-action@v5
if: "!startsWith(github.ref, 'refs/tags/')"
with:
version: latest
args: release --clean --skip=publish --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

75 changes: 75 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: 2024 Risk.Ident GmbH <contact@riskident.com>
#
# SPDX-License-Identifier: CC0-1.0

before:
hooks:
- go mod tidy

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64

dockers:
- image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:v{{ .Version }}-amd64"
dockerfile: goreleaser.Dockerfile
use: buildx
goarch: amd64
goos: linux
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}

- image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:v{{ .Version }}-arm64v8"
dockerfile: goreleaser.Dockerfile
use: buildx
goarch: arm64
goos: linux
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}

docker_manifests:
- name_template: "ghcr.io/riskident/{{ .ProjectName }}:v{{ .Version }}"
image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:v{{ .Version }}-amd64"
- "ghcr.io/riskident/{{ .ProjectName }}:v{{ .Version }}-arm64v8"
- name_template: "ghcr.io/riskident/{{ .ProjectName }}:latest"
image_templates:
- "ghcr.io/riskident/{{ .ProjectName }}:v{{ .Version }}-amd64"
- "ghcr.io/riskident/{{ .ProjectName }}:v{{ .Version }}-arm64v8"

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ COPY go.mod go.sum .
RUN go mod download

COPY *.go .
ENV CGO_ENABLED=0
RUN go install
RUN CGO_ENABLED=0 go install

# NOTE: When updating here, remember to also update in ./goreleaser.Dockerfile
FROM scratch
COPY --from=build /go/bin/ri-forward-webhook /usr/bin/
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ go run .
podman build . -t ghcr.io/riskident/ri-forward-webhook
```

## Releasing

1. Create a new release on GitHub, with "v" prefix on version: <https://github.com/RiskIdent/ri-forward-webhook/releases/new>

2. Write a small changelog, like so:

```markdown
## Changes (since v0.3.0)

- Added some feature. (#123)
```

3. Our GitHub Action with goreleaser will build and add artifacts to release

## License

This repository complies with the [REUSE recommendations](https://reuse.software/).
Expand Down
17 changes: 17 additions & 0 deletions goreleaser.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 Risk.Ident GmbH <contact@riskident.com>
#
# SPDX-License-Identifier: CC0-1.0

FROM docker.io/library/alpine AS certs
RUN apk add --no-cache ca-certificates

# NOTE: When updating here, remember to also update in ./Dockerfile
FROM scratch
COPY ri-forward-webhook /usr/local/bin/
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
ENTRYPOINT ["ri-forward-webhook"]
USER 10000
LABEL \
org.opencontainers.image.source=https://github.com/RiskIdent/ri-forward-webhook \
org.opencontainers.image.description="Forwards and validates webhooks" \
org.opencontainers.image.licenses=GPL-3.0-or-later