Skip to content

Commit

Permalink
Add Goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
evenh committed Jul 31, 2024
1 parent 6b44183 commit cffd214
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 7 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: goreleaser

on:
push:
tags:
- '*'

permissions:
contents: write
packages: write
id-token: write # needed for signing the images with GitHub OIDC Token
actions: read

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

- run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

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

- name: Install Cosign
uses: sigstore/[email protected]

- name: Install Syft for SBOM Generation
shell: bash
run: curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78 changes: 74 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ builds:
ignore:
- goos: darwin
goarch: i386
tags:
- osusergo
- netgo

archives:
- format: tar.gz
files:
- readme.md
- server.md
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
Expand All @@ -38,9 +44,73 @@ archives:
- goos: windows
format: zip

dockers:
- image_templates:
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-linux-amd64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
goos: linux
goarch: amd64
- image_templates:
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-linux-arm64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
goos: linux
goarch: arm64
- image_templates:
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-darwin-arm64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=darwin/arm64"
goos: darwin
goarch: arm64
- image_templates:
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-darwin-amd64"
use: buildx
build_flag_templates:
- "--pull"
- "--platform=darwin/amd64"
goos: darwin
goarch: amd64

docker_manifests:
- name_template: "ghcr.io/kartverket/skipctl:{{ .Tag }}"
image_templates:
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-linux-arm64"
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-linux-amd64"
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-darwin-arm64"
- "ghcr.io/kartverket/skipctl:{{ .Tag }}-darwin-amd64"

docker_signs:
- artifacts: all
cmd: cosign
args:
- "sign"
- "--oidc-issuer=https://token.actions.githubusercontent.com"
- "${artifact}"
- "--yes"

signs:
- artifacts: all
cmd: cosign
signature: "${artifact}.sig"
args:
- "sign-blob"
- "--oidc-issuer=https://token.actions.githubusercontent.com"
- "--output-signature=${signature}"
- "${artifact}"
- "--yes"

sboms:
- artifacts: archive

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ debug:

.PHONY: build
build: lint test proto-lint generate
go build -trimpath -ldflags="-s -w -X 'main.GitCommitHash=$(version)'"
go build -tags osusergo,netgo -trimpath -ldflags="-s -w -X 'main.GitCommitHash=$(version)'"

.PHONY: build-nolint
build-nolint: test proto-lint generate
go build -trimpath -ldflags="-s -w -X 'main.GitCommitHash=$(version)'"

go build -tags osusergo,netgo -trimpath -ldflags="-s -w -X 'main.GitCommitHash=$(version)'"

0 comments on commit cffd214

Please sign in to comment.