diff --git a/.gitea/actions/copy-latest-ebuild-as/action.yml b/.gitea/actions/copy-latest-ebuild-as/action.yml new file mode 100644 index 0000000..b6308ee --- /dev/null +++ b/.gitea/actions/copy-latest-ebuild-as/action.yml @@ -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="added ${{ inputs.version }}" + fi + echo "message=${message}" >> "${GITHUB_OUTPUT}" diff --git a/.gitea/actions/drop-ebuilds-matching/Dockerfile b/.gitea/actions/drop-ebuilds-matching/Dockerfile new file mode 100644 index 0000000..35453b0 --- /dev/null +++ b/.gitea/actions/drop-ebuilds-matching/Dockerfile @@ -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" ] diff --git a/.gitea/actions/drop-ebuilds-matching/action.yml b/.gitea/actions/drop-ebuilds-matching/action.yml new file mode 100644 index 0000000..75eb5a9 --- /dev/null +++ b/.gitea/actions/drop-ebuilds-matching/action.yml @@ -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}" diff --git a/.gitea/actions/fetch-electron-update/action.yml b/.gitea/actions/fetch-electron-update/action.yml new file mode 100644 index 0000000..17d04a8 --- /dev/null +++ b/.gitea/actions/fetch-electron-update/action.yml @@ -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}" + ) diff --git a/.gitea/actions/pkgdev-manifest/action.yml b/.gitea/actions/pkgdev-manifest/action.yml new file mode 100644 index 0000000..4a203a2 --- /dev/null +++ b/.gitea/actions/pkgdev-manifest/action.yml @@ -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 + ' diff --git a/.gitea/actions/update-electron-bin-ebuild/action.yml b/.gitea/actions/update-electron-bin-ebuild/action.yml new file mode 100644 index 0000000..07849ca --- /dev/null +++ b/.gitea/actions/update-electron-bin-ebuild/action.yml @@ -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}} diff --git a/.gitea/actions/update-electron-bin-ebuild/entrypoint.sh b/.gitea/actions/update-electron-bin-ebuild/entrypoint.sh new file mode 100755 index 0000000..d62cebf --- /dev/null +++ b/.gitea/actions/update-electron-bin-ebuild/entrypoint.sh @@ -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}" diff --git a/.gitea/workflows/update-yandex-music.yaml b/.gitea/workflows/update-yandex-music.yaml deleted file mode 100644 index d485337..0000000 --- a/.gitea/workflows/update-yandex-music.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: Update Yandex Music -run-name: ${{gitea.actor}} updating yandex-music ebuild if needed -on: - schedule: - - cron: '0 * * * *' - -jobs: - Check-New-Releases: - runs-on: ubuntu-latest - steps: - - run: echo Test diff --git a/.gitea/workflows/yandex-music.yaml b/.gitea/workflows/yandex-music.yaml new file mode 100644 index 0000000..d8cbbe0 --- /dev/null +++ b/.gitea/workflows/yandex-music.yaml @@ -0,0 +1,57 @@ +name: yandex-music +on: + workflow_dispatch: + push: + branches: + - "master" + tags: + - "v*" + schedule: + - cron: "0 * * * *" + +jobs: + check-and-update: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + token: ${{GITEA_TOKEN}} + + - name: Fetch update manifest + uses: ./.gitea/actions/fetch-electron-update + id: manifest + with: + url: https://desktop.app.music.yandex.net/stable/latest-linux.yml + + - name: Remove deprecated ebuilds + uses: ./.gitea/actions/drop-ebuilds-matching + id: cleanup + with: + atom: media-sound/yandex-music + condition: ${{steps.manifest.outputs.deprecated_versions}} + + - name: Create ebuild for latest version + uses: ./.gitea/actions/copy-latest-ebuild-as + id: latest + with: + atom: media-sound/yandex-music + version: ${{steps.manifest.outputs.version}} + + - name: Check repo for validity + uses: ./.gitea/actions/pkgdev-manifest + + - name: Check repo for validity + uses: pkgcore/pkgcheck-action@v1 + with: + args: --keywords=-RedundantVersion media-sound/yandex-music + + - name: Commit new ebuild + uses: EndBug/add-and-commit@v9 + if: ${{steps.latest.outputs.message != '' || steps.cleanup.outputs.message != ''}} + with: + add: media-sound/yandex-music + author_name: Automation + author_email: noreply@ratigorsk-12.ru + message: ${{ format('media-sound/yandex-music {0} {1}', steps.cleanup.outputs.message, steps.latest.outputs.message) }} + push: true