Skip to content

Commit cf48957

Browse files
committed
ci: use git describe for OCI image version label
1 parent 8b3f38a commit cf48957

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.github/workflows/dockerhub.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
uses: actions/checkout@v2
3030
with:
3131
fetch-depth: 0
32+
33+
- name: Retrieve version
34+
run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
3235

3336
- name: Get Docker tags for Alpine based image
3437
if: ${{ matrix.base == 'alpine' }}
@@ -42,6 +45,8 @@ jobs:
4245
type=semver,pattern={{version}}
4346
type=semver,pattern={{major}}.{{minor}}
4447
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
48+
labels: |
49+
org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
4550
4651
- name: Get Docker tags for Debian based image
4752
if: ${{ matrix.base == 'debian' }}
@@ -55,11 +60,10 @@ jobs:
5560
type=semver,suffix=-debian,pattern={{version}}
5661
type=semver,suffix=-debian,pattern={{major}}.{{minor}}
5762
type=raw,value=debian,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
63+
labels: |
64+
org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
5865
flavor: latest=false
5966

60-
- name: Retrieve version
61-
run: echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV
62-
6367
- name: Set up QEMU
6468
uses: docker/setup-qemu-action@v1
6569

@@ -77,7 +81,7 @@ jobs:
7781
id: docker_build_alpine
7882
uses: docker/build-push-action@v2
7983
with:
80-
build-args: VERSION=${{ env.VERSION }}
84+
build-args: VERSION=${{ env.GIT_DESCRIBE }}
8185
platforms: linux/amd64,linux/arm64,linux/arm/v7
8286
push: true
8387
tags: ${{ steps.docker_meta_alpine.outputs.tags }}
@@ -88,7 +92,7 @@ jobs:
8892
id: docker_build_debian
8993
uses: docker/build-push-action@v2
9094
with:
91-
build-args: VERSION=${{ env.VERSION }}
95+
build-args: VERSION=${{ env.GIT_DESCRIBE }}
9296
file: Dockerfile.debian
9397
platforms: linux/amd64,linux/arm64,linux/arm/v7
9498
push: true

0 commit comments

Comments
 (0)