Skip to content

Commit 317f9f0

Browse files
authored
Merge pull request #241 from smlx/dockers-v2
feat: switch to experimental goreleaser dockers_v2
2 parents 2b51ba7 + 8385ff7 commit 317f9f0

2 files changed

Lines changed: 25 additions & 76 deletions

File tree

.github/workflows/release.yaml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ jobs:
3838
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
3939
with:
4040
go-version: stable
41+
- uses: docker/setup-buildx-action@v3
4142
- name: Login to GHCR
4243
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
4344
with:
4445
registry: ghcr.io
4546
username: ${{ github.repository_owner }}
4647
password: ${{ secrets.GITHUB_TOKEN }}
47-
- name: Export SBOM in SPDX JSON format
48+
- name: Export SBOM for binary in SPDX JSON format
4849
# https://docs.github.com/en/rest/dependency-graph/sboms?apiVersion=2022-11-28
4950
run: |
5051
gh api \
@@ -60,33 +61,12 @@ jobs:
6061
args: release --clean
6162
env:
6263
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
# attest artefacts
64+
# attest artifacts
6465
- uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
6566
with:
66-
subject-path: |
67-
dist/*.tar.gz
68-
sbom.spdx.json
69-
# parse artifacts to the format required for image attestation
70-
- run: |
71-
echo "digest=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("go-cli-github:v"))|.extra.Digest')" >> "$GITHUB_OUTPUT"
72-
echo "name=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("go-cli-github:v"))|.name|split(":")[0]')" >> "$GITHUB_OUTPUT"
73-
id: image_metadata_go_cli_github
74-
env:
75-
ARTIFACTS: ${{steps.goreleaser.outputs.artifacts}}
76-
- run: |
77-
echo "digest=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("another-binary:v"))|.extra.Digest')" >> "$GITHUB_OUTPUT"
78-
echo "name=$(echo "$ARTIFACTS" | jq -r '.[]|select(.type=="Docker Manifest")|select(.name|test("another-binary:v"))|.name|split(":")[0]')" >> "$GITHUB_OUTPUT"
79-
id: image_metadata_another_binary
80-
env:
81-
ARTIFACTS: ${{steps.goreleaser.outputs.artifacts}}
67+
subject-checksums: ./dist/checksums.txt
8268
# attest images
8369
- uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
8470
with:
85-
subject-digest: ${{steps.image_metadata_go_cli_github.outputs.digest}}
86-
subject-name: ${{steps.image_metadata_go_cli_github.outputs.name}}
87-
push-to-registry: true
88-
- uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
89-
with:
90-
subject-digest: ${{steps.image_metadata_another_binary.outputs.digest}}
91-
subject-name: ${{steps.image_metadata_another_binary.outputs.name}}
71+
subject-checksums: ./dist/digests.txt
9272
push-to-registry: true

.goreleaser.yaml

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -27,61 +27,30 @@ builds:
2727
changelog:
2828
use: github-native
2929

30-
dockers:
31-
- ids:
30+
dockers_v2:
31+
- id: go-cli-github
32+
ids:
3233
- go-cli-github
33-
image_templates:
34-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:v{{ .Version }}-amd64"
35-
use: buildx
36-
build_flag_templates:
37-
- "--build-arg=BINARY=go-cli-github"
38-
- "--platform=linux/amd64"
39-
- ids:
40-
- go-cli-github
41-
image_templates:
42-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:v{{ .Version }}-arm64v8"
43-
use: buildx
44-
goarch: arm64
45-
build_flag_templates:
46-
- "--build-arg=BINARY=go-cli-github"
47-
- "--platform=linux/arm64/v8"
48-
- ids:
49-
- another-binary
50-
image_templates:
51-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:v{{ .Version }}-amd64"
52-
use: buildx
53-
build_flag_templates:
54-
- "--build-arg=BINARY=another-binary"
55-
- "--platform=linux/amd64"
56-
- ids:
34+
images:
35+
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github"
36+
tags:
37+
- "v{{ .Version }}"
38+
build_args:
39+
BINARY: go-cli-github
40+
- id: another-binary
41+
ids:
5742
- another-binary
58-
image_templates:
59-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:v{{ .Version }}-arm64v8"
60-
use: buildx
61-
goarch: arm64
62-
build_flag_templates:
63-
- "--build-arg=BINARY=another-binary"
64-
- "--platform=linux/arm64/v8"
65-
66-
docker_manifests:
67-
- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:v{{ .Version }}"
68-
image_templates:
69-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:v{{ .Version }}-amd64"
70-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:v{{ .Version }}-arm64v8"
71-
- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:latest"
72-
image_templates:
73-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:v{{ .Version }}-amd64"
74-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/go-cli-github:v{{ .Version }}-arm64v8"
75-
- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:v{{ .Version }}"
76-
image_templates:
77-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:v{{ .Version }}-amd64"
78-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:v{{ .Version }}-arm64v8"
79-
- name_template: "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:latest"
80-
image_templates:
81-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:v{{ .Version }}-amd64"
82-
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary:v{{ .Version }}-arm64v8"
43+
images:
44+
- "ghcr.io/{{ .Env.GITHUB_REPOSITORY }}/another-binary"
45+
tags:
46+
- "v{{ .Version }}"
47+
build_args:
48+
BINARY: another-binary
8349

8450
release:
8551
extra_files:
8652
- glob: ./sbom.spdx.json
8753
name_template: "{{ .ProjectName }}.v{{ .Version }}.sbom.spdx.json"
54+
55+
checksum:
56+
name_template: checksums.txt

0 commit comments

Comments
 (0)