Files
qbz/.github/workflows/release-gentoo.yml
T

219 lines
7.9 KiB
YAML

name: release-gentoo
# The overlay repo (vicrodh/qbz-overlay) must NEVER be edited by hand: any
# ebuild change without a Manifest regeneration bricks emerge with a digest
# mismatch (issue #557 — the 2.0.0 RESTRICT edit was pushed manually and
# skipped the Manifest). Template changes between releases are published by
# re-running THIS workflow via workflow_dispatch with the released version.
on:
workflow_run:
workflows: ["release-linux"]
types: [completed]
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 1.2.0)"
required: true
type: string
publish:
description: "Push generated ebuilds and Manifests to qbz-overlay"
required: false
default: false
type: boolean
concurrency:
group: gentoo-overlay
cancel-in-progress: false
permissions:
contents: read
jobs:
update-overlay:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') && !contains(github.event.workflow_run.head_branch, '-')) }}
steps:
- name: Checkout app repo
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.ref }}
- name: Determine version
id: version
env:
EVENT_NAME: ${{ github.event_name }}
WORKFLOW_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
DISPATCH_VERSION: ${{ inputs.version }}
run: |
if [[ "$EVENT_NAME" == "workflow_run" ]]; then
REF="$WORKFLOW_HEAD_BRANCH"
if [[ ! "$REF" =~ ^v[0-9]+(\.[0-9]+){1,3}([.-][0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid tag: $REF"
exit 1
fi
VERSION="${REF#v}"
else
VERSION="$DISPATCH_VERSION"
fi
if [[ ! "$VERSION" =~ ^[0-9]+(\.[0-9]+){2}([.-][0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid release version: $VERSION"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Version: $VERSION"
- name: Clone overlay repo
env:
OVERLAY_PAT: ${{ secrets.APT_REPO_TOKEN }}
SHOULD_PUBLISH: ${{ github.event_name == 'workflow_run' || inputs.publish }}
run: |
if [[ "$SHOULD_PUBLISH" == "true" ]]; then
if [[ -z "$OVERLAY_PAT" ]]; then
echo "::error::APT_REPO_TOKEN is required when publishing"
exit 1
fi
git clone "https://x-access-token:${OVERLAY_PAT}@github.com/vicrodh/qbz-overlay.git" /tmp/qbz-overlay
else
git clone https://github.com/vicrodh/qbz-overlay.git /tmp/qbz-overlay
fi
cd /tmp/qbz-overlay
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Update binary ebuild
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
cd /tmp/qbz-overlay/media-sound/qbz-bin
# Remove old version ebuilds (keep metadata.xml)
rm -f qbz-bin-*.ebuild
# Copy template from app repo and update version
cp "${{ github.workspace }}/packaging/gentoo/qbz-bin.ebuild.template" "qbz-bin-${VERSION}.ebuild"
echo "=== qbz-bin-${VERSION}.ebuild ==="
cat "qbz-bin-${VERSION}.ebuild"
- name: Update source ebuild
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
cd /tmp/qbz-overlay/media-sound/qbz
# Remove old version ebuilds (keep metadata.xml)
rm -f qbz-*.ebuild
# Copy template from app repo and update version
cp "${{ github.workspace }}/packaging/gentoo/qbz.ebuild.template" "qbz-${VERSION}.ebuild"
echo "=== qbz-${VERSION}.ebuild ==="
cat "qbz-${VERSION}.ebuild"
- name: Generate Manifests
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
# Helper: compute BLAKE2B and SHA512 for a file, output Manifest line
manifest_line() {
local type="$1" name="$2" file="$3"
local size blake2b sha512
size=$(stat -c%s "$file")
blake2b=$(b2sum "$file" | awk '{print $1}')
sha512=$(sha512sum "$file" | awk '{print $1}')
echo "${type} ${name} ${size} BLAKE2B ${blake2b} SHA512 ${sha512}"
}
# --- qbz-bin Manifest ---
cd /tmp/qbz-overlay/media-sound/qbz-bin
MANIFEST=""
# Download DIST files and hash them. Both are required: each is
# keyworded in the ebuild, so publishing a Manifest without either
# DIST entry bricks emerge on that architecture. The arm64 release
# runs independently and can finish well after amd64.
for arch_pair in "amd64:amd64" "aarch64:arm64"; do
arch="${arch_pair%%:*}"
dist_name="qbz_${VERSION}_${arch}.tar.gz"
url="https://github.com/vicrodh/qbz/releases/download/v${VERSION}/${dist_name}"
echo "Downloading ${dist_name}..."
ok=0
for attempt in $(seq 1 60); do
if curl -sLf "$url" -o "/tmp/${dist_name}"; then
ok=1
break
fi
echo "Attempt ${attempt} failed for ${dist_name}, retrying in 30s..."
sleep 30
done
if [[ "$ok" == 1 ]]; then
MANIFEST+="$(manifest_line DIST "$dist_name" "/tmp/${dist_name}")"$'\n'
else
echo "ERROR: required asset ${dist_name} not found at ${url}"
exit 1
fi
done
# Hash the ebuild itself
MANIFEST+="$(manifest_line EBUILD "qbz-bin-${VERSION}.ebuild" "qbz-bin-${VERSION}.ebuild")"$'\n'
# Hash metadata.xml
MANIFEST+="$(manifest_line MISC "metadata.xml" "metadata.xml")"$'\n'
echo "$MANIFEST" > Manifest
echo "=== qbz-bin Manifest ==="
cat Manifest
# --- qbz (source) Manifest ---
cd /tmp/qbz-overlay/media-sound/qbz
MANIFEST=""
# Download source tarball
dist_name="qbz-${VERSION}.tar.gz"
url="https://github.com/vicrodh/qbz/archive/refs/tags/v${VERSION}.tar.gz"
echo "Downloading source tarball..."
if curl -sLf "$url" -o "/tmp/${dist_name}"; then
MANIFEST+="$(manifest_line DIST "$dist_name" "/tmp/${dist_name}")"$'\n'
else
echo "ERROR: source tarball not found at ${url}"
exit 1
fi
# Hash the ebuild
MANIFEST+="$(manifest_line EBUILD "qbz-${VERSION}.ebuild" "qbz-${VERSION}.ebuild")"$'\n'
# Hash metadata.xml
MANIFEST+="$(manifest_line MISC "metadata.xml" "metadata.xml")"$'\n'
echo "$MANIFEST" > Manifest
echo "=== qbz Manifest ==="
cat Manifest
- name: Commit and push
if: github.event_name == 'workflow_run' || inputs.publish
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
cd /tmp/qbz-overlay
git add -A
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Update to v${VERSION}"
git push
- name: Upload dry-run overlay metadata
if: github.event_name == 'workflow_dispatch' && !inputs.publish
uses: actions/upload-artifact@v7
with:
name: gentoo-overlay-dry-run
retention-days: 7
path: |
/tmp/qbz-overlay/media-sound/qbz-bin/*.ebuild
/tmp/qbz-overlay/media-sound/qbz-bin/Manifest
/tmp/qbz-overlay/media-sound/qbz/*.ebuild
/tmp/qbz-overlay/media-sound/qbz/Manifest
if-no-files-found: error