From 9a999e0cdb207de2c9d9d4276860435727818989 Mon Sep 17 00:00:00 2001 From: Chris O'Donnell <1666298+codfish@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:45:11 -0400 Subject: [PATCH] fix: update release workflow to ensure every docker tag is pushed (#208) --- .github/workflows/release.yml | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4aa0eb7..b813c12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,28 +62,31 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: docker login + - name: Docker login run: | echo "$GCR_TOKEN" | docker login ghcr.io -u codfish --password-stdin env: GCR_TOKEN: ${{ secrets.GCR_TOKEN }} + # Step to create a list of tags to push to GCR always including the latest tag and optionally + # the new release tag and major release tag. + - name: Create tags list + id: tags + shell: bash + run: | + TAGS="ghcr.io/codfish/semantic-release-action:latest" + if [ "${{ steps.semantic.outputs.new-release-published }}" == "true" ]; then + TAGS="${TAGS},ghcr.io/codfish/semantic-release-action:v${{ steps.semantic.outputs.release-version }}" + TAGS="${TAGS},ghcr.io/codfish/semantic-release-action:v${{ steps.semantic.outputs.release-major }}" + fi + echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" + + # Push docker images to GCR # Dockerhub is auto synced with the repo, no need to explicitly deploy - - name: build and push latest docker image to GCR + - name: Build and push docker images to GCR uses: docker/build-push-action@v5 with: context: . platforms: linux/arm64,linux/amd64 push: true - tags: ghcr.io/codfish/semantic-release-action:latest - - - name: push docker images for releases to GCR - if: steps.semantic.outputs.new-release-published == 'true' - run: | - docker tag ghcr.io/codfish/semantic-release-action ghcr.io/codfish/semantic-release-action:$VERSION_TAG - docker tag ghcr.io/codfish/semantic-release-action ghcr.io/codfish/semantic-release-action:$MAJOR_TAG - docker push ghcr.io/codfish/semantic-release-action:$VERSION_TAG - docker push ghcr.io/codfish/semantic-release-action:$MAJOR_TAG - env: - VERSION_TAG: v${{ steps.semantic.outputs.release-version }} - MAJOR_TAG: v${{ steps.semantic.outputs.release-major }} + tags: ${{ steps.tags.outputs.tags }}