39 lines
1.4 KiB
Bash
Executable File
39 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
fail() {
|
|
echo "$*" >&2
|
|
exit 2
|
|
}
|
|
|
|
[ "$#" -ge 1 ] || fail "usage: $0 <gitea-token-file> [rust_realease options...]"
|
|
token_file=$1
|
|
shift
|
|
[ -f "$token_file" ] && [ -r "$token_file" ] || fail "token file must be a readable regular file"
|
|
for tool in rust_realease cargo jq; do
|
|
command -v "$tool" >/dev/null 2>&1 || fail "$tool is not installed or not available in PATH"
|
|
done
|
|
|
|
unset GITEA_TOKEN
|
|
GITEA_TOKEN=
|
|
IFS= read -r GITEA_TOKEN <"$token_file" || :
|
|
[ -n "$GITEA_TOKEN" ] || fail "token file has an empty first line"
|
|
|
|
repository_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
# Query the member's resolved version, including workspace inheritance. Keep the
|
|
# token unexported until Cargo has finished; it belongs only to the publisher.
|
|
metadata=$(cargo metadata --offline --no-deps --format-version 1 \
|
|
--manifest-path "$repository_dir/Cargo.toml") || fail "could not read Cargo metadata"
|
|
manifest_version=$(printf '%s\n' "$metadata" | jq -er \
|
|
'[.packages[] | select(.name == "fader_master") | .version] |
|
|
if length == 1 and (.[0] | type == "string" and length > 0)
|
|
then .[0] else error("unresolved package version") end') \
|
|
|| fail "could not determine fader_master package version"
|
|
|
|
set -- "$repository_dir" --package fader_master --artifact-format both "$@"
|
|
case "$manifest_version" in
|
|
*-*) set -- "$@" --prerelease ;;
|
|
esac
|
|
export GITEA_TOKEN
|
|
exec rust_realease "$@"
|