Files
profilarr/.github/workflows/release.yml
2026-05-26 14:17:55 +09:30

229 lines
7.2 KiB
YAML

name: Release
on:
push:
branches: [develop]
tags: ['v*']
env:
REGISTRY: ghcr.io
permissions:
contents: read
jobs:
# ─── Build per-arch Docker images ──────────────────────────────────────
docker:
name: Docker (${{ matrix.image }} / ${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- image: profilarr
dockerfile: Dockerfile
platform: linux/amd64
runner: ubuntu-latest
- image: profilarr
dockerfile: Dockerfile
platform: linux/arm64
runner: ubuntu-24.04-arm
- image: profilarr-parser
dockerfile: Dockerfile.parser
platform: linux/amd64
runner: ubuntu-latest
- image: profilarr-parser
dockerfile: Dockerfile.parser
platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Set Image Base
run: echo "IMAGE_BASE=ghcr.io/$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine channel
id: channel
env:
REF: ${{ github.ref }}
run: |
if [[ "$REF" == refs/tags/v* ]]; then
echo "value=stable" >> "$GITHUB_OUTPUT"
else
echo "value=develop" >> "$GITHUB_OUTPUT"
fi
- name: Determine build version
id: version
env:
REF: ${{ github.ref }}
run: |
if [[ "$REF" == refs/tags/v* ]]; then
echo "value=${REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
else
echo "value=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
fi
- name: Determine commit short sha
id: commit
run: echo "value=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
- name: Determine build timestamp
id: builtat
run: echo "value=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_BASE }}/${{ matrix.image }}
labels: |
org.opencontainers.image.licenses=AGPL-3.0
- name: Build and push by digest
id: build
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platform }}
build-args: |
VITE_CHANNEL=${{ steps.channel.outputs.value }}
PROFILARR_VERSION=${{ steps.version.outputs.value }}
PROFILARR_COMMIT=${{ steps.commit.outputs.value }}
PROFILARR_BUILT_AT=${{ steps.builtat.outputs.value }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.IMAGE_BASE }}/${{ matrix.image }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=registry,ref=${{ env.IMAGE_BASE }}/${{ matrix.image }}:buildcache-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
cache-to: type=registry,ref=${{ env.IMAGE_BASE }}/${{ matrix.image }}:buildcache-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }},mode=max
- name: Export digest
id: digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
echo "hash=${digest#sha256:}" >> "$GITHUB_OUTPUT"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v7
with:
name: digest--${{ matrix.image }}--${{ steps.digest.outputs.hash }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# ─── Merge into multi-arch manifest ────────────────────────────────────
manifest:
name: Manifest (${{ matrix.image }})
needs: [docker]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
image: [profilarr, profilarr-parser]
steps:
- name: Set Image Base
run: echo "IMAGE_BASE=ghcr.io/$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Download digests
uses: actions/download-artifact@v8
with:
pattern: digest--${{ matrix.image }}--*
path: /tmp/digests
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_BASE }}/${{ matrix.image }}
tags: |
type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.IMAGE_BASE }}/${{ matrix.image }}@sha256:%s ' *)
- name: Inspect manifest
run: |
docker buildx imagetools inspect ${{ env.IMAGE_BASE }}/${{ matrix.image }}:${{ steps.meta.outputs.version }}
# ─── Publish GitHub release notes ──────────────────────────────────────
github-release:
name: GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
needs: [manifest]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Generate release notes
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --current --output RELEASE_NOTES.md
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
if gh release view "$TAG" >/dev/null 2>&1; then
gh release edit "$TAG" \
--title "$TAG" \
--notes-file RELEASE_NOTES.md \
--latest
else
gh release create "$TAG" \
--title "$TAG" \
--notes-file RELEASE_NOTES.md \
--verify-tag \
--latest
fi