new ebuild: dev-util/opencode-desktop-bin
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
name: "Fetch the latest GitHub release"
|
||||
description: "Find the newest stable semver release (vX.Y.Z) in a GitHub repository and check release assets"
|
||||
inputs:
|
||||
repository:
|
||||
description: "GitHub repository in owner/name form"
|
||||
required: true
|
||||
assets:
|
||||
description: "space separated release asset names that must be available"
|
||||
required: false
|
||||
default: ""
|
||||
version:
|
||||
description: "use this version instead of detecting the latest one (may include a leading v)"
|
||||
required: false
|
||||
default: ""
|
||||
outputs:
|
||||
version:
|
||||
description: "version without the v prefix; empty if no suitable release was found"
|
||||
tag:
|
||||
description: "release tag"
|
||||
available:
|
||||
description: "true when the release and all requested assets are available"
|
||||
forced:
|
||||
description: "true when the version was supplied as an input"
|
||||
runs:
|
||||
using: docker
|
||||
image: docker://linuxserver/yq
|
||||
entrypoint: /bin/bash
|
||||
args:
|
||||
- -c
|
||||
- |
|
||||
set -euo pipefail
|
||||
repo="${{ inputs.repository }}"
|
||||
forced="${{ inputs.version }}"
|
||||
assets="${{ inputs.assets }}"
|
||||
|
||||
forced_flag=false
|
||||
if [[ -n "${forced}" ]]; then
|
||||
version="${forced#v}"
|
||||
if ! [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Invalid version: ${forced}" >&2
|
||||
exit 1
|
||||
fi
|
||||
forced_flag=true
|
||||
else
|
||||
auth=()
|
||||
if [[ -n "${GH_TOKEN:-}" ]]; then
|
||||
auth=(-H "Authorization: Bearer ${GH_TOKEN}")
|
||||
fi
|
||||
|
||||
releases=$(curl -fsSL "${auth[@]}" \
|
||||
"https://api.github.com/repos/${repo}/releases?per_page=100")
|
||||
|
||||
# Only stable vX.Y.Z tags belong to this package. Other tags in the
|
||||
# repository (e.g. process-daemon-v*) and prereleases must be ignored.
|
||||
version=$(printf '%s' "${releases}" | jq -r '
|
||||
[ .[]
|
||||
| select(.draft == false and .prerelease == false)
|
||||
| .tag_name
|
||||
| select(test("^v[0-9]+\\.[0-9]+\\.[0-9]+$"))
|
||||
| ltrimstr("v")
|
||||
]
|
||||
| sort_by(split(".") | map(tonumber))
|
||||
| last // empty
|
||||
')
|
||||
fi
|
||||
|
||||
if [[ -z "${version}" ]]; then
|
||||
echo "No suitable stable release found" >&2
|
||||
echo "version=" >> "${GITHUB_OUTPUT}"
|
||||
echo "tag=" >> "${GITHUB_OUTPUT}"
|
||||
echo "available=false" >> "${GITHUB_OUTPUT}"
|
||||
echo "forced=${forced_flag}" >> "${GITHUB_OUTPUT}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
tag="v${version}"
|
||||
available=true
|
||||
for asset in ${assets}; do
|
||||
url="https://github.com/${repo}/releases/download/${tag}/${asset}"
|
||||
echo "Checking ${url}"
|
||||
if ! curl -fsSIL -o /dev/null "${url}"; then
|
||||
echo "Release asset is not available yet: ${asset}" >&2
|
||||
available=false
|
||||
fi
|
||||
done
|
||||
|
||||
echo "version=${version}" >> "${GITHUB_OUTPUT}"
|
||||
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
|
||||
echo "available=${available}" >> "${GITHUB_OUTPUT}"
|
||||
echo "forced=${forced_flag}" >> "${GITHUB_OUTPUT}"
|
||||
Reference in New Issue
Block a user