From 73ab21cfbfae907b66f22e819f3898be4ef49b7a Mon Sep 17 00:00:00 2001 From: Pablo Chacin Date: Tue, 19 Nov 2024 21:30:34 +0100 Subject: [PATCH 1/2] fix publish images Signed-off-by: Pablo Chacin --- .github/workflows/release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e50f48a..6379dde 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,6 +47,11 @@ jobs: run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin + - name: Log into Docker Hub + if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} + run: | + echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin + - name: Publish master image to ghcr.io if: ${{ github.ref == 'refs/heads/master' }} run: | @@ -72,11 +77,6 @@ jobs: -t "ghcr.io/${IMAGE_REPOSITORY}:latest" . fi - - name: Log into Docker Hub - if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }} - run: | - echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin - - name: Publish master image to Docker Hub if: ${{ github.ref == 'refs/heads/master' }} run: | From f06c69dc51972c89b986408495255e404efb90e3 Mon Sep 17 00:00:00 2001 From: Pablo Chacin Date: Tue, 19 Nov 2024 21:37:09 +0100 Subject: [PATCH 2/2] simplify image publishing Signed-off-by: Pablo Chacin --- .github/workflows/release.yml | 40 ++++++++--------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6379dde..410d120 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,52 +52,30 @@ jobs: run: | echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin - - name: Publish master image to ghcr.io + - name: Publish master image if: ${{ github.ref == 'refs/heads/master' }} run: | - echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:master" + echo "Publish as master" docker buildx build --push \ --platform linux/amd64,linux/arm64 \ -t ${IMAGE_REPOSITORY}:master \ -t "ghcr.io/${IMAGE_REPOSITORY}:master" . - - name: Publish tagged version image to ghcr.io + - name: Publish tagged version if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | VERSION="${VERSION#v}" - echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" - docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" - docker push "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" - # We also want to tag the latest stable version as latest - if [[ ! "$VERSION" =~ (RC|rc) ]]; then - echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:latest" - docker buildx build --push \ - --platform linux/amd64,linux/arm64 \ - -t ${IMAGE_REPOSITORY}:latest \ - -t "ghcr.io/${IMAGE_REPOSITORY}:latest" . - fi - - - name: Publish master image to Docker Hub - if: ${{ github.ref == 'refs/heads/master' }} - run: | - echo "Publish as ${IMAGE_REPOSITORY}:master" + echo "Publish as ${VERSION}" docker buildx build --push \ - --platform linux/amd64,linux/arm64 \ - -t ${IMAGE_REPOSITORY}:master \ - -t "ghcr.io/${IMAGE_REPOSITORY}:master" . - - - name: Publish tagged version image to Docker Hub - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: | - VERSION="${VERSION#v}" - echo "Publish as ${IMAGE_REPOSITORY}:${VERSION}" - docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:${VERSION}" - docker push "${IMAGE_REPOSITORY}:${VERSION}" + --platform linux/amd64,linux/arm64 \ + -t ${IMAGE_REPOSITORY}:${VERSION} \ + -t "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" . # We also want to tag the latest stable version as latest if [[ ! "$VERSION" =~ (RC|rc) ]]; then - echo "Publish as ${IMAGE_REPOSITORY}:latest" + echo "Publish as latest" docker buildx build --push \ --platform linux/amd64,linux/arm64 \ -t ${IMAGE_REPOSITORY}:latest \ -t "ghcr.io/${IMAGE_REPOSITORY}:latest" . fi +