panlabel 0.6.0

The universal annotation converter
Documentation
name: Docker

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+*'
  workflow_dispatch:
    inputs:
      tag:
        description: 'Image tag (e.g. "0.3.0" or "test")'
        required: true
        default: 'dev'

permissions:
  contents: read

env:
  IMAGE_NAME: strickvl/panlabel

jobs:
  docker:
    name: Build & push Docker image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # QEMU lets buildx cross-compile for arm64 on an amd64 runner
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Log in to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      # Compute image tags from the git ref:
      #   v0.3.0  →  0.3.0, 0.3, latest
      #   v0.4.0-rc.1  →  0.4.0-rc.1  (no "latest")
      - name: Extract metadata (tags, labels)
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.IMAGE_NAME }}
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}

      # Extract bare version for the OCI label build arg
      - name: Extract version
        id: version
        run: |
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            echo "version=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
          else
            # Strip leading 'v' from tag
            echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
          fi

      - name: Build and push
        uses: docker/build-push-action@v6
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          build-args: |
            VERSION=${{ steps.version.outputs.version }}
          cache-from: type=gha
          cache-to: type=gha,mode=max