name: Release Jobs

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build-xsdev-image:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - uses: actions/checkout@v4

      - name: init
        run: make init

      - uses: docker/metadata-action@v5
        id: metadata
        with:
          images: |
            ghcr.io/${{ github.repository_owner }}/xsdev
          tags: |
            master
          labels: |
            maintainer=${{ github.repository_owner }}

      - uses: docker/setup-buildx-action@v3

      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - uses: docker/build-push-action@v6
        with:
          context: .
          platforms: linux/amd64
          push: ${{ github.ref == 'refs/heads/master' }}
          tags: ${{ steps.metadata.outputs.tags }}
          labels: ${{ steps.metadata.outputs.labels }}
