diff --git a/.github/scripts/codec-checksums.sh b/.github/scripts/codec-checksums.sh new file mode 100755 index 0000000..4c92af8 --- /dev/null +++ b/.github/scripts/codec-checksums.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Rewrite linux/Dockerfile's _SHA256 for each _VERSION that differs from ; prints what changed. +# Unchanged versions are never re-hashed, so a tarball swapped upstream still fails the build's sha256sum -c. +set -euo pipefail + +dockerfile=linux/Dockerfile +base=${1:?usage: codec-checksums.sh } +base_file=$(git show "${base}:${dockerfile}") + +while IFS='=' read -r var ver; do + lib=${var%_VERSION} + grep -q "^ARG ${lib}_SHA256=" "$dockerfile" || continue + old=$(sed -n "s/^ARG ${var}=//p" <<<"$base_file") + [ "$ver" = "$old" ] && continue + + template=$(grep -oE "https://[^\"]*\\\$\\{${var}\\}[^\"]*" "$dockerfile" | head -1 || true) + if [ -z "$template" ]; then + echo "::error::no download URL in ${dockerfile} uses \${${var}}" >&2 + exit 1 + fi + url=${template//"\${${var}}"/$ver} + sha=$(curl -fsSL --retry 3 "$url" | sha256sum | cut -d' ' -f1) + + sed "s/^ARG ${lib}_SHA256=.*/ARG ${lib}_SHA256=${sha}/" "$dockerfile" > "${dockerfile}.tmp" + mv "${dockerfile}.tmp" "$dockerfile" + echo "${lib} ${old:-unset} -> ${ver}" +done < <(sed -n 's/^ARG \([A-Z0-9_]*_VERSION\)=\(.*\)$/\1=\2/p' "$dockerfile") diff --git a/.github/workflows/codec-checksums.yml b/.github/workflows/codec-checksums.yml new file mode 100644 index 0000000..7be6aff --- /dev/null +++ b/.github/workflows/codec-checksums.yml @@ -0,0 +1,61 @@ +name: Codec checksums + +# Renovate bumps a codec *_VERSION in linux/Dockerfile but can't recompute its *_SHA256; this commits it to the PR. +on: + pull_request: + branches: [main] + paths: ['linux/Dockerfile'] + +permissions: + contents: read + +jobs: + checksums: + # Same-repo Renovate branches only; a fork PR's token can't push, and nothing else should be rewritten. + if: startsWith(github.head_ref, 'renovate/') && github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + contents: write # push the checksum commit + actions: write # re-run the required checks on it + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - name: Recompute checksums for changed versions + id: sums + env: + BASE_REF: ${{ github.base_ref }} + run: | + set -euo pipefail + updated=$(.github/scripts/codec-checksums.sh "origin/${BASE_REF}") + # Decide on the file, not the output: a PR whose checksums are already right reports versions but changes nothing. + if git diff --quiet -- linux/Dockerfile; then + echo "No checksum to update.${updated:+ Versions already current: $updated}" + echo "changed=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + echo "$updated" + { + echo "changed=true" + echo "summary<> "$GITHUB_OUTPUT" + + # A push made with GITHUB_TOKEN starts no workflow, so the required checks are dispatched by hand. + - name: Commit and re-run the required checks + if: steps.sums.outputs.changed == 'true' + env: + GH_TOKEN: ${{ github.token }} + HEAD_REF: ${{ github.head_ref }} + SUMMARY: ${{ steps.sums.outputs.summary }} + run: | + set -euo pipefail + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + git commit -q -am "chore(deps): update codec checksums" -m "$SUMMARY" + git push origin "HEAD:${HEAD_REF}" + gh workflow run mirror.yml --ref "$HEAD_REF" + gh workflow run codeql.yml --ref "$HEAD_REF" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7efbc7f..b9ab4ea 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,6 +11,7 @@ on: branches: [ "main" ] schedule: - cron: '27 3 * * 1' + workflow_dispatch: permissions: contents: read diff --git a/linux/Dockerfile b/linux/Dockerfile index 5d1d417..9f3df45 100644 --- a/linux/Dockerfile +++ b/linux/Dockerfile @@ -21,10 +21,16 @@ ARG FFMPEG_TAG=n8.1.2 # and the build proceeds — auto-updates above n8.1.2 keep flowing. ARG FFMPEG_COMMIT=38b88335f99e76ed89ff3c93f877fdefce736c13 ARG FFMPEG_COMMIT_TAG=n8.1.2 +# Renovate bumps these; codec-checksums.yml then rewrites the matching *_SHA256 below. +# renovate: datasource=repology depName=alpine_edge/lame versioning=loose extractVersion=^(?[^-]+) ARG LAME_VERSION=3.100 +# renovate: datasource=github-tags depName=xiph/ogg extractVersion=^v(?\d+\.\d+(?:\.\d+)?)$ ARG OGG_VERSION=1.3.5 +# renovate: datasource=github-tags depName=xiph/vorbis extractVersion=^v(?\d+\.\d+(?:\.\d+)?)$ ARG VORBIS_VERSION=1.3.7 +# renovate: datasource=github-tags depName=xiph/opus extractVersion=^v(?\d+\.\d+(?:\.\d+)?)$ ARG OPUS_VERSION=1.5.2 +# renovate: datasource=repology depName=alpine_edge/opencore-amr versioning=loose extractVersion=^(?[^-]+) ARG OPENCORE_AMR_VERSION=0.1.6 # SHA-256 of each source tarball (verified before building). diff --git a/renovate.json b/renovate.json index 942e1ee..1b52fb3 100644 --- a/renovate.json +++ b/renovate.json @@ -1,4 +1,5 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["github>chodeus/chodeus-ops"] + "extends": ["github>chodeus/chodeus-ops"], + "gitIgnoredAuthors": ["41898282+github-actions[bot]@users.noreply.github.com"] }