Skip to content

Commit 7753bba

Browse files
author
chavacava
committed
chore: add release machinery
1 parent bad3961 commit 7753bba

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

.github/workflows/release.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
-
18+
name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: stable
22+
-
23+
name: Run GoReleaser
24+
uses: goreleaser/goreleaser-action@v6
25+
with:
26+
version: latest
27+
args: release --clean
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
buildx:
32+
runs-on: ubuntu-latest
33+
34+
env:
35+
PLATFORMS: linux/amd64,linux/arm64
36+
IMAGE_NAME: ${{ github.repository }}
37+
REGISTRY: ghcr.io
38+
39+
permissions:
40+
contents: read
41+
packages: write
42+
attestations: write
43+
id-token: write
44+
45+
steps:
46+
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Docker meta
51+
id: meta
52+
uses: docker/metadata-action@v5
53+
with:
54+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
55+
tags: |
56+
type=semver,pattern={{version}}
57+
type=semver,prefix=v,pattern={{version}}
58+
type=semver,prefix=v,pattern={{major}}.{{minor}}
59+
type=semver,prefix=v,pattern={{major}}
60+
type=sha
61+
62+
- name: Set up QEMU
63+
uses: docker/setup-qemu-action@v3
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Login to GitHub Container Registry
69+
uses: docker/login-action@v3
70+
with:
71+
registry: ghcr.io
72+
username: ${{ github.actor }}
73+
password: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Build and push
76+
id: push
77+
uses: docker/build-push-action@v6
78+
with:
79+
platforms: ${{ env.PLATFORMS }}
80+
tags: ${{ steps.meta.outputs.tags }}
81+
labels: ${{ steps.meta.outputs.labels }}
82+
build-args: |
83+
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
84+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
85+
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
86+
BUILDER=buildx
87+
push: true
88+
89+
- name: Generate artifact attestation
90+
uses: actions/attest-build-provenance@v1
91+
with:
92+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
93+
subject-digest: ${{ steps.push.outputs.digest }}
94+
push-to-registry: true

.goreleaser

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is an example goreleaser.yaml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
---
4+
version: 2
5+
archives:
6+
- id: dbc4go
7+
name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
8+
before:
9+
hooks:
10+
- "go mod download"
11+
builds:
12+
-
13+
env:
14+
- CGO_ENABLED=0
15+
- BUILDER=GoReleaser
16+
goos:
17+
- linux
18+
- darwin
19+
- windows
20+
21+
changelog:
22+
filters:
23+
include:
24+
- "^feature:"
25+
- "^fix:"
26+
sort: asc
27+
checksum:
28+
name_template: checksums.txt
29+
snapshot:
30+
version_template: "{{ .Tag }}-next"
31+
project_name: dbc4go

0 commit comments

Comments
 (0)