name: Release image on: release: types: [published] workflow_dispatch: permissions: contents: read packages: write concurrency: group: release-image cancel-in-progress: false jobs: image: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - name: Log in to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to Gitea uses: docker/login-action@v3 with: registry: git.tben.me 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 }} 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/')" ghcr="$(printf '%s\n' \ "ghcr.io/moduletrace/cobble:latest" \ "ghcr.io/moduletrace/cobble:${version}" \ "ghcr.io/moduletrace/cobble:${minor}" \ "ghcr.io/moduletrace/cobble:${sha}")" gitea="$(printf '%s\n' \ "git.tben.me/moduletrace/cobble:latest" \ "git.tben.me/moduletrace/cobble:${version}" \ "git.tben.me/moduletrace/cobble:${minor}" \ "git.tben.me/moduletrace/cobble:${sha}")" else ghcr="ghcr.io/moduletrace/cobble:${sha}" gitea="git.tben.me/moduletrace/cobble:${sha}" fi { echo "ghcr<> "$GITHUB_OUTPUT" # The registry the installer defaults to, so this one must succeed. - name: Build and push to GHCR uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.tags.outputs.ghcr }} provenance: false sbom: false cache-from: type=gha cache-to: type=gha,mode=max # The mirror's registry, from the image just built: no second build, # and Cloudflare rate limiting git.tben.me (429/1015 on blob uploads) # can never fail a release the installer depends on. - name: Mirror to Gitea continue-on-error: true env: GITEA_TAGS: ${{ steps.tags.outputs.gitea }} GHCR_IMAGES: ${{ steps.tags.outputs.ghcr }} run: | set -euo pipefail first_ghcr="$(printf '%s\n' "$GHCR_IMAGES" | head -n1)" args=() while IFS= read -r tag; do [ -n "$tag" ] || continue args+=(--tag "${tag}") done <<< "$GITEA_TAGS" docker buildx imagetools create "${args[@]}" "${first_ghcr}"