diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml new file mode 100644 index 0000000..69053f2 --- /dev/null +++ b/.github/workflows/image.yml @@ -0,0 +1,59 @@ +name: Image + +# Publishes the container image to GitHub Container Registry for each release +# tag: ghcr.io//:, :. and :latest, for +# amd64 and arm64. The heretix-demo repository runs these images. +# +# Run it by hand to publish a release tagged before this workflow existed: +# it builds that tag with this workflow. That also moves :latest to it. +on: + push: + tags: ["v*"] + workflow_dispatch: + inputs: + tag: + description: "Release tag to publish, e.g. v1.2.3" + required: true + +permissions: + contents: read + packages: write + +jobs: + image: + runs-on: ubuntu-latest + env: + TAG: ${{ inputs.tag || github.ref_name }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ env.TAG }} + + - uses: docker/setup-qemu-action@v3 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}},value=${{ env.TAG }} + type=semver,pattern={{major}}.{{minor}},value=${{ env.TAG }} + flavor: latest=true + + - 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 }} + cache-from: type=gha + cache-to: type=gha,mode=max