diff --git a/.github/workflows/release-docker-images.yaml b/.github/workflows/release-docker-images.yaml index ea176f4..76da936 100644 --- a/.github/workflows/release-docker-images.yaml +++ b/.github/workflows/release-docker-images.yaml @@ -19,13 +19,32 @@ jobs: build: runs-on: ubuntu-latest steps: + - id: read_tag + name: Read release tag name (mostly vx.x.x) + run: | + if [ "${{ github.event_name }}" = "release" ]; then + export TAG="${{ github.ref_name }}" + elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + export TAG="${{ inputs.release }}" + fi + + echo "release_tag=${TAG}" >> "$GITHUB_OUTPUT" + - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ steps.read_tag.outputs.release_tag }} + + - name: Read Go version from go.mod + id: read_go_version + run: | + go_version_raw=$(grep "^go " go.mod | awk '{print $2}') + echo "go_version=${go_version_raw}" >> "$GITHUB_OUTPUT" - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21 + go-version: '${{ steps.read_go_version.outputs.go_version }}' - name: Set up QEMU id: qemu @@ -45,13 +64,17 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + - id: build + name: Build and push Docker images + env: + RELEASE_TAG: ${{ steps.read_tag.outputs.release_tag }} run: | - if [ "${{ github.event_name }}" = "release" ]; then - export TAG="${{ github.ref_name }}" - elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - export TAG="${{ inputs.release }}" + export IMG="ghcr.io/$GITHUB_REPOSITORY:$RELEASE_TAG" + + if grep -q '^docker-buildx:' Makefile; then + make docker-buildx + else + make docker-build + make docker-push fi - - export IMG="ghcr.io/$GITHUB_REPOSITORY:$TAG" - make docker-buildx +