Files
cobble/.github/workflows/release.yml
T
2026-10-22 13:58:59 +01:00

93 lines
2.7 KiB
YAML

name: Release image
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
packages: write
concurrency:
group: release-image
cancel-in-progress: false
jobs:
# One leg per registry, so a registry having a bad day (Cloudflare rate
# limits git.tben.me's blob uploads) can never fail the release image that
# the installer installs from by default.
image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- registry: ghcr.io
soft: "false"
- registry: git.tben.me
soft: "true"
continue-on-error: ${{ matrix.soft }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: matrix.registry == 'ghcr.io'
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Gitea
if: matrix.registry == 'git.tben.me'
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ secrets.GITEA_USERNAME }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Work out image tags
id: tags
env:
EVENT: ${{ github.event_name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
REGISTRY: ${{ matrix.registry }}
run: |
set -euo pipefail
sha="sha-${GITHUB_SHA::12}"
if [ "$EVENT" = "release" ] && [ -n "$RELEASE_TAG" ]; then
version="$RELEASE_TAG"
minor="$(printf '%s' "$version" | sed -E 's/^v?([0-9]+)\.([0-9]+).*/\1.\2/')"
tags="$(printf '%s\n' \
"${REGISTRY}/moduletrace/cobble:latest" \
"${REGISTRY}/moduletrace/cobble:${version}" \
"${REGISTRY}/moduletrace/cobble:${minor}" \
"${REGISTRY}/moduletrace/cobble:${sha}")"
else
tags="$(printf '%s\n' \
"${REGISTRY}/moduletrace/cobble:${sha}")"
fi
{
echo "tags<<EOF"
echo "$tags"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags }}
provenance: false
sbom: false
cache-from: type=gha,scope=${{ matrix.registry }}
cache-to: type=gha,mode=max,scope=${{ matrix.registry }}