소스 검색

ci: use git describe for OCI image version label

Nicolas Duchon 3 년 전
부모
커밋
0ff39b804c
1개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. 10 6
      .github/workflows/dockerhub.yml

+ 10 - 6
.github/workflows/dockerhub.yml

@@ -28,6 +28,9 @@ jobs:
         uses: actions/checkout@v2
         with:
           fetch-depth: 0
+      
+      - name: Retrieve version
+        run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
 
       - name: Get Docker tags for Debian based image
         id: docker_meta_debian
@@ -40,6 +43,8 @@ jobs:
             type=semver,pattern={{version}}
             type=semver,pattern={{major}}.{{minor}}
             type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
+          labels: |
+            org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
 
       - name: Set up QEMU
         uses: docker/setup-qemu-action@v1
@@ -53,9 +58,6 @@ jobs:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
-      - name: Retrieve version
-        run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
-
       - name: Build and push the Debian based image
         id: docker_build_debian
         uses: docker/build-push-action@v2
@@ -79,6 +81,9 @@ jobs:
         uses: actions/checkout@v2
         with:
           fetch-depth: 0
+      
+      - name: Retrieve version
+        run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
 
       - name: Get Docker tags for Alpine based image
         id: docker_meta_alpine
@@ -91,6 +96,8 @@ jobs:
             type=semver,suffix=-alpine,pattern={{version}}
             type=semver,suffix=-alpine,pattern={{major}}.{{minor}}
             type=raw,value=alpine,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
+          labels: |
+            org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
           flavor: latest=false
 
       - name: Set up QEMU
@@ -105,9 +112,6 @@ jobs:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
-      - name: Retrieve version
-        run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
-
       - name: Build and push the Alpine based image
         id: docker_build_alpine
         uses: docker/build-push-action@v2