Skip to content

Commit aa92ed3

Browse files
authored
Always use git tag for container image (#2985)
Version strips the "v" prefix, which we want to be in the container image tag.
2 parents 10e4588 + deececd commit aa92ed3

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,15 @@ jobs:
6161
- name: Set snapshot tag
6262
id: vars
6363
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')
64-
run: echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
64+
run: |
65+
echo "tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
66+
echo "git_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
6567
6668
- name: Push snapshot images
6769
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')
6870
run: |
71+
docker tag ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.git_tag }}-amd64 ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.tag }}-amd64
72+
docker tag ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.git_tag }}-arm64 ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.tag }}-arm64
6973
docker push ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.tag }}-amd64
7074
docker push ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.tag }}-arm64
7175
docker manifest create ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.tag }} --amend ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.tag }}-amd64 --amend ghcr.io/parca-dev/parca-agent:${{ steps.vars.outputs.tag }}-arm64

.goreleaser.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ release:
7777
name: parca-agent
7878
prerelease: auto
7979
draft: false
80-
name_template: 'v{{ .Tag }}'
80+
name_template: '{{ .Tag }}'
8181
dockers:
82-
- image_templates: ["ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Version }}-amd64"]
82+
- image_templates: ["ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Tag }}-amd64"]
8383
dockerfile: Dockerfile
8484
use: buildx
8585
build_flag_templates:
@@ -89,10 +89,10 @@ dockers:
8989
- --label=org.opencontainers.image.description={{ .ProjectName }}
9090
- --label=org.opencontainers.image.url=https://parca.dev/
9191
- --label=org.opencontainers.image.source=https://github.com/parca-dev/{{ .ProjectName }}
92-
- --label=org.opencontainers.image.version={{ .Version }}
92+
- --label=org.opencontainers.image.version={{ .Tag }}
9393
- --label=org.opencontainers.image.revision={{ .FullCommit }}
9494
- --label=org.opencontainers.image.licenses=Apache-2.0
95-
- image_templates: ["ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Version }}-arm64"]
95+
- image_templates: ["ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Tag }}-arm64"]
9696
goarch: arm64
9797
dockerfile: Dockerfile
9898
use: buildx
@@ -103,15 +103,15 @@ dockers:
103103
- --label=org.opencontainers.image.description={{ .ProjectName }}
104104
- --label=org.opencontainers.image.url=https://parca.dev/
105105
- --label=org.opencontainers.image.source=https://github.com/parca-dev/{{ .ProjectName }}
106-
- --label=org.opencontainers.image.version={{ .Version }}
106+
- --label=org.opencontainers.image.version={{ .Tag }}
107107
- --label=org.opencontainers.image.revision={{ .FullCommit }}
108108
- --label=org.opencontainers.image.licenses=Apache-2.0
109109
docker_manifests:
110-
- name_template: ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Version }}
110+
- name_template: ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Tag }}
111111
image_templates:
112-
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Version }}-amd64
113-
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Version }}-arm64
112+
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Tag }}-amd64
113+
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Tag }}-arm64
114114
- name_template: ghcr.io/parca-dev/{{ .ProjectName }}:latest
115115
image_templates:
116-
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Version }}-amd64
117-
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Version }}-arm64
116+
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Tag }}-amd64
117+
- ghcr.io/parca-dev/{{ .ProjectName }}:{{ .Tag }}-arm64

0 commit comments

Comments
 (0)