scripts: minor improvements

This commit is contained in:
Ryan Heywood 2025-02-04 22:01:56 -05:00
parent aa8526cda0
commit 083eb16b39
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
2 changed files with 11 additions and 4 deletions

View File

@ -1,13 +1,18 @@
#!/bin/bash
set -eu
set -o pipefail
scripts_dir="$(dirname $0)"
scripts_dir="$(dirname "$0")"
python_script="$scripts_dir/generate-dependency-queue.py"
registry_url="https://git.distrust.co/api/packages/public/cargo"
search_url="${registry_url}/api/v1/crates"
cargo metadata --format-version=1 | python3 "$python_script" | while read crate version; do
cargo metadata --format-version=1 | python3 "$python_script" | while read -r crate version; do
# Verify the package does not exist
if test "${crate}" = "keyfork-tests"; then
continue
fi
if ! curl "${search_url}?q=${crate}" 2>/dev/null | jq -e "$(printf '.crates | .[] | select(.name == "%s" and .max_version == "%s")' "$crate" "$version")" >/dev/null; then
cargo publish --registry distrust -p "$crate"
fi

View File

@ -1,3 +1,4 @@
#!/bin/bash
set -eu
set -o pipefail
@ -8,8 +9,8 @@ temp_file="$(mktemp)"
cargo metadata --format-version=1 | jq -r '.packages[] | select(.source == null) | .name + " " + .manifest_path + " " + .version' > "$temp_file"
while read crate manifest_path version <&3; do
crate_path="$(dirname $manifest_path)"
while read -r crate manifest_path version <&3; do
crate_path="$(dirname "$manifest_path")"
git_log="$(git log --format='%h %s' "$LAST_REF".."$CURRENT_REF" "$crate_path")"
git_tag="$(git tag --list "$crate-v${version}")"
if test ! -z "$git_log" -a -z "$git_tag"; then
@ -22,6 +23,7 @@ while read crate manifest_path version <&3; do
echo ""
echo "# Crate: ${crate} ${version}"
} | git tag --sign "${crate}-v${version}" -F - -e
reset
echo "Making new tag: ${crate}-v${version}"
fi
done 3<"$temp_file"