43 lines
936 B
Bash
Executable File
43 lines
936 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
printf 'Usage: GITEA_TOKEN=... %s PATH_TO_RPM FEDORA_RELEASE\n' "$0" >&2
|
|
}
|
|
|
|
if (( $# != 2 )); then
|
|
usage
|
|
exit 2
|
|
fi
|
|
|
|
rpm_path=$1
|
|
fedora_release=$2
|
|
|
|
if [[ ! -f $rpm_path || $rpm_path != *.rpm ]]; then
|
|
printf 'Error: %s is not an RPM file.\n' "$rpm_path" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if [[ ! $fedora_release =~ ^[0-9]+$ ]]; then
|
|
printf 'Error: Fedora release must be a number, such as 44.\n' >&2
|
|
exit 2
|
|
fi
|
|
|
|
if [[ -z ${GITEA_TOKEN:-} ]]; then
|
|
printf 'Error: set GITEA_TOKEN to a Gitea access token with package write permission.\n' >&2
|
|
exit 2
|
|
fi
|
|
|
|
upload_url="https://git.ajpanton.se/api/packages/ajp_anton/rpm/fedora/${fedora_release}/upload"
|
|
|
|
curl \
|
|
--fail-with-body \
|
|
--show-error \
|
|
--silent \
|
|
--user "ajp_anton:${GITEA_TOKEN}" \
|
|
--upload-file "$rpm_path" \
|
|
"$upload_url"
|
|
|
|
printf 'Published %s for Fedora %s.\n' "$rpm_path" "$fedora_release"
|