Skip to content

Commit

Permalink
add goreleaser to next tsdproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidapaulopt committed Nov 23, 2024
1 parent 5f5b17c commit 9536d2a
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 2 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# .github/workflows/release.yml
name: goreleaser

on:
push:
branches:
- next

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

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

- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- uses: sigstore/[email protected]

- name: dockerhub-login
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: ghcr-login
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release -f .goreleaser-branch.yaml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_PASSWORD: $${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: $${{ secrets.DOCKER_USERNAME }}
1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
Expand Down
226 changes: 226 additions & 0 deletions .goreleaser-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
# SPDX-FileCopyrightText: 2024 Paulo Almeida <[email protected]>
# SPDX-License-Identifier: MIT

version: 2

env:
- GO111MODULE=on
- CGO_ENABLED=0
- GITHUB_ORG=almeidapaulopt
- DOCKER_ORG=almeidapaulopt
- DOCKERFILE=Dockerfile.goreleaser

before:
hooks:
- go mod tidy
- go generate ./...

gomod:
proxy: false

report_sizes: true

builds:
- id: server
main: ./cmd/server/main.go
binary: tsdproxyd
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
- arm
goarm:
- "6"
- "7"
ignore:
- goarch: arm
goos: windows
- goarch: arm64
goos: freebsd
ldflags:
- -s -w -X "github.com/almeidapaulopt/tsdproxy/internal/core.buildString={{ .Tag }} ({{ .ShortCommit }} {{ .Date }}, {{ .Os }}/{{ .Arch }})" -X "github.com/almeidapaulopt/tsdproxy/core.version={{ .Tag }}"

- id: healthcheck
main: ./cmd/healthcheck/main.go
binary: healthcheck
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
- arm
goarm:
- "6"
- "7"
ignore:
- goarch: arm
goos: windows
- goarch: arm64
goos: freebsd

universal_binaries:
- replace: false

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
use: github
filters:
exclude:
- "^test:"
- "^chore"
- "merge conflict"
- Merge pull request
- Merge remote-tracking branch
- Merge branch
- go mod tidy
groups:
- title: Dependency updates
regexp: '^.*?(feat|fix)\(deps\)!?:.+$'
order: 300
- title: "New Features"
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 100
- title: "Security updates"
regexp: '^.*?sec(\([[:word:]]+\))??!?:.+$'
order: 150
- title: "Bug fixes"
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 200
- title: "Documentation updates"
regexp: ^.*?doc(\([[:word:]]+\))??!?:.+$
order: 400
- title: "Build process updates"
regexp: ^.*?build(\([[:word:]]+\))??!?:.+$
order: 400
- title: Other work
order: 9999

archives:
- format: tar.gz
files:
- README.md
- LICENSE
allow_different_binary_count: true

dockers:
- use: buildx
goos: linux
goarch: amd64
dockerfile: "{{ .Env.DOCKERFILE }}"
image_templates:
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-amd64"
- "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-amd64"
build_flag_templates:
- "--pull"
- '--label=io.artifacthub.package.maintainers=[{"name":"Paulo Almeida","email":"[email protected]"}]'
- "--label=io.artifacthub.package.license=MIT"
- "--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.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
- "--label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--platform=linux/amd64"
- use: buildx
goos: linux
goarch: arm64
dockerfile: "{{ .Env.DOCKERFILE }}"
image_templates:
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-arm64v8"
- "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-arm64v8"
build_flag_templates:
- "--pull"
- '--label=io.artifacthub.package.maintainers=[{"name":"Paulo Almeida","email":"[email protected]"}]'
- "--label=io.artifacthub.package.license=MIT"
- "--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.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
- "--label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--platform=linux/arm64/v8"
- use: buildx
goos: linux
goarch: arm
goarm: 6
dockerfile: "{{ .Env.DOCKERFILE }}"
image_templates:
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv6"
- "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv6"
build_flag_templates:
- "--pull"
- '--label=io.artifacthub.package.maintainers=[{"name":"Paulo Almeida","email":"[email protected]"}]'
- "--label=io.artifacthub.package.license=MIT"
- "--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.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
- "--label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--platform=linux/arm/v6"
- use: buildx
goos: linux
goarch: arm
goarm: 7
dockerfile: "{{ .Env.DOCKERFILE }}"
image_templates:
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv7"
- "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv7"
build_flag_templates:
- "--pull"
- '--label=io.artifacthub.package.maintainers=[{"name":"Paulo Almeida","email":"[email protected]"}]'
- "--label=io.artifacthub.package.license=MIT"
- "--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.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
- "--label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--platform=linux/arm/v7"

docker_manifests:
- name_template: "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}"
image_templates:
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-amd64"
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-arm64v8"
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv6"
- "{{ .Env.DOCKER_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv7"
- name_template: ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}
image_templates:
- ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-amd64
- ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-arm64v8
- ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv6
- ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Branch }}-armv7

docker_signs:
- cmd: cosign
artifacts: manifests
output: true
args:
- "sign"
- "${artifact}@${digest}"
- --yes
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ builds:
- goarch: arm64
goos: freebsd
ldflags:
- -s -w -X "github.com/almeidapaulopt/tsdproxy/core.buildString={{ .Tag }} ({{ .ShortCommit }} {{ .Date }}, {{ .Os }}/{{ .Arch }})" -X "github.com/almeidapaulopt/tsdproxy/core.version={{ .Tag }}"
- -s -w -X "github.com/almeidapaulopt/tsdproxy/internal/core.buildString={{ .Tag }} ({{ .ShortCommit }} {{ .Date }}, {{ .Os }}/{{ .Arch }})" -X "github.com/almeidapaulopt/tsdproxy/core.version={{ .Tag }}"

- id: healthcheck
main: ./cmd/healthcheck/main.go
Expand Down

0 comments on commit 9536d2a

Please sign in to comment.