Files
Draupnir/.github/workflows/ghcr-release.yml
T
2026-05-05 12:31:43 +02:00

84 lines
2.6 KiB
YAML

# SPDX-FileCopyrightText: 2026 Catalan Lover <catalanlover@protonmail.com>
#
# SPDX-License-Identifier: CC0-1.0
name: "GHCR - Release"
on:
release:
types: [published]
env:
PLATFORMS: linux/amd64,linux/arm64
IMG_SOURCE: https://github.com/${{ github.repository }}
jobs:
ghcr-release:
runs-on: ubuntu-latest
permissions:
id-token: write
packages: write
contents: read
attestations: write
artifact-metadata: write
steps:
- name: Check out
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Get release tag
id: release_version
run: echo "release_version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Set lowercase image owner
id: image_owner
run:
echo "image_owner=$(echo '${{ github.repository_owner }}' | tr
'[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
# Needed for multi platform builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: ${{ env.PLATFORMS }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image to GHCR
id: push_ghcr
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
# Shared Buildx cache scope reused by all container image workflows.
# Keep the scope name aligned across workflows to maximize cache hits.
cache-from: type=gha,scope=draupnir-container-build
cache-to: type=gha,scope=draupnir-container-build,mode=max
labels: |
org.opencontainers.image.source=${{ env.IMG_SOURCE }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ github.ref_name }}
org.opencontainers.image.licenses=Apache-2.0
sbom: true
tags: |
ghcr.io/${{ steps.image_owner.outputs.image_owner }}/draupnir:${{ steps.release_version.outputs.release_version }}
- name: Attest pushed image
id: attest
uses: actions/attest@v4
with:
subject-name:
ghcr.io/${{ steps.image_owner.outputs.image_owner }}/draupnir
subject-digest: ${{ steps.push_ghcr.outputs.digest }}
push-to-registry: true