diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 24c5028..fcdd0b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -137,6 +137,9 @@ jobs: name: Create GitHub Release needs: build runs-on: ubuntu-latest + outputs: + should_release: ${{ steps.meta.outputs.should_release }} + tag_name: ${{ steps.meta.outputs.tag_name }} permissions: contents: write steps: @@ -267,3 +270,54 @@ jobs: run: | echo "No new semantic release created." echo "Add a commit starting with break, feat, or fix after the latest tag." + + docker: + name: Publish Docker image + needs: release + if: needs.release.outputs.should_release == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check out code + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Prepare image name + id: image + env: + REPOSITORY: ${{ github.repository }} + run: | + echo "name=ghcr.io/$(echo "$REPOSITORY" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.name }} + tags: | + type=raw,value=latest + type=raw,value=${{ needs.release.outputs.tag_name }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}