49 lines
1.1 KiB
Bash
Executable File
49 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
usage() {
|
|
echo "usage: $0 <gitea-token-file> [rust_realease options...]" >&2
|
|
exit 2
|
|
}
|
|
|
|
[ "$#" -ge 1 ] || usage
|
|
token_file=$1
|
|
shift
|
|
|
|
if [ ! -f "$token_file" ] || [ ! -r "$token_file" ]; then
|
|
echo "token file is not a readable regular file: $token_file" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! command -v rust_realease >/dev/null 2>&1; then
|
|
echo "rust_realease is not installed or not available in PATH" >&2
|
|
exit 2
|
|
fi
|
|
|
|
GITEA_TOKEN=
|
|
IFS= read -r GITEA_TOKEN <"$token_file" || :
|
|
if [ -z "$GITEA_TOKEN" ]; then
|
|
echo "token file is empty: $token_file" >&2
|
|
exit 2
|
|
fi
|
|
export GITEA_TOKEN
|
|
|
|
repository_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
manifest_version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' \
|
|
"$repository_dir/Cargo.toml" | head -n 1)
|
|
if [ -z "$manifest_version" ]; then
|
|
echo "could not determine the selected package version" >&2
|
|
exit 2
|
|
fi
|
|
|
|
set -- \
|
|
"$repository_dir" \
|
|
--package rping \
|
|
--artifact-format both \
|
|
"$@"
|
|
case "$manifest_version" in
|
|
*-*) set -- "$@" --prerelease ;;
|
|
esac
|
|
|
|
exec rust_realease "$@"
|