49 lines
1.5 KiB
YAML
49 lines
1.5 KiB
YAML
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
|
|
atom="${{ inputs.atom }}"
|
|
version="${{ inputs.version }}"
|
|
ebuild_dir="./${atom}"
|
|
name="${atom##*/}"
|
|
want_ebuild="${ebuild_dir}/${name}-${version}.ebuild"
|
|
message=""
|
|
|
|
if [[ -f "${want_ebuild}" ]]; then
|
|
echo "Ebuild already exists"
|
|
else
|
|
shopt -s nullglob
|
|
existing_ebuilds=( "${ebuild_dir}/${name}-"*.ebuild )
|
|
if (( ${#existing_ebuilds[@]} == 0 )); then
|
|
echo "No existing ebuild to copy from" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Use version sort: plain globbing would put 2.9.0 after 2.10.0.
|
|
latest_existing_ebuild=$(
|
|
printf '%s\n' "${existing_ebuilds[@]}" \
|
|
| sort -V \
|
|
| tail -n 1
|
|
)
|
|
echo "Copying ${latest_existing_ebuild} to ${want_ebuild}"
|
|
cp "${latest_existing_ebuild}" "${want_ebuild}"
|
|
message="add ${version}"
|
|
fi
|
|
echo "message=${message}" >> "${GITHUB_OUTPUT}"
|