Automatic workflow to update yandex-music ebuild
Some checks failed
yandex-music / check-and-update (push) Failing after 29s

This commit was merged in pull request #1.
This commit is contained in:
Petr Polezhaev
2026-02-02 15:40:24 +03:00
committed by Petr Polezhaev
parent 6e6228033f
commit 32173db78b
17 changed files with 254 additions and 161 deletions

View File

@@ -0,0 +1,34 @@
name: "Copy the latest ebuild for the package as version given"
description: "Checks if the ebuild with the specified version exists and if not - copies the latest existing one over"
inputs:
atom:
description: "category/name package atom"
required: true
version:
description: "the desired version of the ebuild"
required: true
outputs:
message:
description: "space separated list of versions added"
value: ${{ steps.copy.outputs.message }}
runs:
using: composite
steps:
- id: copy
shell: bash
run: |
set -euo pipefail
ebuild_dir="./${{ inputs.atom }}"
name=$(basename "${{ inputs.atom }}")
want_ebuild="${ebuild_dir}/${name}-${{ inputs.version }}.ebuild"
message=""
if [[ -f "${want_ebuild}" ]]; then
echo "Ebuild already exists"
else
existing_ebuilds=( "${ebuild_dir}"/*.ebuild )
latest_existing_ebuild="${existing_ebuilds[-1]}"
echo "Copying ${latest_existing_ebuild} to ${want_ebuild}"
cp "${latest_existing_ebuild}" "${want_ebuild}"
message="add ${{ inputs.version }}"
fi
echo "message=${message}" >> "${GITHUB_OUTPUT}"

View File

@@ -0,0 +1,5 @@
FROM gentoo/portage:latest as portage
FROM gentoo/stage3:amd64-openrc
COPY --from=portage /var/db/repos/gentoo /var/db/repos/gentoo
RUN emerge -q app-portage/portage-utils && rm -Rf /var/db/repos/gentoo
ENTRYPOINT [ "/bin/bash" ]

View File

@@ -0,0 +1,36 @@
name: "Drop ebuilds matching the condition"
description: "Checks if any ebuild for the package matches the condition and if so - removes them"
inputs:
atom:
description: "category/name package atom"
required: true
condition:
description: "version condition used to match ebuilds to drop"
required: true
outputs:
message:
description: "space-separated list of removed ebuild versions"
runs:
using: docker
image: Dockerfile
args:
- -c
- |
set -euo pipefail
condition_atom=$(echo "${{inputs.condition}}" | sed -r 's:^(<|>)=?:\0${{inputs.atom}}-:')
existing_ebuilds=( "./${{inputs.atom}}"/*.ebuild )
category=$(dirname "${{inputs.atom}}")
message=""
for ebuild in ${existing_ebuilds[@]}; do
p="=${category}/$(basename "${ebuild%.*}")"
echo "Checking ${p} vs ${condition_atom}"
if qatom -qc "${p}" "${condition_atom}" | grep -cq '=='; then
echo "Removing ${ebuild}"
rm -f "${ebuild}"
if [[ -z "${message}" ]]; then
message="drop"
fi
message="${message} `qatom -F '%{PV}' "${p}"`"
fi;
done;
echo "message=${message}" >> "${GITHUB_OUTPUT}"

View File

@@ -0,0 +1,26 @@
name: "Fetch the electron-updater manifest"
description: "Check the specified manifest and extract the version and deprecated versions"
inputs:
url:
description: "electron-updater update manifest url to check"
required: true
outputs:
version:
description: "Latest version for the package"
deprecated_versions:
description: "A condition string for deprecated packages"
runs:
using: docker
image: docker://linuxserver/yq
entrypoint: /bin/bash
args:
- -c
- |
set -euo pipefail
manifest=$(mktemp)
curl -L -s "${{ inputs.url }}" | yq -r '.version, .commonConfig.DEPRECATED_VERSIONS' | (
read version;
read deprecated;
echo "version=${version}" >> "${GITHUB_OUTPUT}"
echo "deprecated_versions=${deprecated}" >> "${GITHUB_OUTPUT}"
)

View File

@@ -0,0 +1,23 @@
name: "Construct manifests using pkgdev"
description: "Construct manifest using pkgdev"
runs:
using: composite
steps:
- name: Cache pkgdev
uses: actions/cache@v5
with:
path: |
~/.cache/pkgcore
~/.cache/pkgcheck
~/.cache/distfiles
key: pkgdev
- name: Run pkgdev manifest
uses: docker://git.ratigorsk-12.ru/gentoo/pkgdev-docker:master
with:
args: >
-c '
set -euo pipefail
pmaint sync gentoo
pkgdev manifest -d ~/.cache/distfiles
'

View File

@@ -0,0 +1,18 @@
name: "Update electron app bin ebuild if needed"
description: "Check the update manifest and copy an existing version ebuild if a new version is out"
inputs:
atom:
description: "category/name specifying the ebuild to update"
required: true
update-url:
description: "electron-updater update manifest url to check"
required: true
outputs:
changes:
description: "if any changes were produced"
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{inputs.atom}}
- ${{inputs.update-url}}

View File

@@ -0,0 +1,40 @@
#!/bin/bash
set -euo pipefail
atom="${1}"
update_url="${2}"
echo "Fetching update manifest from ${update_url}"
update_manifest=$(mktemp)
curl --follow -s -o "${update_manifest}" "${update_url}"
latest_version=$(yq -r '.version' "${update_manifest}")
echo "Latest version: ${latest_version}"
if [[ -z "${latest_version}" ]]; then
echo "No version tag in the downloaded manifest" >&2
cat "${update_manifest}" >&2
exit 1
fi
ebuild_dir="${GITHUB_WORKSPACE}/$atom"
latest_ebuild="${ebuild_dir}/yandex-music-${latest_version}.ebuild"
if [[ -f "${latest_ebuild}" ]]; then
echo "Ebuild for version ${latest_version} already exists"
exit 0
fi
echo "New version detected: ${latest_version}"
existing_ebuilds=( "${ebuild_dir}"/*.ebuild )
latest_existing_ebuild="${existing_ebuilds[-1]}"
if [[ -z "${latest_existing_ebuild}" ]]; then
echo "Error: No existing ebuild found to copy from" >&2
exit 1
fi
echo "Copying ${latest_existing_ebuild} to ${latest_ebuild}"
cp "${latest_existing_ebuild}" "${latest_ebuild}"